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 724903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:16:35+00:00 2026-05-14T06:16:35+00:00

I am trying to post to my own test soap server (C#) with Android

  • 0

I am trying to post to my own test soap server (C#) with Android in combination with KSOAP2.

Now I have the specifications from the SOAP server, it expects:

POST /SharingpointCheckBarcode.asmx HTTP/1.1
Host: awc.test.trin-it.nl
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/checkBarcode"

<?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:Header>
    <AuthHeader xmlns="http://tempuri.org/">
      <username>string</username>
      <password>string</password>
    </AuthHeader>
  </soap:Header>
  <soap:Body>
    <checkBarcode xmlns="http://tempuri.org/">
      <barcode>string</barcode>
    </checkBarcode>
  </soap:Body>
</soap:Envelope>  

But what Android KSOAP2 sends out:

<?xml version="1.0" encoding="utf-8"?>
    <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>
            <checkBarcode xmlns="http://tempuri.org" id="o0" c:root="1">
                <username i:type="d:string">test</username>
                <password i:type="d:string">test</password>
                <barcode i:type="d:string">2620813000301</barcode>
            </checkBarcode>
        </v:Body>
    </v:Envelope>

With this code:

    try {
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        request.addProperty("username", "test");
        request.addProperty("password", "test");
        request.addProperty("barcode", "2620813000301");

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.encodingStyle = "test";

        envelope.setOutputSoapObject(request);

        AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport (URL); 
        androidHttpTransport.debug = true;
        androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");

        androidHttpTransport.call(SOAP_ACTION, envelope);
        Log.d("MyAPP", "----------------- " + androidHttpTransport.requestDump +"\r\n\r\n" + androidHttpTransport.responseDump);
        ((TextView)findViewById(R.id.lblStatus)).setText(androidHttpTransport.requestDump +"\r\n\r\n" + androidHttpTransport.responseDump);
    } catch(Exception E) {
        ((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage());
    }

The response I get back from the server is that there are no results found, so not an error, but when I test it with another App or PHP, it with the same data, it says it’s OK.

I think it’s because of the

  • 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-14T06:16:35+00:00Added an answer on May 14, 2026 at 6:16 am

    When you use addProperty this automatically adds it to the soap body, so thats wrong in your sample.

    If you want to set up a username/password security header you have to build up the necessary Element[] and set it with as headerOut on your envelope.

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.headerOut = security;
    

    To build up security as an Element[] you use something along these lines

            Element usernameElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "Username");
            usernameElement.addChild(Node.TEXT, username);
            Element passwordElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "Password");
            passwordElement.addChild(Node.TEXT, password);
    
            Element usernameTokenElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "UsernameToken");
            usernameTokenElement.addChild(Node.ELEMENT, usernameElement);
            usernameTokenElement.addChild(Node.ELEMENT, passwordElement);
    
            Element securityElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "Security");
            securityElement.setPrefix(null, OASIS_SECURITY_XSD_URL);
            securityElement.addChild(Node.ELEMENT, usernameTokenElement);
    

    and add it all up in an Element[] before you set it to headerOut

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

Sidebar

Related Questions

No related questions found

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.