Android's WebService SOAP protocol and server interaction, problem solving overtime

 
Most Web search can not actually solve the problem. The solution specially wrote. 
Creating MyAndroidHttpTransport class,

Package Penalty for com.example.omhandroid.lib;

Import org.ksoap2.transport.HttpTransportSE;
Import org.ksoap2.transport.ServiceConnection;

Import java.io.IOException;
Import java.net.SocketException;

public class MyAndroidHttpTransport the extends HttpTransportSE {

Private int timeout = 600000; // default timeout is 10 * 60s Private int ReadTimeout = 600000; // default timeout is 10 * 60s public MyAndroidHttpTransport (String URL) { Super (URL); } public MyAndroidHttpTransport (String URL, timeout int) { Super (URL); the this.







timeout = timeout;
}
public ServiceConnection getServiceConnection() throws IOException {
return new org.ksoap2.transport.ServiceConnectionSE(this.proxy, this.url, this.timeout, this.readTimeout);
}
}



调用如下:

// generates a call WebService method call information of soap, Soap and specify the version
SoapSerializationEnvelope Envelope = new new SoapSerializationEnvelope (SoapEnvelope. VER11);
// whether to invoke DotNet development WebService
Envelope. DotNet = to true;

envelope.setOutputSoapObject (Request);

MyAndroidHttpTransport httpTransport = MyAndroidHttpTransport new new ( SOAP_ADDRESS);

. httpTransport Debug = to true;
the try {
httpTransport.call ( WSDL_TARGET_NAMESPACE + OPERATION_NAME, Envelope);
Object envelope.getResponse Response = ();
return response.toString ();
} the catch (Exception Exception) {
Exception. printStackTrace ();
return"";
}

Found effective, safe to use

Guess you like

Origin www.cnblogs.com/ninilwh/p/11607429.html