VB.NetWebサービスを作成します。これは、IIS7.0のAndroidエミュレーターによって呼び出されます。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();
}
} });
}
}