Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation.

Similar presentations


Presentation on theme: "1 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation."— Presentation transcript:

1 1 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation

2 2 Developing a SOAP Web Service SOAP allows us to develop platform independent Web services When implementing a Web service, we do not need to directly program in SOAP Growing number of tools for developing SOAP- based Web services (over 40) Only high-level language is required. Major development tools include – Apache’s AXIS (Java based) – IBM’s WebSphere (previously used AXIS as its SOAP engine) – SUN’s Java Web Services Developer Pack (JWSDP) – Microsoft SOAP Toolkit (programming using C# or managed C++) EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation

3 3 Life Cycle of a Web Service EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Web Service XML Registry Client 1. Post WSDL document 2. Retrieve WSDL document 3. Invoke A Web Service development platform should provide tools to help in Developing and hosting the service Generating the WSDL document Developing or interfacing with the XML Registry Developing the client programs A Web Service development platform should provide tools to help in Developing and hosting the service Generating the WSDL document Developing or interfacing with the XML Registry Developing the client programs

4 4 AXIS stands for Apache eXtensible Interaction System Essentially a SOAP engine – A framework for constructing SOAP processors such as clients, servers, gateway, etc. Also includes – A server which plugs into servlet engines such as Tomcat – Extensive support for WSDL AXIS is the 3 rd generation of Apache SOAP, which began at IBM as “SOAP4J” EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Apache’s AXIS

5 5 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Features of AXIS (Comparing with SOAP 2.0) Faster Speed – AXIS uses SAX (Simple API for XML) parsing to achieve significantly greater speed than SOAP 2.0, which is based on DOM (Document Object Model) Flexibility – AXIS provides a deployment descriptor (WSDD) for describing various components like services, Handler objects, serializers/deserializers, and so on. Hence gives the developer the freedom to insert extensions into the engine for custom applications

6 6 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Component-oriented deployment – Axis introduces the concept of chainables and handlers for implementing common patterns of processing for applications. Transport framework – Axis provides a transport framework by providing senders and listeners for SOAP over various protocols such as SMTP, FTP, and so on. WSDL Support – Allow automatically exporting machine-readable descriptions of the deployed services

7 7 Architecture of AXIS EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Call Requestor AXIS CLIENT Transport Listener Transport Sender Dispatcher Web Service AXIS SERVER 1 2 3 4 5 6

8 8 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation 1. Requestor builds a SOAP request using a Call object by specifying the target URI, details of the service and encoding style 2. Transport listener converts the incoming message into a XML Message object and puts it into a MessageContext object. Also set the property of the message 3. Dispatcher forwards the request to the target web service. Different services (Java bean, EJB, COM, etc) may have different dispatcher 4. Target web service executes the method and returns the response to the dispatcher 5. Dispatcher forwards the response to the transport sender 6. Transport sender sends the XML message back over the wire protocol to the requestor. Make use of the property encapsulated by the Transport Listener

9 9 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Communications Between Listener, Dispatcher and Sender Transport Listener Transport Sender Handler Serializer De-serializer Transport Listener Chain Transport Sender Chain Router Canonicalizer Dispatcher

10 10 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation A Handler is responsible for some specific processing associated with an input, output, or fault flow Can be used to encrypt/decrypt message headers and the message body, to process digital signature headers, and so on. A Chain is a sequence of Handlers in order to jointly carry out a function AXIS provides the flexibility to freely insert different Handlers to a Chain to suit different applications

11 11 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation For instance, the transport listener chain contains the following three handlers – De-Serializer: This handler parses the InputStream into XML and uses various decoding schemes to convert XML into a format native to the programming language underlying the Axis processing node – Canonicalizer: This handler is responsible for getting the information on where/how to return the response message. The canonicalizer handler also creates the output message to be forwarded to the dispatcher – Router: This handler determines the service details like the service name and operation from the incoming request message

12 12 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation For the transport sender chain, it contains only one handler – Serializer: This handler is responsible for converting a message into an XML stream by encapsulating the details of the messaging protocol By using the built-in Serializer and De-Serializer, complex data structure, e.g. Java Bean, can be converted in XML stream and surfed thru the Web

13 13 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Four Steps to Start a Service in AXIS Prepare the WSDD file Use the AdminClient class to send the file to the AXIS engine Develop the Service Usually it means to just prepare a general Java class with publicly accessible methods Generate the WSDL file Wrap up the Java class

14 14 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Web Service Deployment Descriptor (WSDD) All services need to go thru a process of deployment before they can provide their service to the clients It is just like to register the service in its database Axis defines an XML-based WSDD for defining Services and Handlers to deploy into the Axis engine

15 15 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation The WSDD at the root level contains the elements to notify the Axis engine that it is to deploy a service/handler It may contain the element to tell the Axis engine that it is to undeploy a particular service or handler The element is used to describe the services to be deployed Can define the details like class name, method name, and scope using the parameter attribute

16 16 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation : : Default namespace. Any keyword that its namespace is not defined should belong to this namespace. Hence indicate that this is a WSDD deployment Define the java namespace of this document

17 17 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation <parameter name="className" value=“Hello.HelloService"/> <parameter name="className" value=“Hello.HelloService"/> The name of service to be deployed Actual class name of the service (assume this wsdd file is located in the same directory as directory Hello and the class HelloService is inside Hello) Any public method in the class may be exposed via SOAP Provider of the service. Indicate it is a Java RPC service. The actual class is org.apache.axis.providers.java.RPCProvider Also it indicates the service is of RPC style

18 18 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation To undeploy a service, a WSDD file with undeployment element should be developed C:\java org.apache.axis.client.AdminClient deploy.wsdd Assume the name of the WSDD file is deploy.wsdd, it can be sent to the AXIS engine by using the AdminClient class

19 19 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation The service is called HelloName. It is provided by the HelloService class, which has one method sayHello(). It can be checked by using this URL: http://localhost:8080/axis/servlet/AxisServlet

20 20 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Axis supports scoping service objects three ways: – Request scope (default): create a new java object each time a SOAP request comes in for service – Session scope: create a new object for a client for all requests he made for the same service – Application scope: create a shared object to service all requests from all clients of the same service <parameter name=“scope" value=“request"/> <parameter name=“scope" value=“request"/> Can be set to session or application

21 21 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Create a Simple Service A service can be any java class with a publicly accessible method public class HelloService { public String sayHello (String firstName) { String result = "Hello, "+firstName+"!"; return result; } public class HelloService { public String sayHello (String firstName) { String result = "Hello, "+firstName+"!"; return result; } Class name: MessageRequire 1 string as input Method name Will return a string when it is called

22 22 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Develop the Client Assume the service has been deployed and the client has obtained the WSDL of the service A client program can be developed by simply using a few APIs provided by AXIS import org.apache.axis.client.Call; import org.apache.axis.client.Service; import javax.xml.namespace.QName; public class HelloClient { public static void main(String args[]) { : } import org.apache.axis.client.Call; import org.apache.axis.client.Service; import javax.xml.namespace.QName; public class HelloClient { public static void main(String args[]) { : }

23 23 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation try { String endpoint = “http://localhost:8080/axis/services/HelloName”; Service service = new Service(); String name1 = “Dr Lun"; Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName( “enpklun:polyu.edu.hk:soap”, “sayHello”)); String ret = (String)call.invoke(new Object[]{name1}); System.out.println(ret); } catch (Exception e) { e.printStackTrace(); } try { String endpoint = “http://localhost:8080/axis/services/HelloName”; Service service = new Service(); String name1 = “Dr Lun"; Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName( “enpklun:polyu.edu.hk:soap”, “sayHello”)); String ret = (String)call.invoke(new Object[]{name1}); System.out.println(ret); } catch (Exception e) { e.printStackTrace(); } Location of the Server The service name as indicated in WSDD Set method name and its namespace (find a name that is unique) Require an Object array. Now only one element

24 24 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation A String is returned from the service

25 25 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation The actual request messages generated are as follows (will be attached to a HTTP header): POST /axis/services/HelloName HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept: application/soap+xml, application/dime, multipart/related, text/* User-Agent: Axis/1.1 Host: localhost Cache-Control: no-cache Pragma: no-cache SOAPAction: "" Content-Length: 460 : POST /axis/services/HelloName HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept: application/soap+xml, application/dime, multipart/related, text/* User-Agent: Axis/1.1 Host: localhost Cache-Control: no-cache Pragma: no-cache SOAPAction: "" Content-Length: 460 : HTTP Header A special header that indicates the contents followed were SOAP messages A URI may introduce as the value to indicate the URI that should be aware with that information

26 26 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation <soapenv:Envelope xmlns:soapenv= “http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi= “http://www.w3.org/2001/XMLSchema-instance”> <ns1:sayHello soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="enpklun:polyu.edu.hk:soap "> Dr Lun <soapenv:Envelope xmlns:soapenv= “http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi= “http://www.w3.org/2001/XMLSchema-instance”> <ns1:sayHello soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="enpklun:polyu.edu.hk:soap "> Dr Lun Namespace defined by us Parameter passed

27 27 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Using Compound Data Structure The above simple service can only let us send simple data types between client and server For compound data types, such as structs, we may want to use JavaBeans A JavaBean is basically any java class that follows certain naming convention This convention requires that all accessible properties be made available via get/set methods With such convention, a JavaBean becomes a reusable software component that can be visually manipulated within any IDE, e.g. Visual Basic

28 28 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Since JavaBean is just a Java Class, it can be used to store any kind of variables Become popularly used in Web Services JavaBean package HelloBean; public class Record { private String Name; private int Age; public String getName() { return Name; } public void setName(String name) { Name = name; } public int getAge() { return Age;} public void setAge(int age) { Age = age;} } package HelloBean; public class Record { private String Name; private int Age; public String getName() { return Name; } public void setName(String name) { Name = name; } public int getAge() { return Age;} public void setAge(int age) { Age = age;} } A simple JavaBean: 1.no constructor 2.use get/set for its properties

29 29 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Serialization and De-Serialization For any Java class, it needs to go thru the process of serialization to convert it into XML message stream before sending to the wire To convert a XML message stream back to Java class, a de-serializer is required Serializer De-Serializer Processing Java class XML stream

30 30 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation BeanSerializerFactory and BeanDeserializerFactory JavaBean is so popular for Web Services because AXIS has built-in support to convert JavaBean class to XML stream using BeanSerializerFactory and BeanDeserializerFactory classes On server side, we can use these factories by registering the JavaBean class that requires these factories in the WSDD file On client side, we can use these factories by registering the JavaBean class that requires these factories using Call.registerTypeMapping() API

31 31 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation typeMapping and beanMapping For general Java class, we need to develop the serializer and deserializer ourselves and register them by adding the typeMapping tag in WSDD <typeMapping qname=“ns:local” xmlns:ns=“someNamesapce” languageSpecificType=“java:my.java.class” serializer=“my.java.Serialiser” deserializer=“my.java.Deserializer” encodingStyle= “http://schemas.xmlsoap.org/soap/encoding/” /> <typeMapping qname=“ns:local” xmlns:ns=“someNamesapce” languageSpecificType=“java:my.java.class” serializer=“my.java.Serialiser” deserializer=“my.java.Deserializer” encodingStyle= “http://schemas.xmlsoap.org/soap/encoding/” /> serializer and deserializer we develop Follow SOAP 1.1 encoding style Map the specific Java class into the XML qname [someNamespace]:[local]

32 32 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation For JavaBean, we can use the built-in serializer Type mapping can be done by using the beanMapping tag – a shorthand of typeMapping <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers /java"> <parameter name="className" value="HelloBean.RecordService"/> <parameter name="allowedMethods“ value="showRecord"/> <beanMapping qname="myNS:Record“ xmlns:myNS="enpklun:polyu.edu.hk:soap" languageSpecificType="java:HelloBean.Record"/> <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers /java"> <parameter name="className" value="HelloBean.RecordService"/> <parameter name="allowedMethods“ value="showRecord"/> <beanMapping qname="myNS:Record“ xmlns:myNS="enpklun:polyu.edu.hk:soap" languageSpecificType="java:HelloBean.Record"/> The WSDD file for using JavaBean Record

33 33 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation serializer= “org.apache.axis.encoding.ser.BeanSerializerFactory”, deserializer= “org.apache.axis.encoding.ser.BeanDeserializerFactory” encodingStyle= “http://schemas.xmlsoap.org/soap/encoding/” serializer= “org.apache.axis.encoding.ser.BeanSerializerFactory”, deserializer= “org.apache.axis.encoding.ser.BeanDeserializerFactory” encodingStyle= “http://schemas.xmlsoap.org/soap/encoding/” The tag is just the shorthand for a tag with

34 34 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation A Simple Service that Uses JavaBean package HelloBean; public class RecordService { public Record showRecord(Record rec) { Record resp = new Record(); resp.setName(rec.getName()); resp.setAge(rec.getAge()+1); return resp; } package HelloBean; public class RecordService { public Record showRecord(Record rec) { Record resp = new Record(); resp.setName(rec.getName()); resp.setAge(rec.getAge()+1); return resp; } showRecord() will receive a Record JavaBean and return a Record JavaBean The RecordService class contains only one method showRecord() Will return the name and Age (but add 1) as recorded in the JavaBeam sent from the client

35 35 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation The Client Program The Client program also needs to make use of the built-in serializer and deserializer for JavaBean Client XML stream Server – AXIS engine Record Transport Listener Transport Sender Serializer De-serializerRouter Canonicalizer Dispatcher Call De-serializer Serializer RecordService

36 36 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation package HelloBean; import org.apache.axis.AxisFault; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.ser.BeanSerializerFactory; import org.apache.axis.encoding.ser.BeanDeserializerFactory; import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; package HelloBean; import org.apache.axis.AxisFault; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.ser.BeanSerializerFactory; import org.apache.axis.encoding.ser.BeanDeserializerFactory; import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; The built-in serializer and deserializer for JavaBean

37 37 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation public class RecordClient { public static void main(String [] args) throws Exception { // A. Prepare for the JaveBean // B. Prepare for the call try { // C. Make the call & get the result // D. Use the result } catch (AxisFault fault) { // E. Deal with the error, if any } public class RecordClient { public static void main(String [] args) throws Exception { // A. Prepare for the JaveBean // B. Prepare for the call try { // C. Make the call & get the result // D. Use the result } catch (AxisFault fault) { // E. Deal with the error, if any } The basic steps of a sample Client progam

38 38 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation A. Prepare for the JavaBean Record rec = new Record(); // Create a Record JavaBean rec.setName("Chan Tai-Man"); // Set the name of Record rec.setAge(30); // Set the Age of Record QName qn = new QName( "enpklun:polyu.edu.hk:soap", "Record"); // Give XML qualified name to “Record” // such that it can be used in the XML // messages Record rec = new Record(); // Create a Record JavaBean rec.setName("Chan Tai-Man"); // Set the name of Record rec.setAge(30); // Set the Age of Record QName qn = new QName( "enpklun:polyu.edu.hk:soap", "Record"); // Give XML qualified name to “Record” // such that it can be used in the XML // messages

39 39 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation B. Prepare for the Call String endpoint = "http://localhost:8080/axis/services/NameAndAge"; Service service = new Service(); Call call = (Call) service.createCall(); String endpoint = "http://localhost:8080/axis/services/NameAndAge"; Service service = new Service(); Call call = (Call) service.createCall(); org.apache.axis.client.Call class provides the tools for remote procedure call in AXIS environment Can use the createCall() method of org.apache.axis.client.Service class to create a call Before an actual call is made, should fill in the properties of the call Can be prefilled using a WSDL document (on the constructor to the service object) or manually in your client program The URL where the service is foundService name defined in WSDD

40 40 C. Make the Call and Get the Result EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName( new QName("enpklun:polyu.edu.hk:soap", "showRecord")); call.addParameter( "Input-parameter", qn, ParameterMode.IN); call.setReturnType(qn); call.registerTypeMapping(Record.class, qn, new BeanSerializerFactory(Record.class, qn), new BeanDeserializerFactory(Record.class, qn)); Record result = (Record) call.invoke( new Object[]{ rec } ); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName( new QName("enpklun:polyu.edu.hk:soap", "showRecord")); call.addParameter( "Input-parameter", qn, ParameterMode.IN); call.setReturnType(qn); call.registerTypeMapping(Record.class, qn, new BeanSerializerFactory(Record.class, qn), new BeanDeserializerFactory(Record.class, qn)); Record result = (Record) call.invoke( new Object[]{ rec } ); Input the properties Make the call & get the result

41 41 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName( new QName("enpklun:polyu.edu.hk:soap", "showRecord")); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName( new QName("enpklun:polyu.edu.hk:soap", "showRecord")); “Call” needs to know the URL of the server and the method name to be called The endpoint http://localhost:8080/axis/services/NameAndAge defined above Give the target method a qName

42 42 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation call.addParameter( "Input-parameter", qn, ParameterMode.IN); call.setReturnType(qn); call.addParameter( "Input-parameter", qn, ParameterMode.IN); call.setReturnType(qn); “Call” needs to know the kind of parameters to be sent and recevied For general data type, can be automatically detected by Java reflection For customized data type, such as JavaBean, need to declare beforehand Make “Input-parameter” as the first (and the only in this case) parameter of the call The type of both the input and return is qn (qName of Record) IN: make a copy of the parameter and send to service OUT: the parameter will be used by service to send back the result Can be OUT or INOUT

43 43 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation call.registerTypeMapping(Record.class, qn, new BeanSerializerFactory(Record.class, qn), new BeanDeserializerFactory(Record.class, qn)); call.registerTypeMapping(Record.class, qn, new BeanSerializerFactory(Record.class, qn), new BeanDeserializerFactory(Record.class, qn)); “Call” also needs to know how to serialize or deserialize a JavaBean registerTypeMapping() registers the Java class to be used, its type and the associated serialization factories The qName of the Record class defined before where to find the Record class (in this case, HelloBean.Record) create the built-in serializer and deserializer with the target JavaBean class as input

44 44 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Record result = (Record) call.invoke( new Object[]{ rec } ); Record result = (Record) call.invoke( new Object[]{ rec } ); Finally use invoke() to call the remote service Need to pass an array of Object as the input parameter – now there is only one Object “rec” in the array By default, invoke() returns an Object. Need to cast it to the javaBean class, i.e. Record

45 45 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Result of calling the remote service

46 46 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation Request SOAP Messages Generated POST /axis/services/NameAndAge HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept: application/soap+xml, application/dime, multipart/related, text/* User-Agent: Axis/1.1 Host: localhost Cache-Control: no-cache Pragma: no-cache SOAPAction: "" Content-Length: 768 : POST /axis/services/NameAndAge HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept: application/soap+xml, application/dime, multipart/related, text/* User-Agent: Axis/1.1 Host: localhost Cache-Control: no-cache Pragma: no-cache SOAPAction: "" Content-Length: 768 : HTTP Header SOAP message follows

47 47 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation <soapenv:Envelope xmlns:soapenv= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ns1:showRecord soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="enpklun:polyu.edu.hk:soap"> : <soapenv:Envelope xmlns:soapenv= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ns1:showRecord soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="enpklun:polyu.edu.hk:soap"> : Define the method to be called Define the input parameter. Point to the part of document with ID=id0

48 48 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Record" xmlns:soapenc= "http://schemas.xmlsoap.org/soap/encoding/“ xmlns:ns2="enpklun:polyu.edu.hk:soap"> 30 Chan Tai-Man <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Record" xmlns:soapenc= "http://schemas.xmlsoap.org/soap/encoding/“ xmlns:ns2="enpklun:polyu.edu.hk:soap"> 30 Chan Tai-Man The serializer serializes the private variables in the JavaBean class Record into two XML elements included inside the multiRef tag The qName of Record we have defined Since parameterMode is IN, a copy of the variables is sent

49 49 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation HTTP/1.1 200 OK Content-Type: text/xml;charset=utf-8 Date: Sat, 20 Mar 2004 11:12:33 GMT Server: Apache-Coyote/1.1 Connection: close <soapenv:Envelope xmlns:soapenv= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> : HTTP/1.1 200 OK Content-Type: text/xml;charset=utf-8 Date: Sat, 20 Mar 2004 11:12:33 GMT Server: Apache-Coyote/1.1 Connection: close <soapenv:Envelope xmlns:soapenv= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> : Response SOAP Messages HTTP Header Response SOAP messages follows

50 50 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation <ns1:showRecordResponse soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="enpklun:polyu.edu.hk:soap"> <multiRef id="id0" soapenc:root="0“ soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Record“ xmlns:soapenc= "http://schemas.xmlsoap.org/soap/encoding/“ xmlns:ns2="enpklun:polyu.edu.hk:soap"> 31 Chan Tai-Man <ns1:showRecordResponse soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="enpklun:polyu.edu.hk:soap"> <multiRef id="id0" soapenc:root="0“ soapenv:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Record“ xmlns:soapenc= "http://schemas.xmlsoap.org/soap/encoding/“ xmlns:ns2="enpklun:polyu.edu.hk:soap"> 31 Chan Tai-Man Again, the serializer of the service serializes the JavaBean Record into two XML elements


Download ppt "1 EIE424 Distributed Systems and Networking Programming –Part II 3.2 SOAP – Implementation."

Similar presentations


Ads by Google