1 / 13

XML Web Services

XML Web Services. Alejandro Simon asc0_cate@hotmail.com Course Site: http://asc0.dynup.net/dotnet/ 03/07/03 3:00pm. Client. Web Server Web Service. What are Web Services?. A mean for applications that have network access to consume services provided by a network machine. XML. Network.

milla
Télécharger la présentation

XML Web Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML Web Services Alejandro Simon asc0_cate@hotmail.com Course Site: http://asc0.dynup.net/dotnet/ 03/07/03 3:00pm

  2. Client Web Server Web Service What are Web Services? • A mean for applications that have network access to consume services provided by a network machine. XML Network

  3. Versatility of Web Services • Web Services can be consumed in all types of .NET applications, from ASP.NET web pages to Windows Applications. • Can be consumed in .NET, JAVA, ??? • Can be originated in .NET, JAVA, ??? • Use XML for communication, hence developing language is secondary.

  4. Web Service Mentality • The Web Service Provider is a black box which provides a simple / complicated service through a very simple to use interface. Example: Kinko’s is releasing a Web Service along with an Office client, that will allow you to print from Office and have the results be physically generated, bound, and delivered through Kinko’s

  5. Creating a Web Service Project • File->New->Project • Select Visual C# Project on the left, ASP.NET Web Service on the right. • Modify the last part of the location of the Web Service, the name will change. • Click Ok • A new solution with the Web Service project will be created for you. • Default name of Web Service is Service1.asmx. (Trivia: asmx stands for Active Server Methods) • In the solution explorer, change it to a name of your liking. (right click->rename)

  6. Customizing your Web Service • Choose “View Code” option either from design view, or right click on the .asmx file • Select the HelloWorld web method and use the Comment/Uncomment Buttons to enable it. • Build Project • Visit Web Service page at http://webserver/projectname/webservice.asmx

  7. Web Output of Web Service Class name: Service1 (modify the class name in asmx file to fix this) List of WebMethods (only HelloWorld) Error about default namespace Tags to add to fix it

  8. Consuming a Web Service • Step 1: Build a proxy class • The proxy class will simulate that the web service is a class that is local to your application. • The proxy class takes care of all the communication and parameter passing issues.

  9. How do you build a proxy class? • WSDL.EXE can automatically generate one for you. Start a Visual Studio.NET Command Prompt from Visual Studio.NET Tools Change directories (cd) to your application directory Execute: wsdl /o:WSDemo1p.cs http://asc0.dynup.net/WSDemo1/WSDemo1.asmx • To get help, just execute wsdl.exe without parameters.

  10. What to do with the proxy class? • In the Solution Explorer, click the Show All Files button • Right click on the proxy class, then select “Include in project” • Now you can click on the proxy class to see and modify the code (only if you want to) • From now on, you can use the proxy class in the application. • If you build at this point, you will get compilation errors in: using System.Web.Services.Protocols;

  11. The importance of Project References • Before the proxy class even compiles, one must add a web reference to the project. • This lets Visual Studio know that we will be using Web Services. • On the project, right click on References, select Add Web Reference. • In the address box, type the web path to the asmx file that contains web service. • Once Add Reference button is available, click it and you are good to go!

  12. Consuming Web Services in Windows Forms. • Same steps as in ASP.NET • Use proxy class previously build or build one. • Add Web Reference (MOST IMPORTANT!)

  13. Contact Information • Alejandro Simon asc0_cate@hotmail.com http://asc0.dynup.net/dotnet/

More Related