Multimobile Development: Building Applications for any Smartphone
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...
 
Really good experience at the Apple Store
MonoDroid – looking *awesome*
 
    
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...
 
First volume of Multimobile Development nearly ready to go to press
A mention on Developing for the iPhone and Android: The pros and cons
 
 
System.Runtime.Remoting.Messaging.CallContext
System.Runtime.Remoting.Messaging.ILogicalThreadAffinative
System.Runtime.Remoting.SoapServices
System.Runtime.Serialization.ISerializable
System.Runtime.Serialization.SerializationException




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734