我正在尝试在Android平台上使用客户端在ASP.net中构建一个简单的Web服务。我正在使用Soap库作为连接客户端。虽然我得到了我想要的结果,但它仍然显示为logcat中的错误。我想知道这里有什么问题。
MainActivity:
@Override
protected String doInBackground(String... params) {
String SOAP_Action = "http://tempuri.org/register";
String METHOD = "register";
String NAMESPACE = "http://tempuri.org/";
String URL = "http://myIP/Service.asmx";
try {
SoapObject Request = new SoapObject(NAMESPACE, METHOD);
Request.addProperty("name", params[0]);
Request.addProperty("city", params[1]);
Request.addProperty("address", params[2]);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Request);
HttpTransportSE transportSE = new HttpTransportSE(URL, 60000);
transportSE.call(SOAP_Action, envelope);
resultString = (SoapPrimitive) envelope.getResponse();
Log.d(TAG, "Data Added " + resultString);
} catch (Exception ex) {
Log.e(TAG, "Error: " + ex.getMessage());
ex.printStackTrace();
}
return null;
}
logcat的:
04-21 13:08:15.827 28309-28309/com.example.krupal.webserviceusingsoap W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=314.26392, y[0]=308.14453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=2728472, downTime=2725037, deviceId=0, source=0x1002 }
04-21 13:08:15.827 28309-28309/com.example.krupal.webserviceusingsoap W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=314.26392, y[0]=308.14453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=2728472, downTime=2725037, deviceId=0, source=0x1002 }
04-21 13:08:15.827 28309-28309/com.example.krupal.webserviceusingsoap W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=314.26392, y[0]=308.14453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=2728472, downTime=2725037, deviceId=0, source=0x1002 }
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap E/Response of Service: Error: Unexpected token (position:TEXT Entry Added Succ...@1:24 in java.io.InputStreamReader@a61dd4e)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT Entry Added Succ...@1:24 in java.io.InputStreamReader@a61dd4e)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:432)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:2048)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at org.ksoap2.transport.Transport.parseResponse(Transport.java:129)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at org.ksoap2.transport.HttpTransportSE.parseResponse(HttpTransportSE.java:301)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:274)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:113)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at com.example.krupal.webserviceusingsoap.Register$RegisterAsyncTask.doInBackground(Register.java:105)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at com.example.krupal.webserviceusingsoap.Register$RegisterAsyncTask.doInBackground(Register.java:47)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
04-21 13:08:22.010 28309-5265/com.example.krupal.webserviceusingsoap W/System.err: at java.lang.Thread.run(Thread.java:818)
04-21 13:08:22.012 28309-28322/com.example.krupal.webserviceusingsoap W/EGL_emulation: eglSurfaceAttrib not implemented
04-21 13:08:22.012 28309-28322/com.example.krupal.webserviceusingsoap W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7f7f5f999780, error=EGL_SUCCESS
04-21 13:08:22.098 28309-28322/com.example.krupal.webserviceusingsoap E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f7f56994930
Logcat中的第4行表示文本已成功添加,但仍然是错误而不成功。
需要帮助才能理解错误。
更新/答案:
问题来自网络服务,而不是来自Andriod编码方面。