1 / 14

Lesson 15

Lesson 15. Web Services. What Are Web Services. Web services are programmable and reusable, much like component software, except that they are more easily deployed to the intranet or Internet. Benefits of Web Services.

erna
Download Presentation

Lesson 15

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. Lesson 15 Web Services

  2. What Are Web Services • Web services are programmable and reusable, much like component software, except that they are more easily deployed to the intranet or Internet.

  3. Benefits of Web Services • Allow communication between programs written in different languages and operating on different platforms. • Provide an efficient, flexible way to expose legacy applications and enterprise systems to desktop clients while minimizing point-to-point integration. • Enable companies using the Internet to more easily connect to and use data published by partners or third parties.

  4. Create & Consume • There are two sides to web services • A. Create a webservice for all to use • B. Consume a webserve that others have created

  5. Using Web Matrix To Create Web Services • Create a folder on your hard drive and call it MathService • In Web Matrix, create an XML file and call it MathService.asmx • This file will be used to create your webservice

  6. Copy This Code <%@ WebService Language="VB" Class="MathService" %> Imports System Imports System.Web.Services Public Class MathService : Inherits WebService <WebMethod()> Public Function Add(A As System.Single, B As System.Single) As System.Single Return A + B End Function <WebMethod()> Public Function Subtract(A As System.Single, B As System.Single) As System.Single Return A - B End Function <WebMethod()> Public Function Multiply(A As System.Single, B As System.Single) As System.Single Return A * B End Function <WebMethod()> Public Function Divide(A As System.Single, B As System.Single) As System.Single If B = 0 Return -1 End If Return Convert.ToSingle(A / B) End Function End Class

  7. You Should Have This On Your Screen

  8. Testing MathService Multiply Method • Enter 15 for A • Enter 10 for B • Click Invoke Button

  9. More Testing • Go back and test the Addition Method;Subtraction Method and Division Method • Copy the url that was used to generate this page from the Address of your browser you will need this when you’re creating the XML Web Service Proxy Generator • http://localhost/xml/MathService.asmx

  10. Creating A Proxy for MathService • A Web service requires a proxy between our application and the web service • Web Matrix has a tool called the XML Web Service Proxy Generate which is found under the Tools menu

  11. XML Web Service Proxy Generator • Go to the Tools Menu and select Web Service Proxy Generator • Namespace-MathServiceVB • Output Directory-Change to C:\MathService • Source file – MathService.vb • Generate Assembly-MathService.dll

  12. XML Web Service Proxy Generator Click Generate to continue

  13. Consuming MathService Web Service • Consuming a Web Service and when you want to use a web service in your ASP.NET file • Create a New ASP.NET file and call it MathService • Make sure you create this file in the MathService folder on your c drive

  14. Cut and Paste this code in code view

More Related