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
Solved

what is a Difference between SOAP header and Http header

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
simple java question 3 59
Way to decrease size of apk file 9 86
eclipse apache tomcat admin console 52 121
Bot application - advice 3 38
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 one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

856 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