Presentation is loading. Please wait.

Presentation is loading. Please wait.

SOAP Simple Object Access Protocol An Introduction by Juan J Vargas University of Central Florida CDA 5937Fall 2002.

Similar presentations


Presentation on theme: "SOAP Simple Object Access Protocol An Introduction by Juan J Vargas University of Central Florida CDA 5937Fall 2002."— Presentation transcript:

1 SOAP Simple Object Access Protocol An Introduction by Juan J Vargas University of Central Florida CDA 5937Fall 2002

2 October 2002UCF - CDA 59372 Agenda  What is SOAP?  SOAP History  The SOAP Structure  The SOAP Message Exchange Model  Examples of HTTP / XML / SOAP  SOAP Security  Conclusions and References

3 October 2002UCF - CDA 59373 What is SOAP?  SOAP: “Simple Object Access Protocol” is a lightweight communication protocol for exchange of information in a decentralized, distributed environment.  SOAP combines HTTP (medium of communication) with XML (language of communication) SOAP = XML parser + server/client code + HTTP server  SOAP invokes methods on servers, services, components, and objects via Internet.

4 October 2002UCF - CDA 59374 What is SOAP? (cont.)  SOAP has no explicit programming model, unlike DCOM and CORBA: no special components or tools needed to make an implementation.  Can be implemented in any language (Java, Perl, C++, VB, Windows and UNIX)  SOAP promotes distributed computing thru communication

5 October 2002UCF - CDA 59375 SOAP goals  Developed to be a platform and language independent  Simplicity and extensibility SOAP meets these goals by omitting features often found in messaging systems and distributed object systems: –garbage collection, batching of messages, objects-by-reference

6 October 2002UCF - CDA 59376 SOAP goals (cont)  Simple standardized mechanism for moving structured information  Format for sending messages  Enables different programs, written in different languages and running on different platforms, to communicate with each other

7 October 2002UCF - CDA 59377 SOAP History  SOAP 0: Developed by UserLand, Microsoft, and DevelopMentor in 1998  SOAP 1.0 in 2000  W3C (World Wide Web Consortium) v1.1 final – May 2000  W3C v1.2 draft – July 2001 Specification can be found at: http://www.w3.org/TR/soap12/

8 October 2002UCF - CDA 59378 The SOAP Message Exchange Model (Client/Server)  SOAP defines two types of messages: Requests Responses  Clients send a request to a server to invoke a service, and the server sends back the results

9 October 2002UCF - CDA 59379 The SOAP 1.1 Structure A SOAP message contains 3 parts: 1. Envelope: defines the content of the message – Must be associated with a namespace, e.g.: http://www.w3.org/2001/06/soap-envelope http://www.w3.org/2001/06/soap-envelope 2. Header (optional): contains header information 3. Body: contains call and response information

10 October 2002UCF - CDA 593710 SOAP Header  Is an optional component  The Header has information about how the message is to be processed  Can contain extensions to the message like transaction ids  Can also contain security information

11 October 2002UCF - CDA 593711 Sample … <t:Transaction xmlns:t=“some-URI” soap: mustUnderstand=“1”> 12345 …

12 October 2002UCF - CDA 593712 SOAP Body  Contains the message referred to as “payload”  Must be a child of the Envelope element  Can contain the encodingStyle  Can also contain a element

13 October 2002UCF - CDA 593713 Sample … SOAP v1.1 http://www.w3.org/TR/SOAP

14 October 2002UCF - CDA 593714 Sample … … soap:Server Server Error Ooops… 1001

15 October 2002UCF - CDA 593715 POST /Temperature HTTP/1.1 Host: www.weather.com Content-Type: text/xml Content-Length: SOAPMethodName: #CurrentTemp 37919 URI- Uniform Resource Identifier some-URI -> www.netsolve.com or www.globus.com SOAP request Http Header Xml Payload Soap Extensions

16 October 2002UCF - CDA 593716 HTTP/1.1 200 OK Content-Type: text/xml Content-Length: 5 42 SOAP response Http Header Xml Payload

17 October 2002UCF - CDA 593717 The SOAP 1.2 Structure A SOAP message contains 4 parts: 1. Envelope: defines a framework describing what is in the message 2. Set of encoding rules: expresses instances of application-defined data types 3. Convention for representing remote procedure calls (RPCs) and responses 4. A transport binding convention for exchanging messages

