我在我的应用程序中使用SOAP请求,因为我的SOAP请求结构如下:
<Data>
<Keys>
<String>
<V>string</V>
<K>string</K>
</String>
<String>
<V>string</V>
<K>string</K>
</String>
<Keys>
<CriteriaKeys>
<String>
<V>string</V>
<K>string</K>
</String>
<String>
<V>string</V>
<K>string</K>
</String>
</CriteriaKeys>
<No>int</No>
<Size>int</Size>
</Data>
在此我遇到了设置请求输入的问题。如何使用addproperty方法为此复杂类型设置输入。以下是我的SOAP调用代码:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject authentication = new SoapObject(NAMESPACE,"authentication");
Setting property for authentication
request.addSoapObject(authentication);
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet=true;
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.call(SOAP_ACTION,envelope);
SoapObject result=(SoapObject)envelope.getResponse();
Log.i("myApp",result.toString());
}
答案 0 :(得分:1)
如果您使用的是本机方法/ HTTP类,那么可以通过简单的方法在您的网络电话中设置此请求:
HttpPost post = new HttpPost(url);
post.setEntity(new StringEntity(yourxmlrequestString, "utf-8"));