我正在尝试使用 ksoap2 访问 .NET Web 服务,但我不知道它为什么不起作用。
我已经阅读了很多教程,但仍然无法正常工作。总是得到错误:
at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1413)
at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)
at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
at br.android.listgame.Activitys.ListSimpleActivity.onCreate(ListSimpleActivity.java:108)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1721)
at android.app.ActivityThread.access$1500(ActivityThread.java:124)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3844)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
我已经使用soapUI 测试了web 服务,它工作正常。
SoapObject soap = new SoapObject(NAMESPACE, OPERATION);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soap.addProperty("nome", "artur");
envelope.dotNet = true;
envelope.setOutputSoapObject(soap);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
try {
httpTransport.call(SOAP_ACTION, envelope);
resposta = envelope.getResponse().toString();
} catch (IOException ioex) {
ioex.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
我已经将 .jar 添加到项目中并添加为库,并且我也设置了使用互联网的权限。
我正在使用安卓 2.2