Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

what is a Difference between SOAP header and Http header

Posted on 2012-04-09
5
Medium Priority
?
1,615 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses

670 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