Groups | Blog | Home
all groups > dotnet web services enhancements > july 2004 >

dotnet web services enhancements : Calling an ASMX web service (with WSE 2.0) using SoapClient proxy


SA
7/15/2004 8:05:28 PM
Hi all:

In order to have one generic proxy class on my client that can both handle
TCP and HTTP channels, I created a class that derives from SoapClient.

It can call my TCP SoapService (running as a Windows Service) fine.

It can call my HTTP .asmx Web Service, but apparently, the SOAP body does
not get deserialized. The argument to my WebMethod is Nothing. Yet, in that
same method calling RequestSoapContext.Current.Envelope.GetBodyObject()
returns a valid object.

If I call the same HTTP web service using a proxy that was generated by
adding a Web Reference, it works fine (i.e. the argument to my WebMethod is
the object I expect it to be).

Any ideas?

--

Sven


SA
7/16/2004 8:36:10 AM
Morten:

Thanks.

In my case, I think the solution is shorter:

Name = RequestSoapContext.Current.Envelope.GetBodyObject(GetType(NameInfo))

seems to work fine.

Of course, it is ridiculous to have to do that, IMHO.

However, I think I found the difference. The SoapClient proxy doesn't use
wrapped mode, so the Soap body element is NameInfo. The Web Services client
proxy does use wrapped mode, so the Soap body element is Hello (name of the
WebMethod I am calling). I think I am going to have to investigate how to
get the SoapClient to use wrapped mode, or stop the Web Service from
requiring wrapped mode.

--

Sven


[quoted text, click to view]

SA
7/16/2004 9:02:13 AM
OK, I got it:

adding

Web.Services.Protocols.SoapDocumentMethod(ParameterStyle:=Protocols.SoapPara
meterStyle.Bare)

As an attribute on my WebMethod did the trick! I can now use one SoapClient
proxy to call TCP, HTTP, and ASMX web services.

--

Sven


[quoted text, click to view]

morten
7/16/2004 9:25:58 AM
Hi Sven

I've been struggeling with the same kind of problem. But only if my service
returns a DataSet, all other object that i tried works fine.

I don't know if this is a confirmed bug or a feature.

Workaround to get DataSet out off bodyobject follows here.:

SoapEnvelope resultEnvelope = this.SendRequestResponse("getData", envelope);

// extract result data.
//BUG: DataSet ds = (DataSet) envelope.GetBodyObject(typeof(DataSet)); //
Bug in the WSE 2.0 work around shown below.
DataSet ds = (DataSet) XmlSerializerCache.GetXmlSerializer(typeof(DataSet),
"http://tempuri.org/").Deserialize( new
StringReader(resultEnvelope.Body.InnerXml ));

Regards
Morten




[quoted text, click to view]

Lucien
7/27/2004 12:23:35 PM
Yes you can either make the call wrapped, or change the service to be bare.
If you use the wsewsdl2 tool to create the proxy it will do this
automatically.

[quoted text, click to view]

SA
7/28/2004 3:48:51 PM
Lucien:

I don't use wsewsdl2, I inherit from SoapClient to create my own proxy
class. That's the only way I found it possible to use one class to call both
Tcp and Http and ASMX services.

--

Sven


[quoted text, click to view]

Lucien
8/6/2004 10:48:10 AM
That can't be right. The proxy classes are completely abstract from the
protocol. The only thing that changes is the serviceURI in the contstructor
and you can still change that after instantiating through the destination
property.

If you found issues with this let me know because that should not be the
case (and I haven't come across this).


[quoted text, click to view]

AddThis Social Bookmark Button