Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / August 2004

Tip: Looking for answers? Try searching our database.

Calling an ASMX web service (with WSE 2.0) using SoapClient proxy

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SA - 16 Jul 2004 02:05 GMT
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?

Signature

Sven

morten - 16 Jul 2004 08:25 GMT
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

> Hi all:
>
[quoted text clipped - 13 lines]
>
> Any ideas?
SA - 16 Jul 2004 14:36 GMT
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.

Signature

Sven

> Hi Sven
>
[quoted text clipped - 11 lines]
> 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 ));
[quoted text clipped - 21 lines]
> >
> > Any ideas?
SA - 16 Jul 2004 15:02 GMT
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.

Signature

Sven

> Morten:
>
[quoted text clipped - 61 lines]
> > >
> > > Any ideas?
Lucien - 27 Jul 2004 20:23 GMT
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.

> OK, I got it:
>
> adding

Web.Services.Protocols.SoapDocumentMethod(ParameterStyle:=Protocols.SoapPara
> meterStyle.Bare)
>
[quoted text clipped - 72 lines]
> > > >
> > > > Any ideas?
SA - 28 Jul 2004 21:48 GMT
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.

Signature

Sven

> 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
[quoted text clipped - 3 lines]
> >
> > adding

Web.Services.Protocols.SoapDocumentMethod(ParameterStyle:=Protocols.SoapPara
> > meterStyle.Bare)
> >
[quoted text clipped - 78 lines]
> > > > >
> > > > > Any ideas?
Lucien - 06 Aug 2004 18:48 GMT
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).

> Lucien:
>
[quoted text clipped - 10 lines]
> > >
> > > adding

Web.Services.Protocols.SoapDocumentMethod(ParameterStyle:=Protocols.SoapPara
> > > meterStyle.Bare)
> > >
[quoted text clipped - 84 lines]
> > > > > >
> > > > > > Any ideas?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.