473,395 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Overriding the soapheader Namespace

I wish to change/set the namespace for a header in my web service. I have
found the following code and it does not appear to work and my assumption is
because I am using RPC encoding...

[WebService(Namespace="http://www.mydomain.net/ns")]
public class Service1 : System.Web.Services.WebService
{
// ...

[XmlElement(Namespace="http://www.myotherdomain.net/headers")]
public MyHeader timeHeader;

[WebMethod]
[SoapHeader("timeHeader",Direction=SoapHeaderDirect ion.InOut)]
//...

Is there something I should use instead of the XmlElement to override the
header's namespace?

TIA
Feb 1 '06 #1
7 7038
Hi Michael,

Welcome to the MSDN newsgroup.

As for the ASP.NET webservice's SoapHeader element namespace problem, it is
the expected behavior because the SOAP Rpc encoded message format won't
generate the SOAP message according to the WSDL xml schema or the .NET
class's xml seriazliation format. RPC style SOAP message will generate xml
content for a certain object structure following the encoding rules

#5.1 Rules for Encoding Types in XML
http://www.w3.org/TR/2000/NOTE-SOAP-...#_Toc478383513

So in order to make our web service's request/response SOAP message (XML
content) conforms to our XML schema or .NET class's xml serialization
defination, we should use Document/Literal message style instead of
RPC/encoded....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Feb 2 '06 #2
So to clarify...there is no way for me to override/set the namespace for the
timeHeader structure below.
[WebService(Namespace="http://www.mydomain.net/ns")]
public class Service1 : System.Web.Services.WebService
{
// ...

[XmlElement(Namespace="http://www.myotherdomain.net/headers")]
public MyHeader timeHeader;

[WebMethod]
[SoapHeader("timeHeader",Direction=SoapHeaderDirect ion.InOut)]
//...
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:4P**************@TK2MSFTNGXA02.phx.gbl...
Hi Michael,

Welcome to the MSDN newsgroup.

As for the ASP.NET webservice's SoapHeader element namespace problem, it
is
the expected behavior because the SOAP Rpc encoded message format won't
generate the SOAP message according to the WSDL xml schema or the .NET
class's xml seriazliation format. RPC style SOAP message will generate xml
content for a certain object structure following the encoding rules

#5.1 Rules for Encoding Types in XML
http://www.w3.org/TR/2000/NOTE-SOAP-...#_Toc478383513

So in order to make our web service's request/response SOAP message (XML
content) conforms to our XML schema or .NET class's xml serialization
defination, we should use Document/Literal message style instead of
RPC/encoded....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Feb 2 '06 #3
Thanks for your respone Michael,

Yes, for RPC style message, the soap header's element namespace is an
autogenerated encoding namespace, which derived from the service's
namespace but do not utilize the XML Element's namespace... So those XML
Serizliation attribute can not control that.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Feb 3 '06 #4
OK...here's a WSDL for a test webservice. It appears to be
Document/Literal. I also have the following line of code and it does not
appear to modify the WSDL. Can you tell me why?

[WebService(Namespace="http://Com.SouthernCompany.SecurityTest/webservices/")]
public class Service1 : System.Web.Services.WebService

