473,472 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
Create 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");
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 42958
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...
0
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,...
0
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...
0
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,...
0
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.