Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Changing namespace of a Soap Header

Reply
Thread Tools

Changing namespace of a Soap Header

 
 
Brian Tyler
Guest
Posts: n/a
 
      01-18-2005
I have defined a soap header via the .NET framework

public sealed class MySoapHeader : SoapHeader
{
}

I can successfully send this header either from the client proxy or from the
web service itself. However, it seems that the "type" of the header is
always put into the namespace of the proxy or server. For example, under a
simple proxy, I get

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://tempuri.org"
xmlns:types="http://tempuri.org/encodedTypes"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnssd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<types:MySoapHeader id="h_id1"> ...

Note that it is put into the "types" ns, which is based on the ns of the
proxy.

How do I have the SOAP header have its own namespace? Something I can define
as part of the Soap header so it stays the same regardless of the proxy or
web service it is used with?

Thanks in advance

Brian


 
Reply With Quote
 
 
 
 
Brian Tyler
Guest
Posts: n/a
 
      01-19-2005
Christoph,

Thanks for the reply - I have good and bad news.

Turns out that your suggestion completely fixed the problem - IF - I have
the web service/proxy using document encoded SOAP. However, if I switch to
RPC encoded (and leave the XmlElement in place), then the SOAP header
switches to what you saw earlier. The namespace for the header is switched
to <ns of the web service>/encodedTypes.

I don't know if that is part of the spec or not - I have not really messed
with RPC encoding. However, due to a customer requirement I need to be able
to support both document and RPC.

Thoughts?

Brian


"Christoph Schittko [MVP]" wrote

