3

I have problem accessing a complex WCF web service in Android. The details about my question are as follows:

A typical request to the WCF Web Service has the following XML:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header><Action s:mustUnderstand="1"xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/manojService/MethodName</Action> 
  </s:Header>
  <s:Body>
    <MethodName xmlns="http://tempuri.org/">
      <name>ABC</name>
      <Collection xmlns:d4p1="http://schemas.datacontract.org/2004/07/YXZ.Model" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <d4p1:location>whatever</d4p1:location>
        <d4p1:OfficeLocation>
          <d4p1:Lattitude>28.5</d4p1:Lattitude>
          <d4p1:LocationID>0</d4p1:LocationID>
        </d4p1:OfficeLocation>
      </Collection>
      <Action>Add</Action>   
    </MethodName> 
  </s:Body>
</s:Envelope>

I am using simple SOAP concept for login using KSoap library as below:

try {   
    StringBuilder sb = null;
    SoapObject request = new SoapObject("http://tempuri.org/",
            "methodName");
    request.addProperty("name", "aaaa");

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE( "Service urls");
    androidHttpTransport.call("http://tempuri.org/manojService/MethodName", envelope);
    Object result = (Object) envelope.getResponse();
    String resultData = result.toString();
    System.out.println("result Data :-" + resultData);

} catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
    System.out.println("error is occured :-" + e.getMessage());
}

If you have any solutions for sending the data of array type in soap then please let me know.

Jeroen
  • 60,696
  • 40
  • 206
  • 339
Manoj Kumar
  • 587
  • 2
  • 9
  • 20
  • 1
    Your actual question probably lies in the final sentence, but it's not entirely clear what the actual problem is, how you tried to solve it, and where you got stuck? – Jeroen Oct 01 '12 at 12:40
  • Actually, want to access the WCF Web service according to my above xml request. – Manoj Kumar Oct 01 '12 at 13:02
  • Recently I am getting this error:Object reference not set to an instance of an object. – Manoj Kumar Oct 01 '12 at 13:03
  • You're better off *updating the question*, as opposed to commenting. If your edit is substantial this will bump your question, getting people's attention. Please make sure you're specific about your problem, and tell us [what you've tried](http://whathaveyoutried.com) to solve the problem. – Jeroen Oct 01 '12 at 13:10
  • Can you post on how your WCF service looks like? And what bindings were configured for it to help you out – Rajesh Jul 10 '13 at 14:48
  • see my answer here http://stackoverflow.com/questions/12457758/android-want-to-transfer-data-from-sqlite-db-to-web-server/12457828#12457828 – Shruti Sep 13 '13 at 12:25

0 Answers0