Android SOAP信封修改
应用程序将创建以下请求XML:Android SOAP信封修改,android,xml,soap,Android,Xml,Soap,应用程序将创建以下请求XML: <v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"> <v:Header /
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
some body...
</v:Body>
</v:Envelope>
这是一个logcat跟踪:
06-25 12:50:58.955: I/ENVELOPE_BODY(24323): XMLDataGet{property1=value1; property2=value2; property3=value3; property4=value4; }
06-25 12:50:59.630: D/GetInfo(24323): Exception REQUEST:
06-25 12:50:59.630: D/GetInfo(24323): <v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><XMLDataGet xmlns="http://tempuri.org/"><property1>value1</property1><property2>value2</property2><property3>value3</property3><property4>value4</property4></XMLDataGet></v:Body></v:Envelope>
06-25 12:50:59.635: D/GetInfo(24323): BodyIn
06-25 12:50:59.635: D/GetInfo(24323): null
06-25 12:50:59.635: D/GetInfo(24323): Exception RESPONSE:
06-25 12:50:59.635: D/GetInfo(24323): <s:Envelope xmlns:s="https://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema"><XMLDataGetResponse xmlns="https://tempuri.org/"><XMLDataGetResult><ItemList xmlns="">....the whole data structure...</ItemList></XMLDataGetResult></XMLDataGetResponse></s:Body></s:Envelope>
06-25 12:57:26.500: W/System.err(25523): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{https://schemas.xmlsoap.org/soap/envelope/}s:Envelope>@1:66 in java.io.InputStreamReader@42832a90)
@SHIDHIN.T.S,您在中管理过吗?请在您的代码中指出(在哪行之后),您如何确定
请求XML
@greenapps请解释您的意思…?您说应用程序创建以下请求XML:
。我想知道您在代码中知道它的位置。@greenapps好的,在我的“try”代码下面,有catch(异常e){Log.d(TAG,androidHttpTransport.requestDump);}我这里有这个xml。
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("entity", "persona");
request.addProperty("last_update_date", "20140101");
request.addProperty("country", "UA");
request.addProperty("user", "someuser");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
Log.i(TAG, "Envelope to String: \n" + String.valueOf(envelope));
Log.i(TAG, "request to String: \n" + String.valueOf(request));
envelope.implicitTypes = true;
envelope.setAddAdornments(false);
envelope.dotNet = true;
envelope.bodyOut = request;
envelope.setOutputSoapObject(request);
HttpTransportBasicAuth androidHttpTransport = null;
try
{
androidHttpTransport = new HttpTransportBasicAuth(URL, null, null);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.getResponse();
}
catch (SoapFault e)
{
e.printStackTrace();
Log.d(TAG, "2 HTTP REQUEST:\n" + androidHttpTransport.requestDump);
Log.d(TAG, "2 HTTP RESPONSE:\n" + androidHttpTransport.responseDump);
}
catch (Exception e)
{
e.printStackTrace();
SoapObject resultsRequestSOAP = (SoapObject)envelope.bodyIn;
Log.d(TAG, "Exception REQUEST:\n" + androidHttpTransport.requestDump);
Log.d(TAG, "BodyIn #2 \n" + resultsRequestSOAP);
Log.d(TAG, "Exception RESPONSE:\n" + androidHttpTransport.responseDump);
}
} catch (Exception e) {
e.printStackTrace();
}
}
06-25 12:50:58.955: I/ENVELOPE_BODY(24323): XMLDataGet{property1=value1; property2=value2; property3=value3; property4=value4; }
06-25 12:50:59.630: D/GetInfo(24323): Exception REQUEST:
06-25 12:50:59.630: D/GetInfo(24323): <v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><XMLDataGet xmlns="http://tempuri.org/"><property1>value1</property1><property2>value2</property2><property3>value3</property3><property4>value4</property4></XMLDataGet></v:Body></v:Envelope>
06-25 12:50:59.635: D/GetInfo(24323): BodyIn
06-25 12:50:59.635: D/GetInfo(24323): null
06-25 12:50:59.635: D/GetInfo(24323): Exception RESPONSE:
06-25 12:50:59.635: D/GetInfo(24323): <s:Envelope xmlns:s="https://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema"><XMLDataGetResponse xmlns="https://tempuri.org/"><XMLDataGetResult><ItemList xmlns="">....the whole data structure...</ItemList></XMLDataGetResult></XMLDataGetResponse></s:Body></s:Envelope>
06-25 12:57:26.500: W/System.err(25523): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{https://schemas.xmlsoap.org/soap/envelope/}s:Envelope>@1:66 in java.io.InputStreamReader@42832a90)
07-07 15:15:22.296: I/GetInfo(29392): Envelope to String:
07-07 15:15:22.296: I/GetInfo(29392): org.ksoap2.serialization.SoapSerializationEnvelope@42602660
07-07 15:15:22.296: I/GetInfo(29392): request to String:
07-07 15:15:22.296: I/GetInfo(29392): XMLDataGet{entity=persona; last_update_date=20140101; country=UA; user=someuser; }