473,748 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add SOAP header to a SOAP message?

Hi

I have the following problem.

I'm calling a webservice from within a VB.net 2005 Windows program.
For this i got a WSDL file and loaded that in VB.
Until now i just call the webservice and everything works OK.

Now i need to add an extra attribute/header element to the SOAP header
before i contact the webservice.
The webservice needs this to be in the SOAP header.

Where and how do i do this? I have no clue at all.

From the company that runs the webservice i got an example code in
Java, but i have no idea where this had to be placed.
Hope that soemone can help me or can direct me in a direction to find
a solution

JAVA Code:
// Construct the header
QName headerName = new QName(" http://ech.client.nl/vendor",
"Vendor");
SOAPHeaderEleme nt headerElement = new SOAPHeaderEleme nt(headerName);
headerElement.s etValue("ECH Gui");
headerElement.s etMustUnderstan d(true);

try {
Message message = arg0.getCurrent Message();
message.getSOAP Header().addChi ldElement(heade rElement);
} catch (SOAPException se) {
logger.error("K an niet SOAP header 'Vendor' toevoegen", se);
}

Nov 8 '06 #1
6 43051
To be more precisely.

The webservice i call is not a .NET webservice.
In the WSDL are no header elements defined.

To simplify the question.

I call a webservice and i want to add an SOAP header (with a
headerelement and a value) to the outgoing message.

On Wed, 08 Nov 2006 10:18:22 +0100, Peter van der veen <wrote:
>Hi

I have the following problem.

I'm calling a webservice from within a VB.net 2005 Windows program.
For this i got a WSDL file and loaded that in VB.
Until now i just call the webservice and everything works OK.

Now i need to add an extra attribute/header element to the SOAP header
before i contact the webservice.
The webservice needs this to be in the SOAP header.

Where and how do i do this? I have no clue at all.

From the company that runs the webservice i got an example code in
Java, but i have no idea where this had to be placed.
Hope that soemone can help me or can direct me in a direction to find
a solution

JAVA Code:
// Construct the header
QName headerName = new QName(" http://ech.client.nl/vendor",
"Vendor");
SOAPHeaderElem ent headerElement = new SOAPHeaderEleme nt(headerName);
headerElement. setValue("ECH Gui");
headerElement.s etMustUnderstan d(true);

try {
Message message = arg0.getCurrent Message();
message.getSOAP Header().addChi ldElement(heade rElement);
} catch (SOAPException se) {
logger.error("K an niet SOAP header 'Vendor' toevoegen", se);
}
Nov 8 '06 #2
You will need to add them manually before invoking the endpoint. Check out
this MSDN page for the answer:
http://msdn.microsoft.com/library/de...classtopic.asp

You'll need to know what the SOAP headers look like so that you can create
SoapHeader derived classes and then add instances of those classes to the
SoapHeaderColle ction. You will need to use the SoapHeaderAttri bute as well.

Hope that helps.

"Peter van der veen" wrote:
To be more precisely.

The webservice i call is not a .NET webservice.
In the WSDL are no header elements defined.

To simplify the question.

I call a webservice and i want to add an SOAP header (with a
headerelement and a value) to the outgoing message.

On Wed, 08 Nov 2006 10:18:22 +0100, Peter van der veen <wrote:
Hi

I have the following problem.

I'm calling a webservice from within a VB.net 2005 Windows program.
For this i got a WSDL file and loaded that in VB.
Until now i just call the webservice and everything works OK.

Now i need to add an extra attribute/header element to the SOAP header
before i contact the webservice.
The webservice needs this to be in the SOAP header.

Where and how do i do this? I have no clue at all.

From the company that runs the webservice i got an example code in
Java, but i have no idea where this had to be placed.
Hope that soemone can help me or can direct me in a direction to find
a solution

JAVA Code:
// Construct the header
QName headerName = new QName(" http://ech.client.nl/vendor",
"Vendor");
SOAPHeaderEleme nt headerElement = new SOAPHeaderEleme nt(headerName);
headerElement.s etValue("ECH Gui");
headerElement.s etMustUnderstan d(true);

try {
Message message = arg0.getCurrent Message();
message.getSOAP Header().addChi ldElement(heade rElement);
} catch (SOAPException se) {
logger.error("K an niet SOAP header 'Vendor' toevoegen", se);
}

Nov 8 '06 #3

And that is just the problem.

I want to add a SOAP header but the webservice is not exposing a
header in the WSDL.

