Presentation is loading. Please wait.

Presentation is loading. Please wait.

Current Popular IT I Pertemuan 7 Matakuliah: T0403/Current Popular IT I Tahun: 2008.

Similar presentations


Presentation on theme: "Current Popular IT I Pertemuan 7 Matakuliah: T0403/Current Popular IT I Tahun: 2008."— Presentation transcript:

1 Current Popular IT I Pertemuan 7 Matakuliah: T0403/Current Popular IT I Tahun: 2008

2 Learning Outcomes Learner can describe web services Learner can create web services Learner can write optimized web services code Bina Nusantara Copyright © Surya Sujarwo 2008

3 Material Outline XML Web Services How Web Services Work Uses For Web Services Web Services in ASP.NET Writing optimized web services Bina Nusantara Copyright © Surya Sujarwo 2008

4 XML Web Services What Are XML Web Services? – XML Web services are a way for applications to share data and business logic, over the Web, using nonproprietary standard protocols, such as XML and HTTP, which are supported in a wide variety of environments. History – In the past XML Web Service were much less robust, portable, and easy to use. E.g. Says we work in a shipping company name shipCo, Inc. Many of our client needs to calculate of their shipping cost. Before web services, we have options: First Option: Distribute our shipping price data to the client, so that the clients could import the data into their local data stores and access it. The problem: when the prices change. Second Option: Open up our proprietary network and allow clients to access it through a set of APIs or objects. The problems: client have to maintain their connection and configuration and support whatever means of programming is required to use the objects or APIs required for accessing the data, And also regarding different operating systems. Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

5 XML Web Services (Continue…) History (continue…) Third Option: Create a web page that takes parameters and responds with string that contains the shipping price information embedded in it. The Problem: the calling program might have to make complex programming calls to request content from a Web server and there is no good way to get the results back from the call in an object-oriented manner. The result is embedded in string and must be parsed by the client application. XML Web Service: more like the third option, but instead of string, the return can be an object, when combined with the SOAP protocol and be called in an object-oriented way. The calling program doesn’t have to make low-level socket connections and send HTTP GET request and then read of the returned stream. Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

6 XML Web Services (Continue…) When data returned, they are parsed for the data parts to be used in business logic Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

7 XML Web Services (Continue…) Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002) Using the.NET Web services:

8 How Web Services Work Web service can work due to SOAP. SOAP is a nonproprietary way for invoking programming logic across standard Web protocols. It also provides a mechanism for converting XML that is sent over the Web, either to or from a Web service, into objects. SOAP provides a definition for messages to be sent to make calls over the Web. ASP.NET Web services also use SOAP for enveloping the XML into objects for us. When the call to a Web service return an object like the ShipCoInfo class, the actual contents of the object, and not a binary object, are sent over the wire. Because we are calling the Web service over the HTTP protocol, it returns its results as a stream of text, formatted in XML. Then, once the stream of XML has been received by the calling program, it is deserialized into objects by the framework. Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

9 Uses For Web Services The main uses of web services is to provide one logic to all clients like in the following condition: – A large bank corporation has several thousand employees using 20 different enterprise application to do their various jobs. – The application as follow: Windows platform application written in MFC, ATL, VB, and Access. Unix and Solaris application written in Java and C++. Web based: IIS with ASP, Unix with Perl/CGI. – Every single application needs to be able to pull up the contact information of 100,000 customer’s in the company’s master database. Typical company often has many redundant, disparate chunks of code that all access the same data, each in its own way. – Some systems make call through COM or DCOM objects to get the contact info Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

10 Uses For Web Services (Continue…) – Some via Java RMI or CORBA methods – Others might call the database directly from SQL Library in Unux. Obviously this leads to many problems, not the least of which is the amount of code and support needed to accomplish all of this. On top of that is the administration of all of these database connections and credentials, not to mention what happens when the table layout changes slightly. Half of the apps in the organization might be in need of repair and recompile at that point. A Web service that has a simple object-based interface that allows listing, searching, adding, deleting, and updating of the customer contact database could be this fictional company’s savior. Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

