1 / 22

Module 13: Consuming and Creating XML Web Services

Module 13: Consuming and Creating XML Web Services. Overview. Overview of Using XML Web Services Calling an XML Web Service Using HTTP Using a Proxy to Call an XML Web Service Creating an XML Web Service. Lesson: Overview of Using XML Web Services. What is an XML Web Service?

sef
Télécharger la présentation

Module 13: Consuming and Creating 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. Module 13:Consuming and Creating XML Web Services

  2. Overview • Overview of Using XML Web Services • Calling an XML Web Service Using HTTP • Using a Proxy to Call an XML Web Service • Creating an XML Web Service

  3. Lesson: Overview of Using XML Web Services • What is an XML Web Service? • Why use XML Web Services? • Finding an XML Web Service • Multimedia: XML Web Service Execution Model

  4. What is an XML Web Service? • Programmable logic accessible by standard Web protocols • Allows applications to send and receive information across the Internet • Language, protocol, and platform independent • Stateless architecture • Can be asynchronous • Based on an evolving W3C standard

  5. Why Use XML Web Services? Northwind Traders Travel Site WeatherXML Web Service Pick your destination: Redmond The weatherForecast calls for: Rain Exchange Rate XML Web Service Internet The exchange rate is: $1.56 We can fly you there for only: $1,999.98 Airfare XML Web Service Airfare Database

  6. Finding an XML Web Service Publish XML Web service URL and description 1 UDDI 2 Discover XML Web service 3 Locate XML Web service URL 4 Read .wsdl description Bind XML Web Service to Proxy 5 2 1 Call XML Web Service from the Web Form by Proxy 6 .disco WebForm 3 .wsdl 4 5 6 Web Service Proxy

  7. Multimedia: XML Web Service Execution Model

  8. Lesson: Calling an XML Web Service Using HTTP • How to Call an XML Web Service Using HTTP • Practice: Calling an XML Web Service Using HTTP

  9. How to Call an XML Web Service Using HTTP • Navigate to the XML Web service URL • Select an XMLWeb servicemethod • Call the XML Web service method • View the XMLresponse 1 2 3 4

  10. Practice: Calling an XML Web Service Using HTTP The Student will: • Enter an XML Web Service URL on the instructor machine • Select the XML Web service method to call • Enter values for parameters • View the returned XML Time: 5 Minutes

  11. Lesson: Using a Proxy to Call an XML Web Service • Using Proxies to Call XML Web Services • How to Use a Proxy to Call an XML Web Service • Instructor-Led Practice: Using a Proxy to Call an XML Web Service • XML Web Service Error Handling • Demonstration: Testing the Availability of an XML Web Service

  12. Using Proxies to Call XML Web Services • Appear the same as the original class, but do not contain application logic • Use SOAP to interact with the XML Web Service • Created from the ServiceName.asmx.wsdl file • Add members to manage interactions with the XML Web service and support asynchronous calls WebForm Internet XML WebService SOAP Proxy

  13. How to Use a Proxy to Call an XML Web Service • Create a Web reference for the XML Web Service • Create an instance of the XML Web Service • Call the Web methods of the XML Web Service • Build the ASP.NET Web Application 1 2 3 4 Sub Button1_Click(s As Object, e As EventArgs)... Dim ProxyGetStocks As New _ GetStocks.localhost.Service1() lblResults.Text = _ ProxyGetStocks.GetRating("Contoso") End Sub C# Code Example

  14. Instructor-Led Practice: Using a Proxy to Call an XML Web Service • Create a new ASP.NET Web Application project • Create a proxy for an XML Web service • Test with a browser • View the reference.vb or reference.cs file

  15. XML Web Service Error Handling • Service unavailable • SOAP exceptions from XML Web Services GetStocks.StockWebRef.Service1 ProxyGetStocks = new GetStocks.StockWebRef.Service1(); ProxyGetStocks.Timeout = 10000; try { lblMessage.Text = ProxyGetStocks.GetRating(TextBox1.Text); } catch (Exception err) { lblMessage.Text = err.Message; } Visual Basic .NET Code Example

  16. Demonstration: Testing the Availability of a XML Web Service • Set a timeout error handling Try…Catch statement • Slow the Web service • Test the exception

  17. Lesson: Creating an XML Web Service • How to Create an XML Web Service • XML Web Service Code • Instructor-Led Practice: Creating an XML Web Service

  18. How to Create an XML Web Service 1 • Create a new XML Web Service project in Visual Studio .NET • Declare the WebMethod functions • Build the XML Web Service project • Test witha browser 2 3 4

  19. XML Web Service Code • .asmx page • .asmx.vb page <%@ WebService Language="vb" Codebehind="Service1.asmx.vb" Class="XMLWebServiceName.Service1" %> Imports System Imports System.Web.Services Class Service1 <WebMethod()> Public Function function1() As type 'function_here End Function End Class C# Code Example

  20. Instructor-Led Practice: Creating an XML Web Service • Create an XML Web Service • Test the XML Web Service • Change the Namespace

  21. Review • Overview of Using XML Web Services • Calling an XML Web Service Using HTTP • Using a Proxy to Call an XML Web Service • Creating an XML Web Service

  22. Lab 13: Consuming and Creating XML Web Services Logon Page Login.aspx BenefitsHome PageDefault.aspx CohoWinery Page HeaderHeader.ascx ASPState Menu ComponentClass1.vb or Class1.cs Registration Register.aspx Web.config tempdb Life InsuranceLife.aspx RetirementRetirement.aspx MedicalMedical.aspx DentalDental.aspx XML Web ServicedentalService1.asmx ProspectusProspectus.aspx DoctorsDoctors.aspx User Controlnamedate.ascx Lab Web Application XML Files Doctors Dentists

More Related