Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7405953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:28:56+00:00 2026-05-29T05:28:56+00:00

I’m developing an Android app which needs to connect to a .NET SOAP web

  • 0

I’m developing an Android app which needs to connect to a .NET SOAP web service and generate/populate a number of objects from the response. I’m totally new to web services and SOAP, and relatively new to Android. The web service has already been built (not by me).

I’ve been trying to find info on connecting to SOAP web services in Android. The two basic suggestions seem to be:

  1. Don’t use SOAP,
  2. If you do use SOAP, use KSOAP2.

I’ve looked at various tutorials for KSOAP2 but they all seem to deal only with the most basic, primitive types, such as sending 2 ints to get 1 int back, or sending and receiving strings;, however, I need to send custom objects back and forth.

Is it possible to send and receive custom objects using KSOAP2? If so, how easy/difficult is this? Does the XML have to be parsed to create/populate the objects “by hand”?

EDIT/UPDATE:
After trying for a while to connect to the existing webservice (takes a String and returns a complex object), and getting an error, I decided to try a simpler approach. I connected to a simpler webservice which takes no parameters, and returns an int. This simpler webservice is hosted in the same place as the original one, and the simple one now works fine for me.

FURTHER UPDATE:
All working fine now! Turns out I just had a capitalisation error which was throwing off my parameter.

The final problem was “national” versus “National”. Here’s the soapUI-generated code:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GetClientByNationalID>
         <!--Optional:-->
         <tem:nationalID>XXXXXXX</tem:nationalID>
      </tem:GetClientByNationalID>
   </soapenv:Body>
</soapenv:Envelope>

And the request code which was being generated by my Java:

<v: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/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
    <v:Header />
    <v:Body>
        <GetClientByNationalID xmlns="http://tempuri.org/" id="o0" c:root="1">
            <NationalID i:type="d:string">
                XXXXXXXX
            </NationalID>
        </GetClientByNationalID>
    </v:Body>
</v:Envelope>

My final java code is:

public void webServiceCall() {
    String NAMESPACE = "http://tempuri.org/";
    String METHOD_NAME = "GetClientByNationalID";
    String SOAP_ACTION = "http://tempuri.org/IClientService/GetClientByNationalID"; 

    // unsecure service
    String URL = "http://XXXXXXXXXXXXXXXXXXXX.net/FPUnSecureService/ClientService.svc";

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

    String clientID = "XXXXXXX";

    PropertyInfo pi = new PropertyInfo();
    pi.setName("nationalID"); 
    pi.setValue(clientID); 
    pi.setType(clientID.getClass()); 
    request.addProperty(pi);

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

    envelope.addMapping(NAMESPACE, "GetClientByNationalID", new ClientID().getClass());
    Marshal floatMarshal = new MarshalFloat();
    floatMarshal.register(envelope);

    HttpTransportSE t = new HttpTransportSE(URL); 

    ClientID client = new ClientID(); 
    t.debug = true; 

    try { 
        Log.i("webServiceCall", "Trying call to web service");
        t.call(SOAP_ACTION, envelope);
        SoapObject response = (SoapObject) envelope.getResponse();

        Log.i("success", response.getPropertyAsString(0)); 
        Log.i("success", response.getPropertyAsString(1));
        Log.i("success", response.getPropertyAsString(2));
        Log.i("success", response.getPropertyAsString(3));
        Log.i("success", response.getPropertyAsString(4)); 

    } catch (Exception e) {
        Log.e("webServiceCall", "Error calling webservice.");
        e.printStackTrace(); 
        System.out.println("Request: "  + t.requestDump); 
        System.out.println("Response: " + t.responseDump);
    }

}

I am still confused about these lines:

envelope.addMapping(NAMESPACE, "GetClientByNationalID", new ClientID().
Marshal floatMarshal = new MarshalFloat();
floatMarshal.register(envelope);

I think I added the Marshal parts when I was passing an object as a parameter, I’m not sure if I still need them. I’m also not sure about the addMapping call either, and what I should have in there. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:28:56+00:00Added an answer on May 29, 2026 at 5:28 am

    Use ksoap2, and check my answers with code examples at the following links: Link1,link2,link3. I wrote some details which will help you understand how to start coding.

    let me know if u need help.

    UPDATE ( Answering your question about mapping and marshalling)

    u use addMapping when you are Sending a complex type ( ie an object) through the soap envelope. How will the webservice recognize the complex type ? u need to create locally a class that implement kvmserializable (as mentionned in my links) which will have same parameter as the object on the server, and then u need to add mapping between it and the class that maps to it on the server, so that the enveloppe when parsed on the server it knows this complex type X map to class X on the server. So if you are not Sending complex type, you don’t need to add mapping.(PS:I see that your not sending a complex type since nationalID is of type string. IF lets say nationalID was a complex type of type Z you would do : addMapping(NAMESPACE, Z.class.getSimpleName(), Z.class) )

    As for marshalling, it uses java serialization to change Objects to stream of data to be unmarshalled on the web service. So when u are sending a complex type,based on my experience, it is a good practice to add marshalling to change the complex type to streams of data by serializing it. If you find that you don’t need it just don’t add it, but its always good to understand what are the options out there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.