On Wed, 8 Nov 2006 05:28:02 -0800, J. Dudgeon
<JD******@discu ssions.microsof t.comwrote:
>You will need to add them manually before invoking the endpoint. Check out
this MSDN page for the answer:
http://msdn.microsoft.com/library/de...classtopic.asp

You'll need to know what the SOAP headers look like so that you can create
SoapHeader derived classes and then add instances of those classes to the
SoapHeaderColl ection. You will need to use the SoapHeaderAttri bute as well.

Hope that helps.

"Peter van der veen" wrote:
>To be more precisely.

The webservice i call is not a .NET webservice.
In the WSDL are no header elements defined.

To simplify the question.

I call a webservice and i want to add an SOAP header (with a
headerelemen t and a value) to the outgoing message.

On Wed, 08 Nov 2006 10:18:22 +0100, Peter van der veen <wrote:
>Hi

I have the following problem.

I'm calling a webservice from within a VB.net 2005 Windows program.
For this i got a WSDL file and loaded that in VB.
Until now i just call the webservice and everything works OK.

Now i need to add an extra attribute/header element to the SOAP header
before i contact the webservice.
The webservice needs this to be in the SOAP header.

Where and how do i do this? I have no clue at all.

From the company that runs the webservice i got an example code in
Java, but i have no idea where this had to be placed.
Hope that soemone can help me or can direct me in a direction to find
a solution

JAVA Code:
// Construct the header
QName headerName = new QName(" http://ech.client.nl/vendor",
"Vendor");
SOAPHeaderElem ent headerElement = new SOAPHeaderEleme nt(headerName);
headerElement. setValue("ECH Gui");
headerElement.s etMustUnderstan d(true);

try {
Message message = arg0.getCurrent Message();
message.getSOAP Header().addChi ldElement(heade rElement);
} catch (SOAPException se) {
logger.error("K an niet SOAP header 'Vendor' toevoegen", se);
}

Nov 9 '06 #4
My understanding of your problem is that you want to communicate with some
Web service that you didn't author. This service doesn't expose SOAP headers
in the WSDL but you know the layout and format of the header(s).

If that is the case then the headers don't need to be defined in the WSDL.
As long as the Web service is accepting and processing the SOAP headers
correctly, then follow the instructions above and it should work.

"Peter van der veen" wrote:
>
And that is just the problem.

I want to add a SOAP header but the webservice is not exposing a
header in the WSDL.

On Wed, 8 Nov 2006 05:28:02 -0800, J. Dudgeon
<JD******@discu ssions.microsof t.comwrote:
You will need to add them manually before invoking the endpoint. Check out
this MSDN page for the answer:
http://msdn.microsoft.com/library/de...classtopic.asp

You'll need to know what the SOAP headers look like so that you can create
SoapHeader derived classes and then add instances of those classes to the
SoapHeaderColle ction. You will need to use the SoapHeaderAttri bute as well.

Hope that helps.

"Peter van der veen" wrote:
To be more precisely.

The webservice i call is not a .NET webservice.
In the WSDL are no header elements defined.

To simplify the question.

I call a webservice and i want to add an SOAP header (with a
headerelement and a value) to the outgoing message.

On Wed, 08 Nov 2006 10:18:22 +0100, Peter van der veen <wrote:

Hi

I have the following problem.

I'm calling a webservice from within a VB.net 2005 Windows program.
For this i got a WSDL file and loaded that in VB.
Until now i just call the webservice and everything works OK.

Now i need to add an extra attribute/header element to the SOAP header
before i contact the webservice.
The webservice needs this to be in the SOAP header.

Where and how do i do this? I have no clue at all.

From the company that runs the webservice i got an example code in
Java, but i have no idea where this had to be placed.
Hope that soemone can help me or can direct me in a direction to find
a solution

JAVA Code:
// Construct the header
QName headerName = new QName(" http://ech.client.nl/vendor",
"Vendor");
SOAPHeaderEleme nt headerElement = new SOAPHeaderEleme nt(headerName);
headerElement.s etValue("ECH Gui");
headerElement.s etMustUnderstan d(true);

try {
Message message = arg0.getCurrent Message();
message.getSOAP Header().addChi ldElement(heade rElement);
} catch (SOAPException se) {
logger.error("K an niet SOAP header 'Vendor' toevoegen", se);
}


Nov 9 '06 #5
I only know that i need to add a header with the name 'VENDOR' tha
must be in the namespace "http://ech.client.nl/vendor"
and that i have to give it a value.

After that i need to attach that header to the SOAP message.

