If you can't read please download the document
Upload
margot
View
25
Download
0
Embed Size (px)
DESCRIPTION
CS603 Communication Mechanisms: SOAP. 25 January 2002. SOAP: Simple Object Access Protocol. Overview Goal: RPC protocol that works over wide area networks Interoperable Language independent Problem: Firewalls Solution: HTTP/XML History Work started in 1998 – produced XML-RPC - PowerPoint PPT Presentation
Citation preview
CS603Communication Mechanisms:SOAP25 January 2002
SOAP:Simple Object Access ProtocolOverviewGoal: RPC protocol that works over wide area networksInteroperableLanguage independentProblem: FirewallsSolution: HTTP/XMLHistoryWork started in 1998 produced XML-RPCVendor-led, big Microsoft influence1999: SOAP 1 type system from XML SchemasMore vendors2001: Picked up by W3C XML Protocol working groupNow called XP (XML Protocol)Microsoft using it for their .NET replacement for DCOM
SOAPAdvantagesGoes anywherehttp is universal protocolOpen standardBased on XML, defined by W3C working groupDisadvantagesType semantics must be definedExtra work for usersPure text protocolHigh cost to translate at endpointsEats bandwidth
SOAPComponentsClient side: Ability to generate http calls and listen for responseSounds like a browser!Server:Listen for HTTPBind to procedureRespond with HTTPFirst and last are Web Server!
SOAP call
IBM
SOAP response
34.5
SOAP Template
User-created definitions, e.g. language of messageCall and arguments, or results for a responseErrors (response only)
Key SOAP AttributesHeaderActor: URI of intended recipientencodingStyle: URI of definition of types usedmustUnderstand: True if receiver MUST process elementFault: VersionMismatch, MustUnderstand, Client, Server: Error as a string: Who caused it: Additional information
Building a client:Apache SOAPOpen source web server driven by IBMSOAP available as integral partJava packages to interface between java programs and SOAPAlso supports javascript SOAP clients/servers
SOAPSample Clientimport java.net.URL; import java.util.Vector; import org.apache.soap.SOAPException; import org.apache.soap.Constants;import org.apache.soap.Fault; import org.apache.soap.rpc.Call; import org.apache.soap.rpc.Parameter; import org.apache.soap.rpc.Response;public class Client {public static void main(String[] args) throws Exception {URL url = new URL("http://localhost:8080/apache-soap/servlet/rpcrouter"); Call call = new Call();call.setTargetObjectURI("urn:Hello");call.setMethodName(HelloWorld");call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); Vector params = new Vector();params.addElement(new Parameter("name", String.class, Argument, null)); call.setParams(params);
SOAPSample ClientResponse resp = null; try { resp = call.invoke(url, ""); }catch( SOAPException e ) {System.err.println("Caught SOAPException (" + e.getFaultCode() + "): " +e.getMessage());System.exit(-1);} // Check the response.if( !resp.generatedFault() ) {Parameter ret = resp.getReturnValue();Object value = ret.getValue(); System.out.println(value);} else {Fault fault = resp.getFault(); System.err.println("Generated fault: ");System.out.println (" Fault Code = " + fault.getFaultCode()); System.out.println (" Fault String = " + fault.getFaultString());}}
SOAPServer codepublic class HelloServer{ public String HelloWorld(String name) {System.out.println(name);return "Hello World!; } }
Activating the serverorg.apache.soap.server.ServiceManagerClient http://localhost:8080/apache-soap/servlet/rpcrouter deploy DeploymentDescriptor.xmlDeploymentDescripter.xml:
Client-generated call
Arguments
Server-generated response
Hello World!
DCE vs. Java RMI vs. SOAPPhilosophyDCE RPC: generic interfaceDefine clean sheet systemPort to variety of protocols/systems/languagesJava RMI: proprietary interfaceCoupled to single language/run time systemPort entire system to multiple platformsSOAP: single standard interfaceDefine interface on single protocolPick protocol that is universal
Which do I use?All-JAVA world? RMINeed security / fault tolerance? RPCNeed to get through firewalls? SOAPPerformance?Objects as arguments?