我使用以下使用KSOAP Web服務調用的代碼。的Android KSOAP錯誤字符串問題
private static final String SOAP_ACTION = "http://www.tempuri.org/GetAuthenticateUser";
private static final String METHOD_NAME = "GetAuthenticateUser";
private static final String NAMESPACE = "http://www.tempuri.org/";
private static final String URL = "http://stage.mysite.com/FinancialSnapshotService/Service.asmx?WSDL";
// I have tried http://stage.mysite.com/FinancialSnapshotService/Service.asmx also
public void getResults() {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("vstrUserID", "[email protected]");
request.addProperty("vstrPassword", "password");
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
HttpTransportSE aht = new HttpTransportSE(URL);
try {
aht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
aht.call(SOAP_ACTION, soapEnvelope);
SoapObject result = (SoapObject) soapEnvelope.getResponse();
Log.d("WS", String.valueOf(result));
} catch (Exception e) {
e.printStackTrace();
}
}
雖然Web服務是完全OK(爲iPhone應用程序,因爲它工作正常),我得到錯誤:
05-03 16:47:49.427: WARN/ActivityManager(1194): Activity pause timeout for HistoryRecord{45cc0980 ksoap2app.main/.Ksoap2App}
05-03 16:47:49.821: WARN/System.err(4055): SoapFault - faultcode: 'soap:Client' faultstring: 'Server did not recognize the value of HTTP Header SOAPAction: http://www.tempuri.org/GetAuthenticateUser.' faultactor: 'null' detail: [email protected]
05-03 16:47:49.831: WARN/System.err(4055): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:112)
05-03 16:47:49.831: WARN/System.err(4055): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137)
05-03 16:47:49.831: WARN/System.err(4055): at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
05-03 16:47:49.831: WARN/System.err(4055): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
05-03 16:47:49.831: WARN/System.err(4055): at ksoap2app.main.Ksoap2App.getResults(Ksoap2App.java:44)
05-03 16:47:49.831: WARN/System.err(4055): at ksoap2app.main.Ksoap2App.onCreate(Ksoap2App.java:23)
05-03 16:47:49.831: WARN/System.err(4055): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-03 16:47:49.841: WARN/System.err(4055): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
05-03 16:47:49.841: WARN/System.err(4055): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
05-03 16:47:49.841: WARN/System.err(4055): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
05-03 16:47:49.841: WARN/System.err(4055): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
05-03 16:47:49.841: WARN/System.err(4055): at android.os.Handler.dispatchMessage(Handler.java:99)
05-03 16:47:49.841: WARN/System.err(4055): at android.os.Looper.loop(Looper.java:123)
05-03 16:47:49.841: WARN/System.err(4055): at android.app.ActivityThread.main(ActivityThread.java:4370)
05-03 16:47:49.841: WARN/System.err(4055): at java.lang.reflect.Method.invokeNative(Native Method)
05-03 16:47:49.841: WARN/System.err(4055): at java.lang.reflect.Method.invoke(Method.java:521)
05-03 16:47:49.851: WARN/System.err(4055): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-03 16:47:49.851: WARN/System.err(4055): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-03 16:47:49.851: WARN/System.err(4055): at dalvik.system.NativeStart.main(Native Method)
什麼是我的代碼的問題?
請檢查網絡服務是否正常運行。 – 2011-05-03 12:13:02
檢查這個鏈接,並確保你把東西正確... http://www.ibm.com/developerworks/webservices/library/ws-android/index.html – Farhan 2011-05-03 12:40:24
改變你的網址從'http://階段。 digitalavenues.com/C6FinancialSnapshotService/Service.asmx?WSDL'到** http://stage.digitalavenues.com/C6FinancialSnapshotService/Service.asmx**,然後再試一次。 – 2011-05-05 06:16:46