Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
Controling Serializating of SOAP Headers
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.remoting.


Andy Neilson
I'm using remoting to build a Web Service that uses custom headers for authentication. There are a number of reasons why I need to use remoting (e.g., need to run on NT4, 3GB machines, etc), so don't tell me to use ASP.NET!

The documentation seems a bit sketchy on how to use custom headers in remoting. What I have been able to figure out suggests that there is a terrific bit of infrastructure there, but I can't quite figure it out.

It seems that remoting does just what you would expect and uses SOAP headers to transmit context information out-of-band. In my code that implements the RPC, I can use CallContext.GetHeaders() to get at the headers. I can see the SOAP header in the call context, but I haven't managed to figure out how to customize its serialization. The remoting infrstructure seems quite oblivious to the class that represents my class - it never even constructs it. I've tried supporting various interfaces on it (ISerializable, ILogicalThreadAffinative), attributes (Serializable, SoapType, XmlType), and tried preloading the assembly (SoapServices.Preload(...)).

If my header is an empty element, I do see the header element, and the HeaderNamespace, MustUnderstand and Name fields are filled in, but the Value is null. Any attributes included with the header message are ignored.

If my header contains child elements, I get a parse error (**** System.Runtime.Serialization.SerializationException - Parse Error, no assembly associated with Xml key _P1 authentication).

Has anyone managed to use custom headers with remoting, or is this capability not quite there yet?

Andy

Reply to this message...
Vote that this is a GOOD answer...
 
Auto-following on Twitter
Ubuntu and XP on one “desktop”
 
    
Andy Neilson
After much trial an error, I seem to have found out how to make this work. If I include the "enc:root" attribute on the root of my header, the header is serialized properly and I can access the header in the CallContext:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/";>
<env:Header>
<a:authenticate xmlns:a="urn:my-header-namespace" enc:root="1">
<a:user>Andy</a:user>
<a:password>secret</a:password>
</a:authenticate>
</env:Header>
<env:Body>
....
</env:Body>
</env:Envelope>

I can't say that I've ever seen an example of headers that used SOAP encoding in any way. This seems to me to be a deficiency in the remoting implementation.

Andy
"Andy Neilson" <Click here to reveal e-mail address> wrote in message news:#rFlgadqBHA.2128@tkmsftngp07...
I'm using remoting to build a Web Service that uses custom headers for authentication. There are a number of reasons why I need to use remoting (e.g., need to run on NT4, 3GB machines, etc), so don't tell me to use ASP.NET!

The documentation seems a bit sketchy on how to use custom headers in remoting. What I have been able to figure out suggests that there is a terrific bit of infrastructure there, but I can't quite figure it out.

It seems that remoting does just what you would expect and uses SOAP headers to transmit context information out-of-band. In my code that implements the RPC, I can use CallContext.GetHeaders() to get at the headers. I can see the SOAP header in the call context, but I haven't managed to figure out how to customize its serialization. The remoting infrstructure seems quite oblivious to the class that represents my class - it never even constructs it. I've tried supporting various interfaces on it (ISerializable, ILogicalThreadAffinative), attributes (Serializable, SoapType, XmlType), and tried preloading the assembly (SoapServices.Preload(...)).

If my header is an empty element, I do see the header element, and the HeaderNamespace, MustUnderstand and Name fields are filled in, but the Value is null. Any attributes included with the header message are ignored.

If my header contains child elements, I get a parse error (**** System.Runtime.Serialization.SerializationException - Parse Error, no assembly associated with Xml key _P1 authentication).

Has anyone managed to use custom headers with remoting, or is this capability not quite there yet?

Andy

Reply to this message...
Vote that this is a GOOD answer...
 
Outlook interop - stopping user properties appearing on Outlook message print
Seriously, why is “cut and paste” majorly newsworthy???
 
 
System.Runtime.Remoting.Messaging.CallContext
System.Runtime.Remoting.Messaging.ILogicalThreadAffinative
System.Runtime.Remoting.SoapServices
System.Runtime.Serialization.ISerializable
System.Runtime.Serialization.SerializationException




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734