How to add a Soap header to a Java client

Hello,
I am new in Web Services.I am struggling to set Header using Although is has been added through handler. But My requirement is to add Header at client side not from server side. Following test code is being used to set at header despite it is not working .
Map<String, Object> req_ctx = ((BindingProvider)c).getRequestContext();
     req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:7001/CalculatorWS/CalculatorProgram?wsdl");
     Map<String, List<String>> headers = new HashMap<String, List<String>>();
     headers.put("Username", Collections.singletonList("mkyong"));
     headers.put("Password", Collections.singletonList("password"));
     req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
Please help me to solve this problem.

Many thanks to reply.
It had been done by handler.Handler is deploy at server side,In contrast we need to set handler from client side. with the help of google i found piece of code, follow as below.But it is not working for me.
Need help am i missing something in this code Or what do i use different approach ?
Map<String, Object> req_ctx = ((BindingProvider)c).getRequestContext();
req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:7001/CalculatorWS/CalculatorProgram?wsdl");
Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("Username", Collections.singletonList("mkyong"));
headers.put("Password", Collections.singletonList("password"));
req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);

Similar Messages

  • How to add empty soap header?

    Hello,
    I created a web service proxy using WSDL and XSD files. Then, I created a sample request from client interface and sent the request as an object to call the web services. However, I am not directly calling the webservices as I am doing it through a Gateway. Here, the problem is, the Gateway accepts only empty SOAP headers and the Gateway inserts the security details in that SOAP header and will send a request to the original web services. Even if we add any element in the SOAP header, it is not accepting the request.
    While sending a request through the client interface(Java class), I am not able to generate a empty SOAP header and send as request. I tried several ways adding a empty header. but no result. Is there any way we can add empty SOAP header while sending a requesting through Java class(Client interface)?
    Thanks
    sekhar

    Thanks for your reply.
    I have tried different approaches for adding empty SOAP header with no elements. But, none of them worked. The only solution for this issue is to add OSB proxy which has the functionality to send empty SOAP header which worked for me.
    Thanks
    sekhar

  • How to add a soap header in the mesage

    Hi expert:
       We have a problem about this synchronous scenario: ECC(ABAP Proxy)>PI>P6(SOAP),  In P6,it need additional soap header as below:
    <soapenv:Header>
    <wsse:Security mustUnderstand="0" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <wsse:UsernameToken wsu:Id="UsernameToken-5700630" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsse:Username>admin</wsse:Username>
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</wsse:Password>
    </wsse:UsernameToken>
    </wsse:Security>
    </soapenv:Header>
    How can i add this header to the receiver message?

    Hi
    Create an XSL file like below and use in your mapping.
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <soapenv:Header>
    <wsse:Security mustUnderstand="0" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <wsse:UsernameToken wsu:Id="UsernameToken-5700630" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsse:Username>admin</wsse:Username>
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</wsse:Password>
    </wsse:UsernameToken>
    </wsse:Security>
    </soapenv:Header>
             <xsl:copy-of select=""/>*     
    </xsl:template>
    </xsl:stylesheet>

  • Unable to add custom SOAP header to consumer webservice in CRM( without using PI)

    Hello Experts,
    We have a requirement to consume webservice proxy in CRM without involving PI. We have WSDL file which has many services as depicted in the first screenshot.After checking old posts, I could add custom SOAP header by using if_wsprotocol_ws_header and there is no xml parsing error for ws_header.Have used if_ixml_stream_factory to check xml parsing error for header.
    '<soapenv:Header>'
    '<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'
    '<wsse:UsernameToken wsu:Id="UsernameToken-2">'
                '<wsse:Username>user id</wsse:Username>'
                '<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">paswd</wsse:Password>'
                '<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">MT0B9XFzsZJXXKmVKOsj/Q==</wsse:Nonce>'
                '<wsu:Created>2015-03-30T06:29:17.407Z</wsu:Created>'
    '</wsse:UsernameToken>'
    '</wsse:Security>'
    '</soapenv:Header>' INTO l_string.
    But when my ABAP program as a whole gets executed where consumer proxy is called, then it still throws XML parsing error - undeclared namespace prefix. As mentioned, there is no parsing error for header and WSDL file as a whole in SOAP UI tool works fine,by manually adding SOAP header.
    Have configured SOAMANAGER with logical port.Or any wrong setting in SOAMANAGER can cause this issue? When I tested webservice ping, it gave me attached error but I read in a SAP note that such error can be ignored.
    I want to know if some more setting/coding is required if we manually add custom header to a payload? Is PI really required to implement this requirement? Payload mapping has to be done to add custom header and if that can be taken care by ABAP coding and how?
    Can you please help?
    BR,
    Nisha Verma

    Hello Experts,
    I have not found the solution yet.
    Can anyone provide some insight??
    BR,
    Nisha Verma

  • How to add/change missing header lines in RNIF B2B?

    Hi all,
    We are using RNIF exchange protocol. We have sent invoice from BPEL to B2B. The message invoice reaches the trading partner but they are unable to process it or sent ack back as few header lines are missing in the RNIF envelope.
    Can anyone tell me or provide some pointers abt how to add/change missing header lines in B2B?
    These are the headers missing:
    Delivery header:
    <locationID> <Value>HostTradingPartner</Value> </locationID>
    Service Header:
    <messageStandard>
    <FreeFormText xml:lang="EN">PIDX</FreeFormText>
    </messageStandard> <standardVersion>
    <VersionIdentifier>1.0</VersionIdentifier>
    </standardVersion>
    Can anyone provide some inputs on this?

    As per RNIF standard, all these header elements (locationID in Delivery Header & messageStandard and standardVersion in Service Header) are optional. As you are using RossettNet over RNIF, so Oracle B2B might not be setting these headers.
    I do not have a 10g setup here so cann't test it. I would suggest you to raise a case with Oracle Support because PIDX is a non-RossettaNet standard and it's implementation in Oracle B2B will be different to RossettaNet implementation. Meanwhile, I would try the same in B2B 11g setup.
    Regards,
    Anuj

  • How to set the SOAP Header while publishing to Queue in the mediator

    Hi,
    I am trying to publish the message to a JMS AQ, from the Mediator service in the 11g Soa Suite. I want to add some properties as SOAP Header to the message and send it to the JMS AQ. I have seen the mediator process calling BPEL process, passing the SOAP Header values. In the BPEL process, we have the section <soap:binding> inside that I can give the <soap:header>and set the values.
    Could any one tell me how to do this in Mediator service which is calling the JMS AQ using adapter?
    Thanks,

    The solution in this thread is for VS .NET as this is the forum for CR in .NET.
    With Foxpro, I suspect you want to create a new thread in the SAP Crystal Reports - Legacy SDKs forum.
    Make sure you specify the exact version of CR used.
    - Ludek

  • FInvoice How to add the SOAP frame thru XSLT transform

    Dear All,
    i have the following problem i have implemented as xslt codeto send data from SAP Idoc invoic to WS Finvoic .
    the coding looking as following :
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output encoding="ISO-8859-1"/>
         <xsl:template match="/">
              <!-- Create SOAP-Envelope -->
              <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
                   <!-- Create Header Container -->
                   <SOAP-ENV:Header>
                        <eb:MessageHeader xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd" SOAP-ENV:mustUnderstand="1" eb:id="">
                             <eb:From>
                                  <eb:PartyId>
                                       <xsl:value-of select="Finvoice/SellerOrganisationUnitNumber"/>
                                  </eb:PartyId>
                                  <eb:Role>Sender</eb:Role>
                             </eb:From>
                             <eb:From>
                                  <eb:PartyId>
                                       <xsl:value-of select="Finvoice//SellerBic"/>
                                  </eb:PartyId>
                                  <eb:Role>Intermediator</eb:Role>
                             </eb:From>
                             <eb:To>
                                  <eb:PartyId>
                                       <xsl:value-of select="Finvoice//InvoiceRecipientAddress"/>
                                  </eb:PartyId>
                                  <eb:Role>Receiver</eb:Role>
                             </eb:To>
                             <eb:To>
                                  <eb:PartyId>
                                       <xsl:value-of select="Finvoice//InvoiceRecipientIntermediatorAddress"/>
                                  </eb:PartyId>
                                  <eb:Role>Intermediator</eb:Role>
                             </eb:To>
                             <eb:CPAId>yoursandmycpa</eb:CPAId>
                             <eb:Service>Routing</eb:Service>
                             <eb:Action>ProcessInvoice</eb:Action>
                             <eb:MessageData>
                                  <eb:MessageId>
                                       <xsl:value-of select="Finvoice//SellerReferenceIdentifier"/>
                                  </eb:MessageId>
                                  <eb:Timestamp>
                                       <xsl:value-of select="Finvoice//InvoiceDate"/>
                                  </eb:Timestamp>
                             </eb:MessageData>
                        </eb:MessageHeader>
                   </SOAP-ENV:Header>
                   <!-- Create Body -->
                   <SOAP-ENV:Body>
                        <eb:Manifest eb:id="Manifest" eb:version="2.0">
                             <eb:Reference eb:id="Finvoice" xlink:href="1009">
                                  <eb:schema eb:location="http://www.finvoice.info/yrityksen_verkkolasku/ladattavat/Tekniset tiedostot/schemat/Finvoice.xsd"/>
                             </eb:Reference>
                        </eb:Manifest>
                   </SOAP-ENV:Body>
              </SOAP-ENV:Envelope>
              <!-- Add Finvoice msg. as Payload Container-->
              <xsl:text disable-output-escaping="yes">
         <?xml version="1.0" encoding="ISO-8859-15"?>
         </xsl:text>
    <xsl:text disable-output-escaping="yes">
    <!DOCTYPE Finvoice SYSTEM "Finvoice.dtd">
    </xsl:text>
    <xsl:processing-instruction name="xml-stylesheet">type="text/xsl" href="Finvoice.xsl"</xsl:processing-instruction>
    <xsl:copy-of select="*"/>
    </xsl:template>
    </xsl:stylesheet
    My problem is that I don't know how to add the doctype part via xslt:
    <?xml version="1.0" encoding="ISO-8859-15"?>
    <!DOCTYPE Finvoice SYSTEM "Finvoice.dtd">
    could sombody give me input concerning this
    Thank in advace.
    Best regards !

    Hi,
    I don't know if I completely understand your requirements,
    however, if you have the field DocType in your Idoc Structure Message, like follow:
    <EDI34243 doctype="XXX"/>
    You can use:
    <xsl:value-of select="@doctype"/>

  • How to Capture Runtime SOAP Header in ABAP Webservice

    Hi All,
    I have created a WebService from a ABAP Function Module, and an external (Java Based) system is able consume to it. But while making the call, the external System enriches the SOAP header with certain values, and I need to capture these values in ABAP Function Module.
    How can read the enriched SOAP Header in my ABAP Function Module? is there any Class/Function Module which I can call to get the Runtime SOAP-HEADER or is the runtime SOAP-header available in one of the structures similar to SYST?
    Thanks,
    Ganesh

    Hi Ganesh,
    Please go through this link.
    http://www.sapag.co.in/SAP-XI-SOAP-Adapter-FAQ'S.html
    I think this would be helpful for you..
    Reward points if useful,
    Swamy Kunche

  • How to modify the soap header of ebxml control?

    I need to change the soap header information of the ebxml control
    from
    <eb:CPAId>http://www.openuri.org/cpa</eb:CPAId>
    to
    <eb:CPAId>MyString</eb:CPAId>
    and I want to add some additional information to the header such as the wsse feature
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/12/utility">
    <wsse:UsernameToken>
    <wsse:Username>1234</wsse:Username>
    <wsse:Password>5678</wsse:Password>
    <Organization>abc</Organization>
    <Domain>DEFAULT</Domain>
    </wsse:UsernameToken>
    </wsse:Security>
    Does anyone know where I can change the type value?
    Thanks, Kun

    Your code works. But if I place the TextInput in the formItem
    and form tags, the Y value becomes 0. You can try this one:
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Form paddingBottom="0" paddingTop="0"
    paddingRight="0">
    <mx:FormItem label="Title:">
    <mx:TextInput width="275" id="newSongTitle"/>
    </mx:FormItem>
    <mx:FormItem>
    <mx:Button id="submitSongData" label="Add Song"
    width="150"/>
    </mx:FormItem>
    </mx:Form>
    <mx:Text text="{newSongTitle.x}" width="322"/>
    <mx:Text text="{newSongTitle.y}" width="322"/>
    <mx:Button label="set Y" click="{newSongTitle.y =
    newY.value}"/>
    <mx:NumericStepper id="newY" value="50" minimum="0"
    maximum="400"/>
    </mx:Application>

  • How to add bookmarks to header strip and dock

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/876192]]</blockquote>
    how to add bookmarked sites to header strip below toolbar and above tab strip so that I can enter w/click- visible even when using other tabs, and how can frequent sites be added to mac dock which holds frequently used apps

    If you are using build-in APIs to show PDF in windows store app, you can save the page index as bookmarks. See more code snippets from
    https://code.msdn.microsoft.com/windowsapps/PDF-viewer-showcase-sample-39ced1e8.  

  • How to populate the SOAP Header in JCD/BP while consuming WebService?

    Hello,
    I am trying to invoke a external webservice through both JCD/BP in JCAPS513 and as per wsdl defination we need to send user and token information in the SOAP Header. When I imported the WebService defination into the JCDP/BP, I do not see message part corresponding to SOAP Header. Can anyone help me here?
    Here is the WSDL message, operation & binding details:
    <wsdl:operation name="GetOrderID"> <wsdl:operation name="GetOrderID"> <wsdl:message name="GetOrderIDSoapIn">
    <wsdl:part name="parameters"
    element="tns:GetOrderID"/>
    </wsdl:message>
    <wsdl:message name="GetOrderIDSoapOut">
    <wsdl:part name="parameters"
    element="tns:GetOrderIDResponse"/>
    </wsdl:message>
    <wsdl:message name="GetOrderIDWebServiceCredential">
    <wsdl:part name="WebServiceCredential"
    element="tns:WebServiceCredential"/>
    </wsdl:message>
    <wsdl:input message="tns:GetOrderIDSoapIn"/>
    <wsdl:output message="tns:GetOrderIDSoapOut"/>
    </wsdl:operation>
    <soap:operation soapAction="http://xxxxxx.xxxx.xxx/V2/GetOrderID"
    style="document"/>
    <wsdl:input>
    <soap:body use="literal"/>
    {color:#ff0000} *<soap:header message="tns:GetOrderIDWebServiceCredential"*
    * part="WebServiceCredential"*
    * use="literal"></soap:header>*{color}
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>

    Hi Ganesh,
    Please go through this link.
    http://www.sapag.co.in/SAP-XI-SOAP-Adapter-FAQ'S.html
    I think this would be helpful for you..
    Reward points if useful,
    Swamy Kunche

  • How to create WSSE soap header?

    I need to connect to a web service and it requires WSSE security namespace in the soap header. Does anyone know to create it using Java in the soap header using WSSE security namespace?
    Thanks
    I'm using Jdeveloper 11g

    Doesn't jdeveloper has a wizard in creating a template code for the subject task.

  • How to add abap stack to existing NW Java engine- for XI installation

    Hi All,
    I am having a netweaver Java Stack installed on my system. I would like to install XI - in order to install Xi ,I guess the system should be ABAP + Java. But since I am having java based engine, I would like to add ABAP stack to it. So, my question how to add an ABAP stack to already existing JAVA/J2ee engine.
    So what this process is known as-- Is it upgrading or New Installation. Because I need the guide and CD's for it.
    Can any one tell me which Guide(Install/upgrade/Master) wud help me.
    Thanks
    S

    Hi
    check the link www.service.sap.com/instguides>SAP Netweaver 7.0>installation guides there you can find what is the process which involves in installing ABAP+JAVA with PI
    Regards
    Uday

  • How do you use .wsse policy file from Java Client?

    I'd like to call a WSSE enabled web service from my Java client but setup my encryption/signing requirements with a .wsse policy file.
    I know how to call a web service by programmatically setting up the security headers as described in:
    http://e-docs.bea.com/workshop/docs81/doc/en/core/index.html
    But how can I do the same thing by simply using a .wsse file?

    import java.awt.*;
    import java.applet.Applet;
    import java.awt.event.*;
    import java.net.*;
    public class links extends java.applet.Applet {
       Panel panel = new Panel();
       public links(){
          super();
          add(panel);
          Link link = new Link(this,"Answers for programmers;- ","http://forum.java.sun.com");
          panel.add(link);
       public void init(){
          setVisible(true);
       public class Link extends Label implements MouseListener {
          Applet applet;
          Color fcolor = Color.blue;
          Color lcolor = Color.pink;
          String text;
          String word;
       public Link(Applet ap, String s, String s1){
          super(s);
             this.applet = ap;
             this.text = s;
             this.word = s1;
             addMouseListener(this);
          setForeground(fcolor);
       public void paint(Graphics g){
       super.paint(g);
          if (getForeground() == lcolor){
             Dimension d = getSize();
             g.fillRect(1,d.height-5,d.width,1);
       public void update(Graphics g){paint(g);}
       public void mouseClicked(MouseEvent e){
          try{
             URL url = new URL(word);
             applet.getAppletContext().showDocument(url,"_self");
          catch(MalformedURLException er){ }
       public void mouseEntered(MouseEvent e){
          setForeground(lcolor);
          setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
          repaint();
       public void mouseExited(MouseEvent e){
          setForeground(fcolor);
          setCursor(Cursor.getDefaultCursor());
          repaint();
    public void mousePressed(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
       public static void main (String[] args){
          new links(); 
    }

  • SOAP --XI ---RFC or Java Client  Proxy

    Hello Gurus,
    Need your adivce for a scenario in XI
    Scenario ---  To implement XI with SAP SCEM(Supply Chain Event Management).
    Client is sending data from Web Portal (JSP Page) and wants to integrate with R/3.
    (Request from client and Response from R/3 shown again at browser )
    Web Portal (JSP Page) is on server A and XI on server B
    Queries ---
    1. Can I use Java Client Proxy Approach ---  proxy --- xi -- rfc approach 
    If  Web Portal (JSP page) is working in server A and XI in server B then can I call xi server from jsp page by passing xi server credential (username,password,bus service) and using sync Interface I can show result back to browser.
    2. For SOAP Approach  -- SOAP -- XI --- RFC approach 
    Suppose I need to send two parameters from my Web Portal (JSP page) to xi to R/3 and it will return some result.
    Concept of Webservice --- any application (like BAPI ) exposed.
    a. Pls tell me all the steps required for IR and ID
    b.How can I invoke that generated webservice from my jsp page --- so that my request parameters values go to xi from my jsp page and to R/3 and then result from R/3 to xi and to my jsp page.
    Regards

    I think second approach is more appropriate ie. SOAP>XI>RFC
    Some of the blogs you can refer:
    /people/riyaz.sayyad/blog/2006/05/07/consuming-xi-web-services-using-web-dynpro-150-part-i
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d23cbe11-0d01-0010-5287-873a22024f79
    Sender SOAP adapter config: http://help.sap.com/saphelp_nw04s/helpdata/en/fc/5ad93f130f9215e10000000a155106/content.htm
    Hope this helps,
    Rgds,
    Moorthy

Maybe you are looking for

  • New iMac won't recognize my external monitor.

    I just upgraded my workplace computer to a late-2012 iMac (with the thin edges) from the previous older model. I have an external monitor that I use as a secondary screen - a Samsung SyncMaster BX2440 - that worked great on my older machine using the

  • No shedulines due and delivery split

    I encountered with two errors : they are as follows 1)No schedule lines due for delivery upto the selected date 2) delivery split due to two shipping points. In the first case, I have checked the shedule line of the line item in the order i.e by clic

  • Order of steps to change IP segment address and it's resources - Windows 2008 R2

    I have a 2 node cluster in windows 2008 R2 AD on an HP Proliant DL380 G6 server with an attached MSA2012sa DAS storage where the resources recite.  Resources are mainly data, no apps. I need to change the IP segment/address of the cluster & storage t

  • Airport extreme 802.11n card for 2 Gh intel core duo MacBook pro

    can I upgrade my 2 Gh core duo MacBook's airport card to work with the new airport extreme? 802.11n base station. I could not find any info on the apple site. thnks

  • Many tables many fields

    Hello Everybody! In my case there are three tables: CCIHT_IAL, CCIHT_IPEVINJ, CCIHT_IPEVA . I need a select statement that returns datas regarding below shown fields. How looks such a select statement with these fields and three tables ? I hope someb