RE: prefix in soap header




Hi,
I'm trying to call a java web service and i need some help in creating
a custom SOAP header in c#.

I need to access to a Web service that implements authorization policy,
by using a session token to be passed in the SOAP header.

The header should be as the following:

<env:Header>
<cc:sessionContext
xmlns:cc="http://myServer/XMLSchemas/security2.0/";>
<ticket>14419812551330193201239823092</ticket>
</cc:sessionContext>
</env:Header>

I tried to create a custom AuthorizationSOAPHeader class to represent
the header, but I was not able to define the right tagprefix "cc" for
the XML root element (sessionContext) and its namespace attribute
(cc="http://myServer/XMLSchemas/security2.0/";). I also tried to
manually add the namespace attribute, by overriding the WriteXml method
provided by the IXmlSerializable interface in the
AuthorizationSOAPHeader class, but it was not possible to correctly set
the tag name to "cc:sessionContext", as the ":" character was encoded.

I had to define a custom header class because it isn't defined in the
wsdl because the soap call is intercepted by a proxy service which
inspects the header of the request in order to see if the caller can be
authenticated; then, if the user is authenticated, the request is
routed to the demanded web service. If the sessionContext node doesn't
have the cc prefix as described above, the request is rejected.

Is there a way to set the tag prefix for the XMLRootElement of the
header class( by overriding the WriteXml provided by the
IXmlSerializable interface ) avoiding the encoding of the colon mark?
Or the only possible solution is to implement a SOAP extension?

Thank you for any answer.

It is not uncommon to create a SoapHeader which is not defined in the WSDL. That is the reason why the UnknownSoapHeader class exists in .NET. Combine this with the mustUnderstand instance variables and you have a mechanism of processing/creating SoapHeaders that are not defined in the WSDL.

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
.



Relevant Pages

  • Re: I dont think I can do that !
    ... Hi DaveP, ... you can do the same on the proxy class for the web service. ... you can define a custom header in the same way. ... > So I have to add values to the SOAP header without changing the Web ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: prefix in soap header
    ... I need to access to a Web service that implements authorization policy, ... by using a session token to be passed in the SOAP header. ... Is there a way to set the tag prefix for the XMLRootElement of the ...
    (microsoft.public.dotnet.framework.webservices)
  • Sample (free) web service with custom soap header
    ... To verify some concepts, I was ... trying to find a freely available web service which has got "Custom ... SOAP Header". ... I don't want to host a web service, ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • SOAPHeader not sent to web service
    ... I'm trying to send a custom SOAP Header to a web service. ... created and deployed a property schema with the SOAP Header specified e.g. ...
    (microsoft.public.biztalk.general)
  • prefix in soap header
    ... I need to access to a Web service that implements authorization policy, ... by using a session token to be passed in the SOAP header. ... I tried to create a custom AuthorizationSOAPHeader class to represent ...
    (microsoft.public.dotnet.framework.webservices)