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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:55:56+00:00 2026-06-18T15:55:56+00:00

I want to create soap envelope with security header in android using ksoap2. My

  • 0

I want to create soap envelope with security header in android using ksoap2. My code of android is as…

import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.kxml2.kdom.Element;
import org.kxml2.kdom.Node;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class SOP_WebService extends Activity
{

    private final String NAMESPACE = "http://xmlns.oracle.com/WorklistRetrival";
    private final String URL = "http://www.sample.com/orabpel/default/WorklistRetrival/1.0";
    private final String SOAP_ACTION = "process";
    private final String METHOD_NAME = "WorklistRetrievalREQ";  

    public void onCreate(Bundle savedInstanceState) 
    {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.soap_webservice);

         Button btnClick = (Button) findViewById(R.id.btnClick);
         btnClick.setOnClickListener(new OnClickListener()
         {
            @Override
            public void onClick(View v) 
            {
                callWebservice();
            }
        });
    }

    public void callWebservice()
    {

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        PropertyInfo pi = new PropertyInfo();
        pi.setNamespace(NAMESPACE);
        pi.setName("WorklistType"); 
        pi.setValue("PO_REQUISITION"); 
        request.addProperty(pi);

        PropertyInfo p2 = new PropertyInfo();
        p2.setNamespace(NAMESPACE);
        p2.setName("Status"); 
        p2.setValue("TODO"); 
        request.addProperty(p2);

        PropertyInfo p3 = new PropertyInfo();
        p3.setNamespace(NAMESPACE);
        p3.setName("Mode"); 
        p3.setValue(""); 
        request.addProperty(p3);


         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        Log.i("bodyout", "" + envelope.bodyOut.toString());

        try 
        {
            androidHttpTransport.debug = true;
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
            Log.i("myApp", response.toString());
            Log.i("request", "" + envelope.bodyIn);
            Log.i("response", "" + envelope.bodyOut);
            Log.i("request", "" + androidHttpTransport.requestDump);
            Log.i("response", "" + androidHttpTransport.responseDump);
        } 
        catch (SoapFault e)
        {
            Log.d("soapFault", "soapFault");
            e.printStackTrace();
        }
        catch (Exception e) 
        {
            Log.d("Exception", "Exception");
            e.printStackTrace();
            Log.d("Exception Generated", ""+e.getMessage());
        }

    }

}

And above code create below soap request without security header.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <soap:Header>
    </soap:Header>
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/bpel/aubi/mobile/Worklist">
        <ns1:WorklistRetrievalREQ>
            <ns1:WorklistType>HR_OFFER</ns1:WorklistType>
            <ns1:Status>TODO</ns1:Status>
            <ns1:Mode/>
        </ns1:WorklistRetrievalREQ>
    </soap:Body>
</soap:Envelope>

But I need to create below soap request with security header

<soap:Envelope 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

    <soap:Header>
        <wsse:Security 
            xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
            xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
            xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" soap:mustUnderstand="1">
                <wsse:UsernameToken 
                    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
                    xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                            <wsse:Username>cbrown</wsse:Username>
                            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">welcome</wsse:Password></wsse:UsernameToken>
        </wsse:Security>
    </soap:Header>
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/bpel/aubi/mobile/Worklist">
        <ns1:WorklistRetrievalREQ>
            <ns1:WorklistType>HR_OFFER</ns1:WorklistType>
            <ns1:Status>TODO</ns1:Status>
            <ns1:Mode/>
        </ns1:WorklistRetrievalREQ>
    </soap:Body>
</soap:Envelope>

Please tell me what kind of change are made in this code

  • 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-06-18T15:55:57+00:00Added an answer on June 18, 2026 at 3:55 pm

    I have found my question’s answer. I am put answer to useful others.

    public class SOAP_WebService extends Activity
    {
    
        private final String NAMESPACE = "http://ws.simple/";
        private final String URL = "http://10.0.2.2/SimpleWebservice/simple";
        private final String SOAP_ACTION = "http://ws.simple/getString";
        private final String METHOD_NAME = "getString";
    
        public void onCreate(Bundle savedInstanceState) 
        {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.soap_webservice);
    
             Button btnClick = (Button) findViewById(R.id.btnClick);
             btnClick.setOnClickListener(new OnClickListener()
             {
                @Override
                public void onClick(View v) 
                {
                    callWebservice();
                }
            });
        }
        public void callWebservice()
        {
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            PropertyInfo weightProp =new PropertyInfo();
            weightProp.name = "arg0";
            weightProp.setValue("rajan");
            request.addProperty(weightProp);
    
    
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    
    
            // create header
            Element[] header = new Element[1];
            header[0] = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","Security");
            header[0].setAttribute(null, "mustUnderstand","1");
    
            Element usernametoken = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "UsernameToken");
            usernametoken.setAttribute(null, "Id", "UsernameToken-1");
            header[0].addChild(Node.ELEMENT,usernametoken);
    
            Element username = new Element().createElement(null, "n0:Username");
            username.addChild(Node.IGNORABLE_WHITESPACE,"CBROWN");
            usernametoken.addChild(Node.ELEMENT,username);
    
            Element pass = new Element().createElement(null,"n0:Password");
            pass.setAttribute(null, "Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
            pass.addChild(Node.TEXT, "welcome");
    
            usernametoken.addChild(Node.ELEMENT, pass);
    
    
            // add header to envelope
            envelope.headerOut = header;
    
    
            Log.i("header", "" + envelope.headerOut.toString());
    
    
            envelope.dotNet = false;
            envelope.bodyOut = request;
            envelope.setOutputSoapObject(request);
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            Log.i("bodyout", "" + envelope.bodyOut.toString());
    
            try 
            {
                androidHttpTransport.debug = true;
                androidHttpTransport.call(SOAP_ACTION, envelope);
    
                SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
                Log.i("myApp", response.toString());
            } 
            catch (SoapFault e)
            {
                e.printStackTrace();
            }
            catch (Exception e) 
            {
                e.printStackTrace();
                Log.d("Exception Generated", ""+e.getMessage());
            }
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a listener for soap messages. Can this be done using
Hi I want to create a soap service. When i run it, the service
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =
I want to create a soap enumeration value in php. Here is the complex
I want to create and publish simple WebService using Java. Everything compiles. When I
I realize it's possible to create a PHP Web Service using SOAP, however, are
I want to create a WSS header to authentificate on secured web services. I
I want to create my wsdl by spring-ws automatically and I inserted the code
I want to set up a SOAP development enviornment. So I can create web
i want to create a webservice (SOAP & REST) in python which cab be

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.