Can't use SoapHeaderAttribute and SoapExtensionAttribute together

M

Mike

I need to use a SOAP Extension within a .NET CF application. The
application invokes web services, and there is currently a
SoapHeaderAttribute specified for authentication information.

Within the web service proxy, there is a class defined like this:

[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://myurl")]

[System.Xml.Serialization.XmlRootAttribute(Namespace="http://myurl",
IsNullable=false)]
public class MyAuthenticationHeader :
System.Web.Services.Protocols.SoapHeader {

/// <remarks/>
public string Username;

/// <remarks/>
public string Password;
}

The web method declaration within the web service proxy is currently:

[System.Web.Services.Protocols.SoapHeaderAttribute("MyAuthenticationHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://myurl/MyWebMethod",
RequestNamespace="http://myurl", ResponseNamespace="http://myurl",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string[] MyWebMethod(string[] arg1, string[] arg2) {
object[] results = this.Invoke("MyWebMethod", new object[]
{
arg1,
arg2});
return ((string[])(results[0]));
}


I want to add a SOAP Extension Attribute to the method declaration like
this:

[System.Web.Services.Protocols.SoapHeaderAttribute("MyAuthenticationHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://myurl/MyWebMethod",
RequestNamespace="http://myurl", ResponseNamespace="http://myurl",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[MySoapExtension]
public string[] MyWebMethod(string[] arg1, string[] arg2) {
object[] results = this.Invoke("MyWebMethod", new object[]
{
arg1,
arg2});
return ((string[])(results[0]));
}

Everything works if I use EITHER the SoapHeaderAttribute OR the
SoapExtensionAttribute. However, if I try to use both, I get an
ArgumentNullException immediately after the GetInitializer() method in
my SOAP Extension class fires. There is no other information
available.

Worst case, I can put the authentication information into the SOAP
Header by means of my SOAP Extension, and just do without the
SoapHeaderAttribute. However, this is code someone else has written
and is maintaining, so I want to change it as little as possible.

Thanks in advance for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top