Groups | Blog | Home
all groups > dotnet web services enhancements > july 2004 >

dotnet web services enhancements : Adding elements to the header of a SoapEnvelope



SA
7/22/2004 10:02:22 AM
Hi all,

I need to provide the service with a piece of infrastructure information,
namely where to send "events" to during a long-running process.

I can't use ReplyTo because the reply to the Soap message must be sent to
the Address.

I tried adding a new element to the header of my SoapEnvelope like this:

Envelope.Header.AppendChild(SomeXml)

(SomeXml is an XmlDocument,
<EventReceiverUrl>soap.tcp://somehost/someuri</EventReceiverUrl>)

At the time I am doing this, Envelope.Header is Nothing. I try to set this
header after I have added my body object to the envelope. I am going to have
to write a custom input and output filter? Or am I missing something here?

Thanks,

--

Sven


Lucien
7/27/2004 9:29:12 AM
I don't quite follow the ReplyTo issue. ReplyTo is set by default for
request response in WSE (even if you don't set it). The default value is the
anonymous role as outlined in WS-Addressing.

There are several ways to create headers. One way is to add reference
properties in the destination EPR. Another way is to use the SoapHeader
attribute of ASMX. The other option is the one you suggested. Create one
first:

XmlElement header = message.Context.Envelope.CreateHeader();





[quoted text, click to view]

SA
7/28/2004 3:52:48 PM

[quoted text, click to view]

OK, I can't set the ReplyTo value of the SoapEnvelope header myself, because
then the response would be sent to that address. Not what I want. In a
sense, what I want is unrelated messages to be sent to some specified
address, and the response sent to the sender of the request.
[quoted text, click to view]

OK, not sure if we are talking about the same side. I am talking
client-side. Also, I don't use an autogenerated proxy. Setting the
SoapHeader attribute of ASMX seems to be done server-side, and would thus
only work if the proxy is autogenerated.
[quoted text, click to view]

OK, this might help... I hadn't seen this function yet.

Thanks.
[quoted text, click to view]

Lucien
7/28/2004 4:42:25 PM
To clarify my EPR/header suggestion: If you add an referenceProperty to the
destination on the client, it will get serialized as a header on the request
message. Likewise if you add an ReferenceProperty to the ReplyTo it will get
serialized on the response message (and serialized as a type on the
request).

If you set the ReplyTo yourself to anonymous role the response would be sent
back to the client. If you want to send another message from the service
besides the reply you can add that logic in the service method (and I assume
you want to use a header on the request to indicate the address).


[quoted text, click to view]

SA
7/29/2004 4:54:56 PM

[quoted text, click to view]
Yes, and that works great. Simply using CreateHeader was the answer. I am
still familiarizing myself with the object model of WSE 2.0, as you can
tell...

I now have a clean implementation, instead of trying to fit that address
somewhere in the body.

Thanks.

AddThis Social Bookmark Button