18 October 2002UCF - CDA 593718 HTTP Example  The following is a legal HTTP request message:  HTTP headers are just plain text. POST /foobar HTTP/1.1 Host: 209.110.197.12 Content-Type: text/plain Content-Length: 12 Hello, World

19 October 2002UCF - CDA 593719 HTTP Example First line of an HTTP request contains three components:  The HTTP method: POST The Internet Engineering Task Force (IETF) has standardized a fixed number of HTTP methods: GET is the HTTP method used to surf the Web. POST is the most commonly used HTTP method for building applications.  The Request-URI: /foobar URI (Uniform Resource Identifier) to identify target of request  The protocol version: HTTP/1.1 The protocol version in this example is HTTP/1.1, which indicates that the rules of RFC 2616 are to be observed.

20 October 2002UCF - CDA 593720 HTTP Example The third and fourth lines of the request specify the type and size of the request payload:  Content-Type: text/plain syntax of the payload information as a MIME type Most DCE (Distributed Computing Environment) applications use NDR (Network Data Representation). Most Web applications use text/html or other text-based syntaxes. SOAP uses text/xml  Content-Length: 12 number of bytes of payload information

21 October 2002UCF - CDA 593721 HTTP Example The blank line between the Content-Length header and the request payload is a delimiter. Individual HTTP headers are delimited by a carriage-return / line-feed sequence. The headers are delimited from the payload using an extra carriage-return / line-feed sequence.

22 October 2002UCF - CDA 593722 HTTP Example The following is an HTTP response message:  If server unable to decode the request 200 OK Content-Type: text/plain Content-Length: 12 dlroW,olleH 400 Bad Request Content-Length: 0 307 Temporarily Moved Location: http://209.110.197.44/foobar Content-Length: 0

23 October 2002UCF - CDA 593723 XML NameSpaces To support extensibility, every element and attribute in XML has a namespace URI associated with it. This URI is specified using the xmlns attribute.

24 October 2002UCF - CDA 593724 XML NameSpaces: Example <reverse_string xmlns="urn:schemas-develop-com:StringProcs"> Hello, World This is a comment!! URIs

25 October 2002UCF - CDA 593725 XML NameSpaces: Example XML allows namespace URIs to be mapped to locally unique prefixes as a convenience. <sp:reverse_string xmlns:sp="urn:schemas-develop-com:StringProcs" xmlns:doc='http://foo.com/documentation'> Hello, World This is a comment!!

26 October 2002UCF - CDA 593726 Sample SOAP Namespaces  SOAP envelope: http://www.w3.org/2001/06/soap-envelope  SOAP serialization: http://www.w3.org/2001/06/soap-encoding  SOAP mustUnderstand fault: http://www.w3.org/2001/06/soap-faults http://www.w3.org/2001/06/soap-faults  SOAP upgrade: http://www.w3.org/2001/06/soap-upgrade

27 October 2002UCF - CDA 593727 Example: SOAP Method Request POST /string_server/Object17 HTTP/1.1 Host: 209.110.197.2 Content-Type: text/xml Content-Length: 152 SOAPMethodName: urn:strings-com:IString#reverse Hello, World URI – delim – method name Method must match

28 October 2002UCF - CDA 593728 Example: SOAP Response 200 OK Content-Type: text/xml Content-Length: 162 dlroW,olleH Method name + “Response” suffix

29 October 2002UCF - CDA 593729 SOAP Request Structure

30 October 2002UCF - CDA 593730 Another SOAP Example Let’s build a service that calculates the tax due on a sales transaction. In traditional VB (Visual Basic) terms we will create a function with the following definition: Public Function GetSalesTax(ByVal pSalesTotal As Double) As Double GetSalesTax = pSalesTotal * 0.04 End Function

31 October 2002UCF - CDA 593731 SOAP Example (cont) Dim objTax As New CTaxCalc dblSalesTax = objTax.GetSalesTax(100) If the amount is $100 and GetSalesTax is within the objTax object the VB call looks like:

32 October 2002UCF - CDA 593732 SOAP Example (cont) CLIENT side The request is formatted as an XML document, which is passed up to the server. 100

33 October 2002UCF - CDA 593733 How to send the XML document to the server? The request is a simple HTTP post. The internet browser masks all the complexity of sending a form to a server. But if we are going to do the job ourselves, Microsoft's XML HTTP Request object can be used to give us a helping hand. The LHTTPRequest is an object within the MSXML class library (MSXML.DLL), and it comes with IE5.

