【问题标题】:java.net.ServerTimeoutException in VB.Net web serviceVB.Net Web 服务中的 java.net.ServerTimeoutException
【发布时间】:2012-09-09 03:20:39
【问题描述】:

我制作了一个 VB.Net Web 服务。这将由 IIS 7.0 中的 Android Emulator 调用。返回 2 位总和的简单方法可以正常工作,但是当我尝试在数据库 MY SQL SERVER 中插入记录时,它会生成 java.net.ServerTimeoutException。但是当我当时尝试从浏览器运行它时,它会正常工作,这意味着它能够在数据库中插入记录,但从 Android 模拟器它会给出一个异常。

package com.BuddiesHub;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

public class Register extends Activity
{
EditText mobno,password,cnfpassword,secqus,secans;
Button register;    

public final String SOAP_ACTION = "http://tempuri.org/doRegister";
public  final String OPERATION_NAME = "doRegister"; 
public  final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
public  final String SOAP_ADDRESS = "http://10.0.2.2/BuddiesHub/Service.asmx";

SoapSerializationEnvelope envelope=null;
HttpTransportSE httpTransport=null;
PropertyInfo pi=null;
SoapObject request=null;
Object response=null;
//private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";


 /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.register);

    mobno=(EditText)findViewById(R.id.txtmobno);
    password=(EditText)findViewById(R.id.txtpassword);
    cnfpassword=(EditText)findViewById(R.id.txtcnfpassword);
    secqus=(EditText)findViewById(R.id.txtsecqus);
    secans=(EditText)findViewById(R.id.txtsecans);

    register=(Button)findViewById(R.id.btnregister);
    register.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);

        //mobno ,name,secqus,secans

        pi=new PropertyInfo();
        pi.setName("mobno");
        pi.setValue(mobno.getText().toString());
        pi.setType(String.class);
        request.addProperty(pi);

        pi=new PropertyInfo();
        pi.setName("name");
        pi.setValue(password.getText().toString());
        pi.setType(String.class);
        request.addProperty(pi);

        pi=new PropertyInfo();
        pi.setName("secqus");
        pi.setValue(secqus.getText().toString());
        pi.setType(String.class);
        request.addProperty(pi);

        pi=new PropertyInfo();
        pi.setName("secans");
        pi.setValue(secans.getText().toString());
        pi.setType(String.class);
        request.addProperty(pi);

        envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);
        httpTransport = new HttpTransportSE(SOAP_ADDRESS);
        //SoapObject response=null;
        // response = null;
        //String result = null;

        try
        {
            httpTransport.call(SOAP_ACTION, envelope);
            response = envelope.getResponse().toString();
            Toast.makeText(getBaseContext(), response.toString(), Toast.LENGTH_LONG ).show();
        }
        catch (Exception exception)
        {
            response=exception.toString();
            Toast.makeText(getBaseContext(), response.toString(), Toast.LENGTH_LONG ).show();
        }
    } });
}

}

【问题讨论】:

    标签: android vb.net web-services exception


    【解决方案1】:

    你添加了吗

    <uses-permission android:name="android.permission.INTERNET"/>
    

    到您的 AndroidManifest.xml?

    【讨论】:

    • 亲爱的 Jeff,是的,我在 AndroidManifest.xml 文件中添加了该权限。不处理数据库的简单方法调用成功并返回真值,但只有处理数据库的方法产生异常。
    猜你喜欢
    • 2011-01-18
    • 1970-01-01
    • 1970-01-01
    • 2012-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多