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

A

Andy Fish

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
 
J

Josh Twist

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/
 
A

ajfish

Josh Twist wrote:
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?
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top