?
Solved

what is a Difference between SOAP header and Http header

Posted on 2012-04-09
5
Medium Priority
?
1,700 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
  • 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 2000 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 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