1
我正在調用Soap Web服務。它工作正常,但有些時候我正在通過對等異常獲得連接重置。由對等方重置的連接在SOAP Web服務中異常調用
這是我的web服務的代碼中調用
new Thread(new Runnable() {
public void run() {
Looper.prepare();
String response = "";
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(serverRequestParams.getSoapObject());
HttpTransportSE httpTransport = new HttpTransportSE(serverRequestParams.getUrl(),90000);
httpTransport.debug = true;
try {
HttpParams my_httpParams = new BasicHttpParams();
final String proxyHost = android.net.Proxy.getDefaultHost();
final int proxyPort = android.net.Proxy.getDefaultPort();
if(proxyPort != -1)
{
my_httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxyHost, proxyPort));
}
httpTransport.call(serverRequestParams.getSoapAction(), envelope);
Object data = envelope.getResponse();
if (data instanceof SoapObject) {
SoapObject data2 = (SoapObject) data;
response = data2.toString();
} else if (data instanceof SoapPrimitive) {
SoapPrimitive data3 = (SoapPrimitive) data;
response = data3.toString();
} else if (data != null) {
response = data.toString();
} else if (data == null) {
response = "nodata";
}
}
catch (Exception e) {
System.out.print("Exception:"+e);
}