Can't use SoapHeaderAttribute and SoapExtensionAttribute together

Discussion in 'ASP .Net Web Services' started by Mike, Nov 15, 2005.

  1. Mike

    Mike Guest

    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.
     
    Mike, Nov 15, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TW9yaQ==?=
    Replies:
    3
    Views:
    323
    Patrick.O.Ige
    Jan 18, 2006
  2. Sandra-24
    Replies:
    1
    Views:
    462
    Sandra-24
    Dec 22, 2006
  3. Tim Tyannikov
    Replies:
    0
    Views:
    170
    Tim Tyannikov
    Aug 17, 2004
  4. Tim Tyannikov
    Replies:
    1
    Views:
    327
    Trebek
    Aug 18, 2004
  5. A.M-SG
    Replies:
    1
    Views:
    330
    Steven Cheng[MSFT]
    Sep 14, 2005
Loading...

Share This Page