1

アプリで SOAP Web サービスを使用しています。私が直面している問題は、SOAP リクエストの本文に余分なタグが 1 つあることです。そのため、SOAP Fault エラー "SoapFault - faultcode: 'soap:Server' faultstring: 'Server was Could 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>

このWebサービスを呼び出すために使用しているコードは次のとおりです

   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 ボディ内にはメイン タグが 1 つだけありますが、ここでは と の 2 つがあります。私はそれを処理する方法がわかりません。他の SOAP Web サービスで確認したところ、すべて同じコードで動作しています。私を助けてください。

4

1 に答える 1

0

このチュートリアルを参照してください..役立つかもしれません:

于 2012-07-26T10:47:19.253 に答える