> You can define the namespace of the header by attaching an XmlElement
> attribute to the WebService class' header field:
>
> [WebService(Namespace="http://www.bracketangles.net/ns")]
> public class Service1 : System.Web.Services.WebService
> {
> // ...
>
>
> [XmlElement(Namespace="http://www.bracketangles.net/headers")]
> public MyHeader timeHeader;
>
> [WebMethod]
> [SoapHeader("timeHeader",
> Direction=SoapHeaderDirection.InOut)]
> //...
>
> HTH,
> Christoph Schittko
> MVP XML
> http://weblogs.asp.net/cschittko
>
>
> > -----Original Message-----
> > From: Brian Tyler [(E-Mail Removed)]
> > Posted At: Tuesday, January 18, 2005 1:49 PM
> > Posted To: microsoft.public.dotnet.framework.aspnet.webservic es
> > Conversation: Changing namespace of a Soap Header
> > Subject: Changing namespace of a Soap Header
> >
> > I have defined a soap header via the .NET framework
> >
> > public sealed class MySoapHeader : SoapHeader
> > {
> > }
> >
> > I can successfully send this header either from the client proxy or

> from
> > the
> > web service itself. However, it seems that the "type" of the header is
> > always put into the namespace of the proxy or server. For example,

> under a
> > simple proxy, I get
> >
> > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> > xmlns:tns="http://tempuri.org"
> > xmlns:types="http://tempuri.org/encodedTypes"
> > xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> > xmlnssd="http://www.w3.org/2001/XMLSchema">
> > <soap:Header>
> > <types:MySoapHeader id="h_id1"> ...
> >
> > Note that it is put into the "types" ns, which is based on the ns of

> the
> > proxy.
> >
> > How do I have the SOAP header have its own namespace? Something I can
> > define
> > as part of the Soap header so it stays the same regardless of the

> proxy or
> > web service it is used with?
> >
> > Thanks in advance
> >
> > Brian

>
>



 
Reply With Quote
 
 
 
 
Brian Tyler
Guest
Posts: n/a
 
      01-24-2005
Thanks! I'm glad it is so consistent

Brian

"Christoph Schittko [MVP]" <(E-Mail Removed)> wrote in message
news:u5kZQ$(E-Mail Removed)...
> The familiy of serialization attributed that starts with Xml* does not
> work for RPC encoded messages.
>
> You'll have to substitute them for Soap* serialization attributes or add
> the Soap* attributes if you share types between Document and RPC encoded
> methods. You'll find a list of them at [0].
>
> You don't set the namespace for your header element by attaching a
> SoapElementAttribute, because that doesn't have a Namespace property
> like the XmlElement does.
>
>
> Instead, you attach a SoapType attribute to the HeaderClass:
>
> [SoapType(Namespace="")]
> public sealed class MyHeader : SoapHeader
> {
> // ...
> }
>
>
> HTH,
> Christoph Schittko
> MVP XML
> http://weblogs.asp.net/cschittko
>
>
>
> [0]
> http://msdn.microsoft.com/library/en...attributesthat
> controlsoapencodedserialization.asp?frame=true
>
> > -----Original Message-----
> > From: Brian Tyler [(E-Mail Removed)]
> > Posted At: Wednesday, January 19, 2005 10:31 AM
> > Posted To: microsoft.public.dotnet.framework.aspnet.webservic es
> > Conversation: Changing namespace of a Soap Header
> > Subject: Re: Changing namespace of a Soap Header
> >
> > Christoph,
> >
> > Thanks for the reply - I have good and bad news.
> >
> > Turns out that your suggestion completely fixed the problem - IF - I

> have
> > the web service/proxy using document encoded SOAP. However, if I

> switch to
> > RPC encoded (and leave the XmlElement in place), then the SOAP header
> > switches to what you saw earlier. The namespace for the header is

> switched
> > to <ns of the web service>/encodedTypes.
> >
> > I don't know if that is part of the spec or not - I have not really

> messed
> > with RPC encoding. However, due to a customer requirement I need to be
> > able
> > to support both document and RPC.
> >
> > Thoughts?
> >
> > Brian
> >
> >
> > "Christoph Schittko [MVP]" wrote
> >
> > > You can define the namespace of the header by attaching an

> XmlElement
> > > attribute to the WebService class' header field:
> > >
> > > [WebService(Namespace="http://www.bracketangles.net/ns")]
> > > public class Service1 : System.Web.Services.WebService
> > > {
> > > // ...
> > >
> > >
> > > [XmlElement(Namespace="http://www.bracketangles.net/headers")]
> > > public MyHeader timeHeader;
> > >
> > > [WebMethod]
> > > [SoapHeader("timeHeader",
> > > Direction=SoapHeaderDirection.InOut)]
> > > //...
> > >
> > > HTH,
> > > Christoph Schittko
> > > MVP XML
> > > http://weblogs.asp.net/cschittko
> > >
> > >
> > > > -----Original Message-----
> > > > From: Brian Tyler [(E-Mail Removed)]
> > > > Posted At: Tuesday, January 18, 2005 1:49 PM
> > > > Posted To: microsoft.public.dotnet.framework.aspnet.webservic es
> > > > Conversation: Changing namespace of a Soap Header
> > > > Subject: Changing namespace of a Soap Header
> > > >
> > > > I have defined a soap header via the .NET framework
> > > >
> > > > public sealed class MySoapHeader : SoapHeader
> > > > {
> > > > }
> > > >
> > > > I can successfully send this header either from the client proxy

> or
> > > from
> > > > the
> > > > web service itself. However, it seems that the "type" of the

> header is
> > > > always put into the namespace of the proxy or server. For example,
> > > under a
> > > > simple proxy, I get
> > > >
> > > > <soap:Envelope

> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> > > > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> > > > xmlns:tns="http://tempuri.org"
> > > > xmlns:types="http://tempuri.org/encodedTypes"
> > > > xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> > > > xmlnssd="http://www.w3.org/2001/XMLSchema">
> > > > <soap:Header>
> > > > <types:MySoapHeader id="h_id1"> ...
> > > >
> > > > Note that it is put into the "types" ns, which is based on the ns

> of
> > > the
> > > > proxy.
> > > >
> > > > How do I have the SOAP header have its own namespace? Something I

> can
> > > > define
> > > > as part of the Soap header so it stays the same regardless of the
> > > proxy or
> > > > web service it is used with?
> > > >
> > > > Thanks in advance
> > > >
> > > > Brian
> > >
> > >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header files with "header.h" or <header.h> ?? mlt C++ 2 01-31-2009 02:54 PM
Changing the Namespace URI used for incoming SOAP requests David Clegg ASP .Net Web Services 0 05-05-2008 04:59 AM
How to add SOAP header to a SOAP message? Peter van der veen ASP .Net Web Services 6 11-14-2006 06:44 PM
Changing the SOAP namespace Magesh ASP .Net Web Services 0 10-01-2004 07:37 AM
Creating SOAP Header with namespace pefix Andreas Remsperger ASP .Net Web Services 0 01-30-2004 12:57 PM



Advertisments