11 Uses For Web Services (Continue…) If these programs all accessed the contact information using this Web service, several problems would be solved: – First, a consistent programming model could be used by all applications that need the information, no matter what type of language or OS they were developed on. SOAP is destined to be available to all development environments in the future, and most already have the means to make HTTP calls over the Internet. – Second, the interface to the data can be abstracted to the underlying data structure. What if the customer tables change or even get ported to a completely different brand of database server? Using the Web service as the single point of access to this data, it is the only code that needs to be modified. As long as the objects and Web service interface remain the same, all consuming programs will continue to work without interruption. Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

12 Uses For Web Services (Continue…) Imagine how much money could be saved in just one instance of having to modify the customer database slightly if only one app—the Web services app—has to be changed. Another major benefit is that because Web services are called over the Internet, the only thing the consuming app really needs in production is a valid Internet connection allowing it to be used outside of the corporate network. Besides, Web services can also help in the public domain, where a company may wish to share its data with anonymous users over the Web. E.g. Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

13 Uses For Web Services (Continue…) One more example: – imagine a Web-based communication system where one company maintains a Web chat server with chatting functionality exposed as Web services. – With that system in place, it would be very easy to embed chat capabilities into any consumer- or business-based rich client application. – Taking it even a step further, a PC-based consumer application could implement its user interface in the client machine but get all of its business logic and functionality via Web service calls. – This would keep every user on the same version and eliminate piracy. – It could also usher in the new notion of application rental over the Web. Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

14 Web Services in ASP.NET Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

15 Web Services in ASP.NET (Continue…) Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

16 Web Services in ASP.NET (Continue…) Publish the web services Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

17 Web Services in ASP.NET (Continue…) Add Web Reference from Visual C#, in menu Add Reference, choose Advanced, then choose Add Web Reference Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

18 Web Services in ASP.NET (Continue…) Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

19 Web Services in ASP.NET (Continue…) Use in ASP.NET Website Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

20 Web Services in ASP.NET (Continue…) Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

21 Web Services in ASP.NET (Continue…) Bina Nusantara References: Developing Web Applications with ASP.NET and C# (Hank Meyne and Scott Davis, 2002)

22 Writing optimized web services Important Technology: – Standard Object Access Protocol (SOAP): A communications protocol and an XML-based specification for messages. The protocol of choice for communicating with Web services, although HTTP-POST and HTTP-GET are viable (but limited) alternatives. SOAP messages are usually transmitted over HTTP, although they may also be transmitted over TCP/IP, SMTP, and assorted other protocols. – Web Services Description Language (WSDL): An XML-based vocabulary that describes the set of SOAP messages that a Web service supports. Every Web service has an associated WSDL file that documents the Web methods, including their arguments and return type. VS.NET uses the WSDL file for generating a proxy class that ASP.NET consumer applications can use for communicating with the Web service. VS.NET also provides a default Service Description screen that summarizes the WSDL information in a readable format. You can view the service description when you navigate directly to a Web service and append the ?WSDL query string to the URL entry. – Universal Discovery, Description, and Integration (UDDI): A registered XML file that publishes information about a Web service in a centralized, browsable location. A UDDI directory enables third parties to locate and research your Web service. For more information, visit http://uddi.microsoft.com.http://uddi.microsoft.com Bina Nusantara References: Performance Tuning and Optimizing ASP.NET Applications (Jeffrey Hasan and Kenneth Tu, 2003)

23 Writing optimized web services (Continue…) Bina Nusantara References: Performance Tuning and Optimizing ASP.NET Applications (Jeffrey Hasan and Kenneth Tu, 2003) Simple design optimizations: – Use asynchronous Web method calls where possible – Use timeouts for synchronous calls – Use output caching for responses – Minimize traffic – Minimize use of complex data types – Use SOAP Headers for global information – Use client-side invocation – Code intelligently – Compile intelligently

24 That’s All Thank You for the Attention Bina Nusantara


Download ppt "Current Popular IT I Pertemuan 7 Matakuliah: T0403/Current Popular IT I Tahun: 2008."

Similar presentations


Ads by Google