Search code examples
androidksoap2android-ksoap2

ksoap2 error from server retrieving complextype Server was unable to process request. ---> Object reference not set to an instance of an object


I am getting the following error when requesting and retrieving with complex types from Android client:

Server was unable to process request. ---> Object reference not set to an instance of an object.' faultactor: 'null' detail: org.kxml2.kdom.Node

The wsdl:

<s:complexType name="AlFi_Rsp">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="RspResult" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="RspReason" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="RspExplain" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="RspInstruc" type="s:string"/>
</s:sequence>
</s:complexType>

<s:element name="wsVale">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="UserId" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Service" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="FiTerminal" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>

<s:element name="wsValeResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="wsValeResult" type="tns:AlFi_Rsp"/>
</s:sequence>
</s:complexType>
</s:element>

The client:

    PropertyInfo pi1 = new PropertyInfo();PropertyInfo pi2 = new PropertyInfo();
    PropertyInfo pi3 = new PropertyInfo();


    pi1.setName(KEY_USERID);
    pi2.setName(KEY_SERVICE);
    pi3.setName(KEY_FITERMINAL);

    pi1.setValue(VAR_USERID);
    pi2.setValue(VAR_SERVICE);
    pi3.setValue(VAR_FITERMINAL);

    pi1.setType(PropertyInfo.STRING_CLASS);
    pi2.setType(PropertyInfo.STRING_CLASS);
    pi3.setType(PropertyInfo.STRING_CLASS);

    request.addProperty(pi1);
    request.addProperty(pi2);
    request.addProperty(pi3);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11); // put all required data into a soap
                                    // envelope
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request); // prepare request
    envelope.implicitTypes = true;
    envelope.addMapping(XNAMESPACE, "AlFi_Rsp", OutValeResponse.class);

    HttpTransportSE httpTransport = new HttpTransportSE(XURL);
    httpTransport.debug = true;
    httpTransport.call(XSOAP_ACTION, envelope); // send request

envelope.bodyIn retrieves the above mentioned error.

Request dump:

<?xml version="1.0" encoding="UTF-8"?>
<v:Envelope xmlns:v="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/">
   <v:Header />
   <v:Body>
      <wsVale xmlns="https://.../AlCheq/">
         <UserId i:type="d:string">0</UserId>
         <Service i:type="d:string">0</Service>
         <FiTerminal i:type="d:string">0</FiTerminal>
      </wsVale>
   </v:Body>
</v:Envelope>

Response dump:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>Server was unable to process request. ---> Object reference not set to an instance of an object.' faultactor: 'null' detail: org.kxml2.kdom.Node</faultstring>
         <detail />
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

Both InVale and OutValeResponse classes implement KvmSerializable methods.

I am using last ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies and Android 2.2. Any suggestions?, I ve searched for this for days and do not get to the point.

Thanks for any help


Solution

  • Problem solved.

    Weird but finally it was an issue in the construction of NAMESPACE and SOAP action. I changed this

    String METHOD_NAME = "method";
    String NAMESPACE = "https://url/.../AlCheq/";
    String SOAP_ACTION = NAMESPACE + METHOD_NAME;
    

    for this

    String METHOD_NAME = "method";
    String SOAP_ACTION = "https://url/.../AlCheq/method";
    

    This means, it was something about the "/" in the NAMESPACE