34 October 2002UCF - CDA 593734 SOAP Client (cont) Assuming that strEnvelope contains the XML document described above, the request is formatted thus: Dim objHTTP As New MSXML.XMLHTTPRequest Dim strEnvelope As String 'Set up to post to our localhost server objHTTP.open "post", "http://localhost/soap/soap.asp" 'Set a standard SOAP/ XML header for the content-type objHTTP.setRequestHeader "Content-Type", "text/xml" 'Set a header for the method to be called objHTTP.setRequestHeader "SOAPMethodName", _ "urn:myserver/soap:TaxCalc#GetSalesTax" 'Make the SOAP call objHTTP.send strEnvelope 'Get the return value strReturn = objHTTP.responseBody In this example, the server is in the local computer

35 October 2002UCF - CDA 593735 SOAP Server Side The first job is to create the soap.asp page, to listen for, and process SOAP calls to our server. For the basic listener service, we need to parse the body of the request (the SOAP envelope) and pull out the value of the SalesTotal parameter. Because the request is XML, we can load it into an instance of Microsoft's XMLDOM.

36 October 2002UCF - CDA 593736 SOAP Server Side (cont) Set objReq = Server.CreateObject("Microsoft.XMLDOM") objReq.Load Request Soap.asp begins like this: objReq contains the SOAP envelope from the client.

37 October 2002UCF - CDA 593737 SOAP Server Side (cont) strQuery = "SOAP:Envelope/SOAP:Body/m:GetSalesTax/SalesTotal“ varSalesTotal = objReq.SelectSingleNode(strQuery).Text varSalesTax = varSalesTotal * 0.04 The value of SalesTotal can be extracted by running an XSL pattern query, using the SelectSingleNode method of the XML DOM object, and tax is calculated:

38 October 2002UCF - CDA 593738 SOAP Server Side (cont) 4 The response is ready to be passed back to the client. The SOAP response envelope conforms to a format-type almost identical to the request.

39 October 2002UCF - CDA 593739 SOAP Client Side (cont) The response document can be built either by string- concatenation, or by creating a new instance of a DOM (Document Object Model), and appending the appropriate nodes. Back on the client, the response is received, and can be decoded by extracting the appropriate node from the Envelope document: Dim objReturn As New MSXML.DomDocument objReturn.LoadXML strReturn strQuery = _ "SOAP:Envelope/SOAP:Body/m:GetSalesTaxResponse/SalesTax" dblTax = objReturn.SelectSingleNode(strQuery).Text

40 October 2002UCF - CDA 593740 Problems with example OK, I got it working by Ned Robinson(nrobinson@baseline.com)Tuesday, August 28, 2001 Here is the trick. You must have Application Protection on your web server set to Low so that the service and the application can run in the same address space. Go to IIS Manager, right click on your Web Site and go to Properties. Go to the Home Directory tab and make the change to Application Protection at the bottom.

41 October 2002UCF - CDA 593741 SOAP Security  SOAP specification does not define any protocol- specific security features. Potential security threat due to plain text nature of data.  Security features may be added to the SOAP header (e.g. digital signatures).  Transport protocols such as SSL (using HTTPS), TLS, and IP SECurity (IPSec) can provide the integrity and confidentiality of the message during transmission.

42 October 2002UCF - CDA 593742 Conclusions  SOAP: new and simple protocol. SOAP well suited for internet. Excellent foundation upon which other protocols may be built  Primary goal of SOAP is interoperability  SOAP = XML (data representation) + HTTP (transport) + RPC (call/response mechanism)  Today SOAP does not address some critical distributed services (e.g. security). But SOAP is evolving rapidly.

43 October 2002UCF - CDA 593743 References http://www.vbip.com/xml/soap_syd.asp http://msdn.microsoft.com/msdnmag/issues/0300/soap/default. aspx http://www.w3.org/TR/SOAP/ http://www.xml.org/xml/resources_focus_soap.shtml http://www.javaworld.com/javaworld/jw-03-2001/jw-0330- soap.html http://msdn.microsoft.com/library/default.asp?url=/library/en- us/dnexxml/html/xml10152001.asp http://msdn.microsoft.com/library/default.asp?url=/library/en- us/dnwebsrv/html/Xmloverchap2.asp http://www.microsoft.com/mind/0100/soap/soap.asp


Download ppt "SOAP Simple Object Access Protocol An Introduction by Juan J Vargas University of Central Florida CDA 5937Fall 2002."

Similar presentations


Ads by Google