Module 13: Consuming and Creating  XML Web Services
Overview <ul><li>Overview of Using XML Web Services </li></ul><ul><li>Calling an XML Web Service Using HTTP </li></ul><ul>...
Lesson: Overview of Using XML Web Services <ul><li>What is an XML Web Service? </li></ul><ul><li>Why use XML Web Services?...
What is an XML Web Service? <ul><li>Programmable logic accessible by standard Web protocols </li></ul><ul><ul><li>Allows a...
Why Use XML Web Services? Internet Weather XML Web Service Exchange Rate XML Web Service Pick your destination: The weathe...
Finding an XML Web Service Publish XML Web service URL  and description .disco .wsdl Web Service Proxy Web Form UDDI 1 2 3...
Multimedia:  XML Web Service Execution Model
Lesson: Calling an XML Web Service Using HTTP <ul><li>How to Call an XML Web Service Using HTTP </li></ul><ul><li>Practice...
How to Call an XML Web Service Using HTTP <ul><li>Navigate to the XML Web service URL </li></ul><ul><li>Select an XML Web ...
Practice: Calling an XML Web Service Using HTTP <ul><li>The Student will: </li></ul><ul><ul><li>Enter an XML Web Service U...
Lesson: Using a Proxy to Call an XML Web Service <ul><li>Using Proxies to Call XML Web Services  </li></ul><ul><li>How to ...
Using Proxies to Call XML Web Services  <ul><li>Appear the same as the original class, but do not contain application logi...
How to Use a Proxy to Call an XML Web Service <ul><li>Create a Web reference for the XML Web Service </li></ul><ul><li>Cre...
Instructor-Led Practice: Using a Proxy to Call an XML Web Service <ul><li>Create a new ASP.NET Web Application project </l...
XML Web Service Error Handling <ul><li>Service unavailable </li></ul><ul><li>SOAP exceptions from XML Web Services </li></...
Demonstration: Testing the Availability of a XML Web Service <ul><li>Set a timeout error handling Try…Catch statement  </l...
Lesson: Creating an XML Web Service <ul><li>How to Create an XML Web Service  </li></ul><ul><li>XML Web Service Code </li>...
How to Create an XML Web Service <ul><li>Create a new XML Web Service project in Visual Studio .NET </li></ul><ul><li>Decl...
XML Web Service Code <ul><li>.asmx page </li></ul><ul><li>.asmx.vb page </li></ul><%@ WebService Language=&quot;vb&quot;  ...
Instructor-Led Practice: Creating an XML Web Service <ul><li>Create an XML Web Service  </li></ul><ul><li>Test the XML Web...
Review <ul><li>Overview of Using XML Web Services </li></ul><ul><li>Calling an XML Web Service Using HTTP </li></ul><ul><l...
Lab 13: Consuming and Creating XML Web Services Medical Medical.aspx Benefits Home Page Default.aspx Life Insurance Life.a...
Upcoming SlideShare
Loading in …5
×

2310 b 13

720 views

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
720
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
31
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

