我在我的应用程序中使用 SOAP Webservice。我面临的问题是,SOAP 请求正文中有一个额外的标签。因此,我收到 SOAP 错误错误“SoapFault - faultcode: 'soap:Server' faultstring: 'Server was unable to process request.---> Object reference not set to an instance of an object.' faultactor:'null' 详细信息:org.kxml2.kdom.Node@40516ce8"。
这是 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>
这是我用来调用此网络服务的代码
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", "123@gmail.com");
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 服务,它们都在使用相同的代码。请帮我。