|
| 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
|
|
|
| |
|
| |
| |
| 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
|
|
|
| |
|
| |
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|