0% found this document useful (0 votes)
12 views22 pages

Consuming and Creating XML Web Services

Thank you for the feedback. I will review the module content and lab outline to identify any areas that could be improved or expanded upon based on your comments. The goal is to ensure the material is presented clearly and helps learners effectively gain the skills outlined. Please let me know if any other thoughts come to mind.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views22 pages

Consuming and Creating XML Web Services

Thank you for the feedback. I will review the module content and lab outline to identify any areas that could be improved or expanded upon based on your comments. The goal is to ensure the material is presented clearly and helps learners effectively gain the skills outlined. Please let me know if any other thoughts come to mind.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 22

Consuming and Creating

XML Web Services


Module 13: Consuming and Creating XML Web
Services
• Overview of XML Web Services

• Calling an XML Web Service by Using HTTP

• Calling an XML Web Service by Using a Proxy

• Creating an XML Web Service


Lesson: Overview of 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


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


Why Use XML Web Services?

Northwind Traders Travel Site


Weather
Pick your destination: Redmond XML Web Service

The weather
Forecast calls for:
Rain
Internet Exchange Rate
The exchange rate is: $1.56 XML Web Service

We can fly you there for only:


$1,999.98
Airfare
XML Web Service
Airfare
Database
Finding an XML Web Service

11 Publish XML Web service URL


and description
22 Discover XML Web service UDDI
33 Locate XML Web service URL

44 Read .wsdl description

55 Bind XML Web Service to Proxy 22 11


66 Call XML
Web Service Web 33 .disco
from the Form 44 .wsdl
Web Form
55 66
by Proxy Web Service
Proxy
Multimedia: XML Web Service Execution Model
Lesson: Calling an XML Web Service by Using
HTTP
• Calling an XML Web Service by Using HTTP
Calling an XML Web Service by Using HTTP

1. Navigate to the XML Web service URL

11
2. Select an XML
Web service
method

3. Call the XML Web


service method

22
4. View the XML
response

33

44
Lesson: Calling an XML Web Service by Using a
Proxy
• What Is a Proxy?

• Steps for Calling an XML Web Service

• XML Web Service Error Handling

• Demonstration: Testing the Availability of an XML Web


Service
What Is a Proxy?

• 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

Web
Form Internet XML Web
Service
SOAP
Proxy
Steps for Calling an XML Web Service

1.
11 Create a Web reference for the XML Web Service
2.
22 Create an instance of the XML Web Service
3.
33 Call the Web methods of the XML Web Service
4.
44 Build the ASP.NET Web Application

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
XML Web Service Error Handling

• Service unavailable

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;
}

• SOAP exceptions from XML Web Services

Visual Basic .NET Code Example


Demonstration: Testing the Availability of an XML
Web Service
• Set a timeout error handling Try…Catch statement

• Slow the Web service

• Test the exception


Lesson: Creating an XML Web Service
• Steps to Create an XML Web Service

• XML Web Service Code


Steps to Create an XML Web Service


1
1
Create a new XML Web Service project in
Visual Studio 2008

2
2 Declare the WebMethod functions

3
33 Build the XML Web Service project

4
4
Test with
a browser
XML Web Service Code

• .asmx page

<%@ WebService Language="vb"


Codebehind="Service1.asmx.vb"
Class="XMLWebServiceName.Service1" %>
• .asmx.vb page

Imports System
Imports System.Web.Services

Class Service1
<WebMethod()> Public Function function1() As type
'function_here
End Function
End Class

C# Code Example
Consuming and Creating XML Web Services
• Exercise 1: Create the Dentist XML Web Service and the
GetAllDentists XML Web Service Method
• Exercise 2: Create the GetDentistsByPostalCode XML Web
Service Method
• Exercise 3: Consume the GetAllDentists XML Web Service
Method
• Exercise 4: Consume the GetDentistsByPostalCode XML
Web Service Method

Logon information

Virtual machine 2310C_13


User name Student
Password Pa$$w0rd
Estimated time: xx minutes
Lab Scenario

Logon Page
Login.aspx
Benefits
Coho Home Page Page Header ASPState
Winery Default.aspx Header.ascx
Menu
Registration Component
Register.aspx Class1.vb or Class1.cs Web.
tempdb
config

Life Insurance Retirement Medical Dental


Life.aspx Retirement.aspx Medical.aspx Dental.aspx

Prospectus Doctors User Control XML Web


Lab Web Prospectus.aspx Doctors.aspx namedate.ascx Service
Application dentalService1.asmx

XML
Doctors Dentists
Files
Lab Review
Module Review and Takeaways
Review Questions
• Does an XML Web Service have a user interface?

• How could you quickly test an XML Web service to see


what Web methods and parameters are available?
• How do you access an XML Web service from a Web Form?

• How do you check to see if an XML Web service is


available for use at runtime?
• What is the protocol that is used to communicate between
a proxy and an XML Web service?
• What attribute do you add to methods that you want to be
exposed to the Web from your XML Web service?
Review for Alpha
• Is there any topic or specific content item in the module
that seemed unclear or unnecessary?
• Is there any content item/related subject area that was
not covered and could be included?
• Did you observe any issues with the technical accuracy of
the content?
• Is the content in the module presented in a manner that
encourages learning? Did the flow of topics seem right?
• Does the lab outline indicate the expected scope of tasks
to be covered? Would you like to suggest any tasks that
could be removed or added?

You might also like