Disco.exe :-
Discovey is the most important step when it comes to webservices. This tool discovers the URL's of XML webservices on a given web server. Discovery of webservices is important for its consumers as from the discovery document they can know about the various services they can consume.
This tool locates the webservice. If it finds the webservice it creates .wsdl, .xsd, .disco, and .discomap files and if it does not then the error message displayed to the user.
Let us use this tool to discover our webservice and create the above files:
1) Go to the VS.NET command prompt
2) Run disco.exe /? for checking out all the options
3) This is a list of some important options :
/nosave - Do not save the discovered documents or results to disk (for example wsdl, xsd and disco files). The default is to save the documents.
/out:
/username:
/password:
/domain:
/proxy:
4) To discover the disco files of the webservice give the URL of the web service as
disco.exe http://localhost/MyWebservice/service1.asmx /nosave .
If the URL is found the following message will be displayed to you :
Microsoft (R) Web Services Discovery Utility
[Microsoft (R) .NET Framework, Version 1.0.3705.0]
Copyright (C) Microsoft Corporation 1998-2001. All rights reserved.
Disco found documents at the following URLs:
http://localhost/MyWebservice/service1.asmx?disco
http://localhost/MyWebservice/service1.asmx?wsdl
5) We will now perform the same command without /nosave option to save the document in MyWebSerDocs folder. Please see to it
that the directory exists as this tool does not create the directory
disco.exe http://localhost/MyWebservice/service1.asmx /out:MyWebSerDocs
6)You should see a similar output
Microsoft (R) Web Services Discovery Utility
[Microsoft (R) .NET Framework, Version 1.0.3705.0]
Copyright (C) Microsoft Corporation 1998-2001. All rights reserved.
Disco found documents at the following URLs:
http://localhost/MyWebservice/service1.asmx?disco
http://localhost/MyWebservice/service1.asmx?wsdl
The following files hold the content found at the corresponding URLs:
MyWebSerDocs\service1.disco <- http://localhost/MyWebservice/service1.asmx?disco
MyWebSerDocs\service1.wsdl <- http://localhost/MyWebservice/service1.asmx?wsdl
The file MyWebSerDocs\results.discomap holds links to each of these files.
7) Check out the directory it should have all the above 3 files i.e. Service1.disco, Service1.wsdl and results.discomap
8) Similarly you can discover any web service with this tool and create the .disco, .wsdl and discomap files.
9) These files that we have generated with disco.exe can be used as an input to wsdl.exe to create our webservice proxy class.
WSDL.exe :-
This tool is used to generate webservice proxy class. This file contains all the details for its clients to use when they are interacting
with the webservice.
Let us create the webservice proxy class:
1) Go to VS.Net command prompt
2) Type wsdl.exe /? to view all the options
3) I have listed a few important options below :
/language:
System.CodeDom.Compiler.CodeDomProvider. The default is 'CS' (CSharp).
/server Generate an abstract class for an xml web service implementation using ASP.NET based on the contracts. The default is to generate client proxy classes.
/out:
The filename for the generated proxy code. The default name is derived from
the service name. Short form is '/o:'.
/protocol:
4) To generate the proxy class you can either use .wsdl or .discomap file that we have generated using the disco.exe or you can give the webservice url as input.
5) We will create our proxy class using the .wsdl and .discomap files that we had generated.
6) Type the following command :
wsdl.exe Service1.wsdl
or
wsdl.exe results.discomap.
Service1.cs class will be generated.
7) You can use this proxy class with any of the client application to interact with the webservice.
8) Create a client application say a Windows application and add the proxy class to it by choosing Add Existing Item and selecting out proxy class Service1.cs. Create the webservice object and call any method on it.
Service1 myWebSer = new Service1();
MessageBox.Show(myWebSer.HelloWorld());
No comments:
Post a Comment