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 / November 2005

Tip: Looking for answers? Try searching our database.

Invoking a webmethod (wsewsdl2.exe  vs.  Add Web Reference...)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
alex bean - 11 May 2005 19:22 GMT
Hi,

I've altered the hello world sample web method to take a string parameter
below:

[WebMethod]
public string HelloWorld(string name)
{
    return "Hello " + name;
}

When I use wsewsdl2 to create a class file I have to invoke the web method
this way:

HelloWorld request = new HelloWorld();
request.name = "test";
Service1 proxy_wsewsdl = new Service1();
HelloWorldResponse response = proxy_wsewsdl.HelloWorld(request);
string mystring = response.HelloWorldResult;

But if I use the "Add Web Reference . . . " I can invoke it this way:

intranetserver1.Service1 proxy_WebRef = new intranetserver1.Service1();
string mystring = proxy_WebRef.HelloWorld("test");

I've looked at the source code for the wsewsdl2 generated class and I looked
at the source code from the " Microsoft.VSDesigner" in the Reference.cs file.
I see how each invokes the method differently.

Aside from the obvious (2 lines vs 5 lines of code in the client) why do
wsewsdl.exe and the designer each invoke the method differently?  My guess is
that Wsewsdl.exe is generating some sort of "standards based" class file.  Is
that way to be preferred (even though calling it is a pain)?  
Dilip Krishnan - 11 May 2005 23:57 GMT
Alex,
> I've looked at the source code for the wsewsdl2 generated class and I looked
> at the source code from the " Microsoft.VSDesigner" in the Reference.cs file.
[quoted text clipped - 4 lines]
> that Wsewsdl.exe is generating some sort of "standards based" class file.  Is
> that way to be preferred (even though calling it is a pain)?  

WseWsdl exe generates a proxy thats based on the WSE framework and
wsdl.exe generates a proxy based on th System.Web.Services library. They
essentially do the same thing however, the additional stuff u get with
the wsewsdl client is that it adds the Filters (pipeline) for processing
the WS-* specs. Another interesting thing to note is, WSE (if you have
installed the wse add-in for VS.net) also automatically adds another
proxy in the References.cs/vb thats with the name <wsdl-proxy-name>Wse
that does the same thing as the wsewsdl proxy.

The alternative to not using the wsewsdl generated proxy is to just
derive your proxy from the WebServicesClientProtocol instead of the
standard SoapHttpClientProtocol.

Signature

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilip.krishnan AT apdiya DOT com

alex bean - 12 May 2005 14:26 GMT
Dilip,

Thanks.  I am aware of the filters that WSE adds to your client and service
apps.  I was really wondering what the "best practice" for setting up a call
to web method is?  

More specifically, in first example above (wsewsdl2)  I was required to
create a request object (HelloWorld request = new HelloWorld();),   then I
had to load my string into a property of that object (request.name =
"test";),  then I used that object as the parameter to the webmethod
(=proxy_wsewsdl.HelloWorld(request)  )
The webmethod retuned another object, which I had to access properties to
get the string I was interested in.

Whereas, with the second example all I did was pass the string in directly
and have a sting retuned directly.

Which is "better"?  
Is this the answer:
For this trivial example (pass in one string and get back one string)  the "
wsewsdl2" is overkill and you are probably better off with the Visual Studio
auto generated one but if you had a larger number of complex parameters to a
web method and/or the web method retuned a complex set of parts the "object"
approach (generated by wsewsdl2) is better.

Is that the right answer?  (It probably all boils down to what your
preferences are but I'm also interested in what is considered the best
practice.)
Dilip Krishnan - 12 May 2005 15:24 GMT
There is no real best practice. Its akin to choosing one framework over
the other. Some frameworks are good, some are bad, some are lacking in
features some are loaded with them. I'd say wsdl generated classes are
easy but they dont provide the WS-* stack for you, unless you derive
from the wse client proxy. And once you derive from the wse proxy then
you're pretty much exercising the same WSE code; at which point there is
no real difference.

> Dilip,
>
[quoted text clipped - 24 lines]
> preferences are but I'm also interested in what is considered the best
> practice.)

Signature

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilip.krishnan AT apdiya DOT com

Matt Moran - 22 Nov 2005 03:33 GMT
Hi there,

perhaps you guys could assist in this.  According to the tutorial I'm
working through, if I WSE (v2) enable my web service and the consuming
client and update my client web reference, I should see a <Service>WSE class
(apparently auto generated).  For whatever reason, this is not being created.

In the code pain a comment reads
'This source code was auto-generated by Microsoft.VSDesigner, Version 1.1.
4322.2032.

Note, I'm using .NET 1.1 with WSE 2.0.

Any advice?

thanks

Matt

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.