Solved

what is a Difference between SOAP header and Http header

Posted on 2012-04-09
5
1,285 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 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now