473,289 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

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");
SOAPHeaderElement headerElement = new SOAPHeaderElement(headerName);
headerElement.setValue("ECH Gui");
headerElement.setMustUnderstand(true);

try {
Message message = arg0.getCurrentMessage();
message.getSOAPHeader().addChildElement(headerElem ent);
} catch (SOAPException se) {
logger.error("Kan niet SOAP header 'Vendor' toevoegen", se);
}

Nov 8 '06 #1
6 42904
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");
SOAPHeaderElement headerElement = new SOAPHeaderElement(headerName);
headerElement.setValue("ECH Gui");
headerElement.setMustUnderstand(true);

try {
Message message = arg0.getCurrentMessage();
message.getSOAPHeader().addChildElement(headerElem ent);
} catch (SOAPException se) {
logger.error("Kan 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
SoapHeaderCollection. You will need to use the SoapHeaderAttribute 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");
SOAPHeaderElement headerElement = new SOAPHeaderElement(headerName);
headerElement.setValue("ECH Gui");
headerElement.setMustUnderstand(true);

try {
Message message = arg0.getCurrentMessage();
message.getSOAPHeader().addChildElement(headerElem ent);
} catch (SOAPException se) {
logger.error("Kan 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******@discussions.microsoft.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
SoapHeaderCollection. You will need to use the SoapHeaderAttribute 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");
SOAPHeaderElement headerElement = new SOAPHeaderElement(headerName);
headerElement.setValue("ECH Gui");
headerElement.setMustUnderstand(true);

try {
Message message = arg0.getCurrentMessage();
message.getSOAPHeader().addChildElement(headerElem ent);
} catch (SOAPException se) {
logger.error("Kan 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******@discussions.microsoft.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
SoapHeaderCollection. You will need to use the SoapHeaderAttribute 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");
SOAPHeaderElement headerElement = new SOAPHeaderElement(headerName);
headerElement.setValue("ECH Gui");
headerElement.setMustUnderstand(true);

try {
Message message = arg0.getCurrentMessage();
message.getSOAPHeader().addChildElement(headerElem ent);
} catch (SOAPException se) {
logger.error("Kan 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******@discussions.microsoft.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******@discussions.microsoft.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
SoapHeaderCollection. You will need to use the SoapHeaderAttribute 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");
SOAPHeaderElement headerElement = new SOAPHeaderElement(headerName);
headerElement.setValue("ECH Gui");
headerElement.setMustUnderstand(true);

try {
Message message = arg0.getCurrentMessage();
message.getSOAPHeader().addChildElement(headerElem ent);
} catch (SOAPException se) {
logger.error("Kan 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(Namespace = "http://ech.client.nl/vendor")]
public class VENDOR : SoapHeader
{
public string Value;
}

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

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("vendorHeader", Direction = SoapHeaderDirection.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.Value = "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******@discussions.microsoft.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******@discussions.microsoft.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
SoapHeaderCollection. You will need to use the SoapHeaderAttribute 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");
SOAPHeaderElement headerElement = new SOAPHeaderElement(headerName);
headerElement.setValue("ECH Gui");
headerElement.setMustUnderstand(true);

try {
Message message = arg0.getCurrentMessage();
message.getSOAPHeader().addChildElement(headerElem ent);
} catch (SOAPException se) {
logger.error("Kan 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
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...
0
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...
5
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...
0
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...
1
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...
3
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...
4
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...
6
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...
0
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.