But i'm just call a function in the WSDL so i do net see how to add
such a header to the message.
On Thu, 9 Nov 2006 01:02:01 -0800, J. Dudgeon
<JD******@discu ssions.microsof t.comwrote:
>My understanding of your problem is that you want to communicate with some
Web service that you didn't author. This service doesn't expose SOAP headers
in the WSDL but you know the layout and format of the header(s).

If that is the case then the headers don't need to be defined in the WSDL.
As long as the Web service is accepting and processing the SOAP headers
correctly, then follow the instructions above and it should work.

"Peter van der veen" wrote:
>>
And that is just the problem.

I want to add a SOAP header but the webservice is not exposing a
header in the WSDL.

On Wed, 8 Nov 2006 05:28:02 -0800, J. Dudgeon
<JD******@disc ussions.microso ft.comwrote:
>You will need to add them manually before invoking the endpoint. Check out
this MSDN page for the answer:
http://msdn.microsoft.com/library/de...classtopic.asp

You'll need to know what the SOAP headers look like so that you can create
SoapHeader derived classes and then add instances of those classes to the
SoapHeaderColl ection. You will need to use the SoapHeaderAttri bute as well.

Hope that helps.

"Peter van der veen" wrote:

To be more precisely.

The webservice i call is not a .NET webservice.
In the WSDL are no header elements defined.

To simplify the question.

I call a webservice and i want to add an SOAP header (with a
headerelemen t and a value) to the outgoing message.

On Wed, 08 Nov 2006 10:18:22 +0100, Peter van der veen <wrote:

Hi

I have the following problem.

I'm calling a webservice from within a VB.net 2005 Windows program.
For this i got a WSDL file and loaded that in VB.
Until now i just call the webservice and everything works OK.

Now i need to add an extra attribute/header element to the SOAP header
before i contact the webservice.
The webservice needs this to be in the SOAP header.

Where and how do i do this? I have no clue at all.

From the company that runs the webservice i got an example code in
Java, but i have no idea where this had to be placed.
Hope that soemone can help me or can direct me in a direction to find
a solution

JAVA Code:
// Construct the header
QName headerName = new QName(" http://ech.client.nl/vendor",
"Vendor");
SOAPHeaderElem ent headerElement = new SOAPHeaderEleme nt(headerName);
headerElement. setValue("ECH Gui");
headerElement.s etMustUnderstan d(true);

try {
Message message = arg0.getCurrent Message();
message.getSOAP Header().addChi ldElement(heade rElement);
} catch (SOAPException se) {
logger.error("K an niet SOAP header 'Vendor' toevoegen", se);
}


Nov 14 '06 #6
That was already described in my previous post.

1. Generate a Web service proxy as you normally do.

2. Create a class that describes the SOAP header you will be sending:

[XmlRoot(Namespa ce = "http://ech.client.nl/vendor")]
public class VENDOR : SoapHeader
{
public string Value;
}

3. Add a public member variable to the proxy class named "vendorHead er":

public VENDOR vendorHeader;

leave it set to null for now.

4. Modify the method you are invoking and add the following attribute to
that method:

[SoapHeader("ven dorHeader", Direction = SoapHeaderDirec tion.In)]

5. Modify the body of the method call so that you create an instance of the
member variable. Put this code before the "Invoke" code:

vendorHeader = new VENDOR();
vendorHeader.Va lue = "This is my value";

--------------

That's it.

"Peter van der veen" wrote:
I only know that i need to add a header with the name 'VENDOR' tha
must be in the namespace "http://ech.client.nl/vendor"
and that i have to give it a value.

After that i need to attach that header to the SOAP message.

But i'm just call a function in the WSDL so i do net see how to add
such a header to the message.
On Thu, 9 Nov 2006 01:02:01 -0800, J. Dudgeon
<JD******@discu ssions.microsof t.comwrote:
My understanding of your problem is that you want to communicate with some
Web service that you didn't author. This service doesn't expose SOAP headers
in the WSDL but you know the layout and format of the header(s).

If that is the case then the headers don't need to be defined in the WSDL.
As long as the Web service is accepting and processing the SOAP headers
correctly, then follow the instructions above and it should work.

"Peter van der veen" wrote:
>
And that is just the problem.

I want to add a SOAP header but the webservice is not exposing a
header in the WSDL.

On Wed, 8 Nov 2006 05:28:02 -0800, J. Dudgeon
<JD******@discu ssions.microsof t.comwrote:

