Solved

what is a Difference between SOAP header and Http header

Posted on 2012-04-09
5
1,422 Views
Last Modified: 2012-06-27
Hi,

Can someone explain me what the difference is between SOAP header and Http Header. Can I use any of these two to do basic HTTP authentication. I'm using a Java Client for sending Webserce request.

When I opened a WSDL which my client sent me in soapUI, I this in the header of that SOAP. How do I set the header information?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:polh="http://ws.pol.com/PolContractService/2012-01-03/Polcontractservice_V1_0" xmlns:sec="http://ws.pol.com/IBC/2010-11-19/securitybasetype_V1" xmlns:mes="http://ws.pol.com/IBC/2010-11-19/messagecontextbasetype_V1" xmlns:man="http://ws.pol.com/PolContractService/2012-01-03/managecontractrequest_V1" xmlns:con="http://ws.pol.com/Common/2012-01-05/contractbasetype_V1">
   <soapenv:Header>
      <polh:headerContextParameters>
         <securityContextParameters>
            <sec:usernameToken>
               <sec:userName>?</sec:userName>
               <sec:password>?</sec:password>
            </sec:usernameToken>
         </securityContextParameters>
      </polh:headerContextParameters>
   </soapenv:Header>

Thanks
Ajoo
0
Comment
Question by:Ajoo71
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 37826368
As per i know only diffrences is the body struture ...  you can use soap header is more secure

 

HTTP URL:

http://host:port/sap/xi/adapter_plain?service=BS_A&namepsace=http_test&interface=SI_A

 

SOAP URL:

http://host:port/XISOAPAdapter/MessageServlet?channel=party:service:channel
0
 
LVL 11

Expert Comment

by:anilallewar
ID: 37826875
A SOAP header is tied to the SOAP message and can be used to transfer information specific to that request like authentication info etc. So basically it is that part of the data which might be required but is not part of the SOAP payload (request=>method, params etc).

However, it would go in as the body part of the HTTP POST request.

A HTTP header on the other hand will give some information about the HTTP protocol attributes like Content-Type, accepts etc. It is basically metadata to the server/client as to what attributes the HTTP transport protocol is using.
0
 

Author Comment

by:Ajoo71
ID: 37828581
Thanks Anil,
 WHen I generated stubs, UsernameTokenType.java see code below.  How can I set those values in the header?
<soapenv:Header>
      <polh:headerContextParameters>
         <securityContextParameters>
            <sec:usernameToken>
               <sec:userName>?</sec:userName>
               <sec:password>?</sec:password>
            </sec:usernameToken>
         </securityContextParameters>
      </polh:headerContextParameters>
   </soapenv:Header>

UsernameTokenType userTokenType = new UsernameTokenType();
            userTokenType.setUserName("username");
            userTokenType.setPassword("password");
            SecurityBaseType  securityBaseType = new SecurityBaseType();
            securityBaseType.setUsernameToken(userTokenType);
            
            HeaderContextParameters headerContextParam = new HeaderContextParameters();
            headerContextParam.setSecurityContextParameters(securityBaseType);
0
 
LVL 11

Accepted Solution

by:
anilallewar earned 500 total points
ID: 37831283
I don't have the WSDL to help you out; but generally you can get the SOAP message from the message context and use its header part to put data

SOAPMessageContext messageContext //Got within the SOAPHandler
SOAPMessage msg = messageContext.getMessage();

SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
SOAPHeader header = envelope.addHeader();
header.addElement(headerContextParam);
msg.saveChanges();

Open in new window

0
 

Author Comment

by:Ajoo71
ID: 37874006
Will try that
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
arguments to jar 5 40
spring jars download 1 53
How  can  i  resolve  HTTP Status 404 -? 8 60
batch vs regular insert in spring DAO 2 24
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question