2310 b 13

  1. 1. Module 13: Consuming and Creating XML Web Services
  2. 2. Overview <ul><li>Overview of Using XML Web Services </li></ul><ul><li>Calling an XML Web Service Using HTTP </li></ul><ul><li>Using a Proxy to Call an XML Web Service </li></ul><ul><li>Creating an XML Web Service </li></ul>
  3. 3. Lesson: Overview of Using XML Web Services <ul><li>What is an XML Web Service? </li></ul><ul><li>Why use XML Web Services? </li></ul><ul><li>Finding an XML Web Service </li></ul><ul><li>Multimedia: XML Web Service Execution Model </li></ul>
  4. 4. What is an XML Web Service? <ul><li>Programmable logic accessible by standard Web protocols </li></ul><ul><ul><li>Allows applications to send and receive information across the Internet </li></ul></ul><ul><ul><li>Language, protocol, and platform independent </li></ul></ul><ul><ul><li>Stateless architecture </li></ul></ul><ul><ul><li>Can be asynchronous </li></ul></ul><ul><li>Based on an evolving W3C standard </li></ul>
  5. 5. Why Use XML Web Services? Internet Weather XML Web Service Exchange Rate XML Web Service Pick your destination: The weather Forecast calls for: The exchange rate is: We can fly you there for only: Rain Redmond $1.56 $1,999.98 Airfare Database Airfare XML Web Service Northwind Traders Travel Site
  6. 6. Finding an XML Web Service Publish XML Web service URL and description .disco .wsdl Web Service Proxy Web Form UDDI 1 2 3 4 5 6 1 2 3 4 5 Discover XML Web service Locate XML Web service URL Read .wsdl description Bind XML Web Service to Proxy Call XML Web Service from the Web Form by Proxy 6
  7. 7. Multimedia: XML Web Service Execution Model
  8. 8. Lesson: Calling an XML Web Service Using HTTP <ul><li>How to Call an XML Web Service Using HTTP </li></ul><ul><li>Practice: Calling an XML Web Service Using HTTP </li></ul>
  9. 9. How to Call an XML Web Service Using HTTP <ul><li>Navigate to the XML Web service URL </li></ul><ul><li>Select an XML Web service method </li></ul><ul><li>Call the XML Web service method </li></ul><ul><li>View the XML response </li></ul>1 2 3 4
  10. 10. Practice: Calling an XML Web Service Using HTTP <ul><li>The Student will: </li></ul><ul><ul><li>Enter an XML Web Service URL on the instructor machine </li></ul></ul><ul><ul><li>Select the XML Web service method to call </li></ul></ul><ul><ul><li>Enter values for parameters </li></ul></ul><ul><ul><li>View the returned XML </li></ul></ul><ul><li>Time: 5 Minutes </li></ul>
  11. 11. Lesson: Using a Proxy to Call an XML Web Service <ul><li>Using Proxies to Call XML Web Services </li></ul><ul><li>How to Use a Proxy to Call an XML Web Service </li></ul><ul><li>Instructor-Led Practice: Using a Proxy to Call an XML Web Service </li></ul><ul><li>XML Web Service Error Handling </li></ul><ul><li>Demonstration: Testing the Availability of an XML Web Service </li></ul>
  12. 12. Using Proxies to Call XML Web Services <ul><li>Appear the same as the original class, but do not contain application logic </li></ul><ul><li>Use SOAP to interact with the XML Web Service </li></ul><ul><li>Created from the ServiceName .asmx.wsdl file </li></ul><ul><li>Add members to manage interactions with the XML Web service and support asynchronous calls </li></ul>Internet XML Web Service Proxy Web Form SOAP
  13. 13. How to Use a Proxy to Call an XML Web Service <ul><li>Create a Web reference for the XML Web Service </li></ul><ul><li>Create an instance of the XML Web Service </li></ul><ul><li>Call the Web methods of the XML Web Service </li></ul><ul><li>Build the ASP.NET Web Application </li></ul>Sub Button1_Click(s As Object, e As EventArgs)... Dim ProxyGetStocks As New _ GetStocks.localhost.Service1() lblResults.Text = _ ProxyGetStocks.GetRating(&quot;Contoso&quot;) End Sub 1 2 3 4 C# Code Example
  14. 14. Instructor-Led Practice: Using a Proxy to Call an XML Web Service <ul><li>Create a new ASP.NET Web Application project </li></ul><ul><li>Create a proxy for an XML Web service </li></ul><ul><li>Test with a browser </li></ul><ul><li>View the reference.vb or reference.cs file </li></ul>
  15. 15. XML Web Service Error Handling <ul><li>Service unavailable </li></ul><ul><li>SOAP exceptions from XML Web Services </li></ul>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. 16. Demonstration: Testing the Availability of a XML Web Service <ul><li>Set a timeout error handling Try…Catch statement </li></ul><ul><li>Slow the Web service </li></ul><ul><li>Test the exception </li></ul>
  17. 17. Lesson: Creating an XML Web Service <ul><li>How to Create an XML Web Service </li></ul><ul><li>XML Web Service Code </li></ul><ul><li>Instructor-Led Practice: Creating an XML Web Service </li></ul>
  18. 18. How to Create an XML Web Service <ul><li>Create a new XML Web Service project in Visual Studio .NET </li></ul><ul><li>Declare the WebMethod functions </li></ul><ul><li>Build the XML Web Service project </li></ul><ul><li>Test with a browser </li></ul>1 2 3 4
  19. 19. XML Web Service Code <ul><li>.asmx page </li></ul><ul><li>.asmx.vb page </li></ul><%@ WebService Language=&quot;vb&quot; Codebehind=&quot;Service1.asmx.vb&quot; Class=&quot;XMLWebServiceName.Service1&quot; %> Imports System Imports System.Web.Services Class Service1 <WebMethod()> Public Function function1 () As type 'function_here End Function End Class C# Code Example
  20. 20. Instructor-Led Practice: Creating an XML Web Service <ul><li>Create an XML Web Service </li></ul><ul><li>Test the XML Web Service </li></ul><ul><li>Change the Namespace </li></ul>
  21. 21. Review <ul><li>Overview of Using XML Web Services </li></ul><ul><li>Calling an XML Web Service Using HTTP </li></ul><ul><li>Using a Proxy to Call an XML Web Service </li></ul><ul><li>Creating an XML Web Service </li></ul>
  22. 22. Lab 13: Consuming and Creating XML Web Services Medical Medical.aspx Benefits Home Page Default.aspx Life Insurance Life.aspx Retirement Retirement.aspx Dental Dental.aspx Dentists Doctors Doctors.aspx Doctors Logon Page Login.aspx Registration Register.aspx Coho Winery Prospectus Prospectus.aspx XML Web Service dentalService1.asmx Page Header Header.ascx ASPState tempdb Lab Web Application User Control namedate.ascx Menu Component Class1.vb or Class1.cs XML Files Web. config

×