You will need to add them manually before invoking the endpoint. Check out
this MSDN page for the answer:
http://msdn.microsoft.com/library/de...classtopic.asp

You'll need to know what the SOAP headers look like so that you can create
SoapHeader derived classes and then add instances of those classes to the
SoapHeaderColle ction. You will need to use the SoapHeaderAttri bute as well.

Hope that helps.

"Peter van der veen" wrote:

To be more precisely.

The webservice i call is not a .NET webservice.
In the WSDL are no header elements defined.

To simplify the question.

I call a webservice and i want to add an SOAP header (with a
headerelement and a value) to the outgoing message.

On Wed, 08 Nov 2006 10:18:22 +0100, Peter van der veen <wrote:

Hi

I have the following problem.

I'm calling a webservice from within a VB.net 2005 Windows program.
For this i got a WSDL file and loaded that in VB.
Until now i just call the webservice and everything works OK.

Now i need to add an extra attribute/header element to the SOAP header
before i contact the webservice.
The webservice needs this to be in the SOAP header.

Where and how do i do this? I have no clue at all.

From the company that runs the webservice i got an example code in
Java, but i have no idea where this had to be placed.
Hope that soemone can help me or can direct me in a direction to find
a solution

JAVA Code:
// Construct the header
QName headerName = new QName(" http://ech.client.nl/vendor",
"Vendor");
SOAPHeaderEleme nt headerElement = new SOAPHeaderEleme nt(headerName);
headerElement.s etValue("ECH Gui");
headerElement.s etMustUnderstan d(true);

try {
Message message = arg0.getCurrent Message();
message.getSOAP Header().addChi ldElement(heade rElement);
} catch (SOAPException se) {
logger.error("K an niet SOAP header 'Vendor' toevoegen", se);
}


Nov 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
20282
by: john deviney | last post by:
I have a C#/.Net 1.1 client talking to a Java based web service. I need to insert a soap header on the client side which is expected on the server side. Currently, the Java ws provider, Axis, does not support automatic wsdl generation of custom headers so the wsdl has no information regarding the required header. I've read through a lot of material and managed to get a workable solution but it is far from ideal. I created a new...
0
4670
by: Daniel Thune, MCSE | last post by:
I am having a problem with formatting a SOAP Header in a .Net client. The client calls a Java Axis 1.1 based web service. In order to authenticate the caller, the web service call is intercepted by another web service that validates a security token in the header. I have pasted my current SOAP message that my code sends as captured from a trace function that I added. Below that is a sample SOAP message that the developer of the web...
5
4162
by: vthakur | last post by:
Hello: I have a Axis Web Service that sets the sessionid in the SOAP header for persisting the session. The client is a .Net client that processes the header as an Unknown Header. It sets the session id received from the Service request on subsequent requests to the service. However the Axis Web service does not process the SOAP header received from the .Net client and creates a new session id for each request from the .Net client. Below...
0
1247
by: jack | last post by:
Hi all , i just want to make a call to a webservice i tried and works well however im unable to get how to send the below soap format xml to the webservice which contains header username and password <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
1
2110
by: Peter van der veen | last post by:
Hi I have a problem in VB.net 2.0 We are using a third party webservice. I have loaded the wsdl file and can access the functions the service has. Now this party wants that we add a SOAP header element named 'Vendor' so that they can distinguis which vendor called the webservice.
3
2526
by: mirandacascade | last post by:
1) Is it correct that none of the examples in the ElementSOAP tutorial: http://effbot.org/zone/elementsoap-1.htm include an example in which the SOAP message that contains the request includes a <soap:Headerblock? 2) If one wanted to make use of ElementSOAP, and one wanted it to produce a SOAP message that includes a <soap:Headerwould the general outline be:
4
2485
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code m_Token = null in order to destroy the session token when the user logs out. However, I'm finding that setting class instance to null results in no header being sent back to the client, with the result that the client actually remains with an...
6
46805
by: John | last post by:
I'm trying to call a Webservice (Non-.NET) That requires the insertion of security credentials into the SOAP header. Up until know I've been creating Dynamic proxy classes to call web services and not been dealing with the inner workings of SOAP. Looks Like I need to learn a little about soap and Manually calling Web Services..... Any help will be very appreciated !!!
0
1456
by: ajay p | last post by:
Hi, I have web service which is .NET 2.0. My client is having web service Java AXIs web service. I am able to invoke web method of client web service by passing SOAP Header. Now i facing problem to retrieve value from SOAP header which comes in SOAP response. In following format I am receiving response. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"...
0
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9332
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.