0

I am a newbie in soap web services calling in an android,I called Url, I send parameter also,

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

soap description link is as follows : selticketprice

java code for calling soap webservices are :

                   protected String doInBackground(String... params) {
    // TODO Auto-generated method stub
    final SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_memberRegistration);
        // SerializationUtils.serialize(bFile);
        request.addProperty("fareMediaType", "SJT");
        request.addProperty("fromValue", "1");
        request.addProperty("toValue", "3");
        request.addProperty("ticketDate", "2016-09-29");
        request.addProperty("lang", "en");
        final SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.headerIn = new Element[1];
        envelope.headerIn[0] = buildAuthHeader();
        new MarshalBase64().register(envelope);

        envelope.setOutputSoapObject(request);

        envelope.dotNet = true;
        HttpTransportSE androidHttpTransport = new HttpTransportSE(signUpURL);
        try {
            androidHttpTransport.call(SOAP_ACTION_memberRegistration, envelope);
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            res = response.toString();

        } catch (Exception e) {
            Log.e("exception", e.getMessage(),e);
        }

    return res;
}

private Element buildAuthHeader() {
    Element h = new Element().createElement(NAMESPACE, "AuthHeader");
    Element username = new Element().createElement(NAMESPACE, "Username");
    username.addChild(Node.TEXT, "name");
    h.addChild(Node.ELEMENT, username);
    Element pass = new Element().createElement(NAMESPACE, "Password");
    pass.addChild(Node.TEXT, "*******");
    h.addChild(Node.ELEMENT, pass);

    return h;
}     

1 Answers1

0

Have you considered making the soap request without the use of Soap libraries? This is more accurate and you can track down where an exception occurs as opposed to libs. Also its best for long term situations where the service changes and you cannot use the library. Go through my answer here Call a soap webservice in android

Community
  • 1
  • 1
Gordon developer
  • 387
  • 3
  • 13