using the [WebMethod(MessageName="...")] attribute

Discussion in 'ASP .Net Web Services' started by Andy Fish, Mar 16, 2006.

  1. Andy Fish

    Andy Fish Guest

    Hi,

    I have discovered that if I use this syntax:

    [WebMethod(MessageName="foo")]
    public string bar() {
    return "hello, world";
    }

    then it is not possible to call the web service using the MS soap toolkit.
    Trying to invoke the service with either the name foo or bar gives an error.

    I'm afraid I'm not much of an expert on SOAP and WSDL (I was rather hoping
    that using 2 microsoft implementations of the same standard would give me a
    good chance of interoperability without having to delve into the innards of
    the standard)

    Could someone explain whether this is a deficiency in the SOAP toolkit, or
    is this feature (the ability to have the operation name different from the
    SOAP action) an unofficial .Net extension of the web services standards?

    TIA

    Andy
     
    Andy Fish, Mar 16, 2006
    #1
    1. Advertising

  2. Andy Fish

    Josh Twist Guest

    Hi Andy,

    All that changes is the name of the element that wraps the parameters
    (none in your case) and the SOAP Action header.

    Without MessageName:

    POST /Temp/AspNet20SandPit/Service.asmx HTTP/1.1
    Host: localhost
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://tempuri.org/bar"

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <bar xmlns="http://tempuri.org/" />
    </soap:Body>
    </soap:Envelope>

    With MessageName="foo":

    POST /Temp/AspNet20SandPit/Service.asmx HTTP/1.1
    Host: localhost
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://tempuri.org/foo"

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <foo xmlns="http://tempuri.org/" />
    </soap:Body>
    </soap:Envelope>

    It's been a while since I've used the Soap Toolkit but from memory this
    should be pretty easy to do. Maybe you can post a snippet of how you're
    creating the soap toolkit message.

    Josh
    http://www.thejoyofcode.com/
     
    Josh Twist, Mar 16, 2006
    #2
    1. Advertising

  3. Andy Fish

    Guest

    Josh Twist wrote:
    <snip>
    >
    > It's been a while since I've used the Soap Toolkit but from memory this
    > should be pretty easy to do. Maybe you can post a snippet of how you're
    > creating the soap toolkit message.
    >


    well, I'm calling it from VB, so my code just looks like this:

    Dim Connection As new SoapClient30
    Connection.MSSoapInit wsdlFile
    Connection.foo
    Connection.bar

    this works by the MSSOAP dynamically creating a IDispatch interface
    when the WSDL file is parsed. I guess what you're saying is that I have
    to hook in at a lower level to impact the XML that gets sent?
     
    , Mar 16, 2006
    #3
    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. Temp
    Replies:
    1
    Views:
    1,100
    Natty Gur
    Aug 11, 2003
  2. sunnyz
    Replies:
    1
    Views:
    2,960
    Kevin Spencer
    Oct 15, 2004
  3. Dustyg

    Creating a custom [WebMethod] attribute

    Dustyg, Jan 19, 2006, in forum: ASP .Net Web Services
    Replies:
    4
    Views:
    309
    Dustyg
    Jan 25, 2006
  4. Steven

    error using arraylist as webmethod argument

    Steven, Feb 12, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    179
    Steven
    Feb 12, 2006
  5. Vijay

    MessageName in WebMethod

    Vijay, Feb 21, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    134
    Vijay
    Feb 21, 2006
Loading...

Share This Page