简体   繁体   中英

Android KSOAP2 call ASMX Web Service

class wsCall extends AsyncTask {

private static final String SOAP_ACTION = "http://tempuri.org/PrivateLogin";
private static final String METHOD_NAME = "PrivateLogin";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://192.168.1.110/omoffice/service/wsomjobs.asmx";        
private Context mContext;   

public wsCall (Context context){
     mContext = context;
}

 @Override
protected void onPreExecute() {
    // TODO Auto-generated method stub
    super.onPreExecute();
}

protected String doInBackground(String... params) 
{   
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    request.addProperty("userid","poma");           
    request.addProperty("pw","1");
    request.addProperty("azienda","1");

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);             
    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);               
        SoapObject response = (SoapObject) envelope.bodyIn;
        return "OK";

In androidHttpTransport.call(SOAP_ACTION, envelope) I obtain this error: java.net.ProtocolException: unexpected end of stream

Someone help me?

thanks Marco

Are you sure if SOAP version you are using is 10??

try using SoapPrimitive response = (SoapPrimitive) envelope.getResponse(); instead of SoapObject response = (SoapObject) envelope.bodyIn;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM