0
我在我的應用程序中使用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