{

[XmlElement(Namespace="https://ws.southernco.com/CoolSecurity")]

public Com.SouthernCompany.Cool.Security.ScCredentials
authenticationCredentials;

<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://Com.SouthernCompany.SecurityTest/webservices/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://Com.SouthernCompany.SecurityTest/webservices/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
+ <s:schema elementFormDefault="qualified"
targetNamespace="http://Com.SouthernCompany.SecurityTest/webservices/">
- <s:element name="HelloWorld">
<s:complexType />
</s:element>
- <s:element name="HelloWorldResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ScCredentials" type="tns:ScCredentials" />
- <s:complexType name="ScCredentials">
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="DirectUserNameToken"
type="tns:ScUserNameToken" />
<s:element minOccurs="0" maxOccurs="1" name="OriginatingUserNameToken"
type="tns:ScUserNameToken" />
<s:element minOccurs="0" maxOccurs="1" name="Created" type="s:string" />
</s:sequence>
</s:complexType>
- <s:complexType name="ScUserNameToken">
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Type" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Nonce" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="BinarySecurityToken"
type="tns:ScBinarySecurityToken" />
</s:sequence>
</s:complexType>
- <s:complexType name="ScBinarySecurityToken">
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ValueType" type="s:string" />
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
- <wsdl:message name="HelloWorldSoapIn">
<wsdl:part name="parameters" element="tns:HelloWorld" />
</wsdl:message>
- <wsdl:message name="HelloWorldSoapOut">
<wsdl:part name="parameters" element="tns:HelloWorldResponse" />
</wsdl:message>
- <wsdl:message name="HelloWorldScCredentials">
<wsdl:part name="ScCredentials" element="tns:ScCredentials" />
</wsdl:message>
- <wsdl:portType name="Service1Soap">
- <wsdl:operation name="HelloWorld">
<wsdl:input message="tns:HelloWorldSoapIn" />
<wsdl:output message="tns:HelloWorldSoapOut" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
- <wsdl:operation name="HelloWorld">
<soap:operation
soapAction="http://Com.SouthernCompany.SecurityTest/webservices/HelloWorld"
style="document" />
- <wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:HelloWorldScCredentials" part="ScCredentials"
use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
<soap:header message="tns:HelloWorldScCredentials" part="ScCredentials"
use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="Service1">
- <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
<soap:address
location="http://localhost/WebServiceSecurityTest2/Service1.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:IQ**************@TK2MSFTNGXA02.phx.gbl...
Thanks for your respone Michael,

Yes, for RPC style message, the soap header's element namespace is an
autogenerated encoding namespace, which derived from the service's
namespace but do not utilize the XML Element's namespace... So those XML
Serizliation attribute can not control that.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Feb 10 '06 #5
I simply wish to override the namespace for the ScCredentials structure

Thank you,
MP

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:IQ**************@TK2MSFTNGXA02.phx.gbl...
Thanks for your respone Michael,

Yes, for RPC style message, the soap header's element namespace is an
autogenerated encoding namespace, which derived from the service's
namespace but do not utilize the XML Element's namespace... So those XML
Serizliation attribute can not control that.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Feb 10 '06 #6
And just incase you need it....here's the declaration for the method using
the SoapHeader..
[WebMethod]

[System.Web.Services.Protocols.SoapHeader("authenti cationCredentials",
Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]

public string HelloWorld( string test)
Feb 10 '06 #7
Hi Michael,

Have you tried directly apply namespace on the custom SoapHeader class
itself. like:

[XmlRoot("MySoapHeader",Namespace="http://mytest.dotnet.org")]
public class MyHeader : SoapHeader
{
...................

It works on my side.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Feb 15 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eric | last post by:
Hi, I have a WebService client. All the code is generated by VS.NET 2003. The problem is that some attributes are not generated. All the attributes in the base class are generated. But the...
1
by: justin_sun | last post by:
All the sample code that I can find on SoapHeader is at least one level down within a root node. However, I'm working on a project needs to create a soap header like this: <SOAP-ENV:Header>...
0
by: justin_sun | last post by:
I'm working on a project needs to create a soap header like this: <SOAP-ENV:Header> <MessageID> uuid:6B29FC40-CA47-1067-B31D-00DD010662DA </:MessageID> <To>http://abc.example</To>...
2
by: Mike Fiedler | last post by:
On a client web services request, I have a SoapExtension that is adding a header to the message in the BeforeSerialize stage. If the Web Service request is for an operation with...
0
by: Peter Morris [Droopy eyes software] | last post by:
I'm not sure what my problem is so I thought I'd post here to see if anyone can shed some light onto my problem. 1) I have a SoapHeader descendant called AuthenticateUserHeader that has UserName...
0
by: Mannfred | last post by:
I've written a complex web service in C# to be used by SmartDevices and I'm trying to reduce size of the message to the absolute minimum to save on cost, every byte counts etc. Is there any way...
7
by: Lighter | last post by:
Is overriding a function of a library in accordance with C++ standard? The following code are passed by the VS 2005 and Dev C++. #include <cstdlib> #include <iostream> using namespace std;...
10
by: Andy Kendall | last post by:
I have a problem accessing my custom SoapHeader from a SoapExtension. My extension has no compile time reference to the class derived from SoapHeader, so how can cast it into a SoapHeader of the...
0
by: Fred | last post by:
I am trying to build a consumer to a webservice which use soapheader. I am using Visual Studio 2003. Please see the wsdl-file below. Why is it that the SOAPHEADER is empty when I use it int the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.