如何在SOAP请求中处理多个标记Body
问题描述:
我在我的应用程序中使用SOAP Webservice。我面临的问题是,SOAP请求体中有一个额外的标记。因为我得到了SOAP错误“SoapFault - faultcode:'soap:Server'faultstring:'服务器无法处理请求。”>对象引用未设置为对象的实例。 faultactor:'null'详细信息:[email protected]“。如何在SOAP请求中处理多个标记Body
这里是SOAP请求....
POST /appws.asmx HTTP/1.1
Host: www.xxxxxx.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://xxxxxxx.com/saveCustomerProfile"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<saveCustomerProfile xmlns="http://xxxxxx.com/">
<customerProfile>
<id>long</id>
<name>string</name>
<lastName>string</lastName>
<phoneNumber>string</phoneNumber>
<zipCode>string</zipCode>
<email>string</email>
<birthday>string</birthday>
<gender>string</gender>
<emailExclusiveSavings>boolean</emailExclusiveSavings>
<textExclusiveSavings>boolean</textExclusiveSavings>
</customerProfile>
</saveCustomerProfile>
</soap:Body>
</soap:Envelope>
这里是我使用调用此WebService
SoapObject request = new SoapObject(NAMESPACE, "saveCustomerProfile");
request.addProperty("id", 0);
request.addProperty("name","aaaaa");
request.addProperty("lastName","bbbbbb");
request.addProperty("phoneNumber", "1234567890");
request.addProperty("zipCode", "1234");
request.addProperty("email", "[email protected]");
request.addProperty("birthday", "02/02/2011");
request.addProperty("gender", "male");
request.addProperty("emailExclusiveSavings","true");
request.addProperty("textExclusiveSavings", "false");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.call(SOAP_ACTION, envelope);
System.out.println("response "+envelope.getResponse());
我发现那里的问题正在发生的代码。
<saveCustomerProfile xmlns="http://xxxxxx.com/">
<customerProfile>
通常在SOAP体内只有一个主标签,在这里我有两个和。我不知道如何处理它。我已经检查过一些其他的SOAP Web服务,所有的都在使用相同的代码。请帮帮我。
感谢您的答复....但是,这是没有帮助的,这就是我们如何能够使SOAP请求正常的方式,而不是像我所期待的。 – Aju 2012-07-26 12:14:15