0

I am trying to connect to a webside using SOAP and returning result in JSON format. However I'm really black on the subject and really need some guidance..

My SoapAccess code:

  public SoapAccess (){
        this.user_id = "MYID";
        this.password = "MYPASSWORD";
        this.busstop_id = "16010366";


    Thread networkThread = new Thread() {
    @Override
     public void run() {
          try {

    //Initialize soap request + add parameters
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);        

    request.addProperty("user", user_id);
    request.addProperty("password",password);
    request.addPropertyIfValue("busStopId", busstop_id);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request);

    // Make the soap call.
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

        androidHttpTransport.call(SOAP_ACTION, envelope);     

        SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
        Log.i("myapp",result.toString());
        System.out.println(" --- response ---- " + result); 
             }
             catch (Exception e) {
                 e.printStackTrace();
             }

            }
        };
    networkThread.start();
    }

The SOAP looks like this:

    POST /InfoTransit/userservices.asmx HTTP/1.1
Host: 10.0.2.52
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://miz.it/infotransit/getUserRealTimeForecastByStop"

<?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>
    <getUserRealTimeForecastByStop xmlns="http://miz.it/infotransit">
      <auth>
        <user>string</user>
        <password>string</password>
      </auth>
      <handShakeUser>
        <userIdentifier>string</userIdentifier>
        <token>string</token>
        <response>NONE or Success or GenericError or NotValidToken or NoExistingUser or WsAuthenticationError</response>
      </handShakeUser>
      <busStopId>string</busStopId>
    </getUserRealTimeForecastByStop>
  </soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?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>
    <getUserRealTimeForecastByStopResponse xmlns="http://miz.it/infotransit">
      <getUserRealTimeForecastByStopResult>string</getUserRealTimeForecastByStopResult>
    </getUserRealTimeForecastByStopResponse>
  </soap:Body>
</soap:Envelope>

System Error in LogCat:

04-23 17:31:50.819: W/System.err(11156): SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
04-23 17:31:50.819: W/System.err(11156):    at UserServices.isWsAuthenticatedPUB(WsAuthentication _wsAuth) in c:\DISK_E\SAE\Infotransit\App_Code\UserServices.cs:line 609
04-23 17:31:50.819: W/System.err(11156):    at UserServices.getUserRealTimeForecastByStop(WsAuthentication auth, HandShake handShakeUser, String busStopId) in c:\DISK_E\SAE\Infotransit\App_Code\UserServices.cs:line 460
04-23 17:31:50.819: W/System.err(11156):    --- End of inner exception stack trace ---' faultactor: 'null' detail: org.kxml2.kdom.Node@41b00dc0
04-23 17:31:50.819: W/System.err(11156):    at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:141)
04-23 17:31:50.823: W/System.err(11156):    at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
04-23 17:31:50.823: W/System.err(11156):    at org.ksoap2.transport.Transport.parseResponse(Transport.java:116)
04-23 17:31:50.823: W/System.err(11156):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:259)
04-23 17:31:50.823: W/System.err(11156):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)
04-23 17:31:50.823: W/System.err(11156):    at com.mso.master.SoapAccess$1.run(SoapAccess.java:58)

Is there anyone that can give me a pinpoint on how to connect to this webside and get some result out?

Maggie
  • 33
  • 2
  • 6

1 Answers1

0

If you are just trying to connect to website and get the contents (JSON), I would recommend using java httpconnection class. You can get a inputstream of the contents of the file.

Guru
  • 916
  • 3
  • 12
  • 22