CS603 Communication Mechanisms: SOAP - PowerPoint PPT Presentation

About This Presentation
Title:

CS603 Communication Mechanisms: SOAP

Description:

Based on XML, defined by W3C working group. Disadvantages. Type ... http://localhost:8080/apache-soap/servlet/rpcrouter deploy DeploymentDescriptor.xml ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 18
Provided by: clif8
Category:

less

Transcript and Presenter's Notes

Title: CS603 Communication Mechanisms: SOAP


1
CS603Communication MechanismsSOAP
  • 25 January 2002

2
SOAPSimple 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
  • Vendor-led, big Microsoft influence
  • 1999 SOAP 1 type system from XML Schemas
  • More vendors
  • 2001 Picked up by W3C XML Protocol working
    group
  • Now called XP (XML Protocol)
  • Microsoft using it for their .NET replacement for
    DCOM

3
SOAP
  • Advantages
  • Goes anywhere
  • http is universal protocol
  • Open standard
  • Based on XML, defined by W3C working group
  • Disadvantages
  • Type semantics must be defined
  • Extra work for users
  • Pure text protocol
  • High cost to translate at endpoints
  • Eats bandwidth

4
SOAPComponents
  • Client side Ability to generate http calls and
    listen for response
  • Sounds like a browser!
  • Server
  • Listen for HTTP
  • Bind to procedure
  • Respond with HTTP
  • First and last are Web Server!

5
SOAP call
  • ltsoapEnvelopegt
  • ltsoapBodygt
  • ltxmlnsm"http//www.stock.org/stock" /gt
  • ltmGetStockPricegt
  • ltmStockNamegtIBMlt/mStockNamegt
  • lt/mGetStockPricegt
  • lt/soapBodygt
  • lt/soapEnvelopegt

6
SOAP response
  • ltsoapEnvelopegt
  • ltsoapBodygt
  • ltxmlnsm"http//www.stock.org/stock" /gt
  • ltmGetStockPriceResponsegt
  • ltmPricegt34.5lt/mPricegt
  • lt/mGetStockPriceResponsegt
  • lt/soapBodygt
  • lt/soapEnvelopegt

7
SOAP Template
  • ltsoapEnvelope
  • xmlnssoap"http//schemas.xmlsoap.org/soap/envel
    ope/"
  • soapencodingStyle"http//schemas.xmlsoap.org/so
    ap/encoding/"gt
  • ltsoapHeadergt
  • User-created definitions, e.g. language of
    message
  • lt/soapHeadergt
  • ltsoapBodygt
  • Call and arguments, or results for a response
  • lt/soapBodygt
  • ltsoapFaultgt
  • Errors (response only)
  • lt/soapFaultgt
  • lt/soapEnvelopegt

8
Key SOAP Attributes
  • Header
  • Actor URI of intended recipient
  • encodingStyle URI of definition of types used
  • mustUnderstand True if receiver MUST process
    element
  • Fault
  • ltfaultcodegt VersionMismatch, MustUnderstand,
    Client, Server
  • ltfaultstringgt Error as a string
  • ltfaultactorgt Who caused it
  • ltdetailgt Additional information

9
Building a clientApache SOAP
  • Open source web server driven by IBM
  • SOAP available as integral part
  • Java packages to interface between java programs
    and SOAP
  • Also supports javascript SOAP clients/servers

10
SOAPSample Client
  • import 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//localhost8080/apache-s
    oap/servlet/rpcrouter")
  • Call call new Call()
  • call.setTargetObjectURI("urnHello")
  • call.setMethodName(HelloWorld")
  • call.setEncodingStyleURI(Constants.NS_URI_SOAP_EN
    C)
  • Vector params new Vector()
  • params.addElement(new Parameter("name",
    String.class, Argument, null))
  • call.setParams(params)

11
SOAPSample Client
  • Response 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())

12
SOAPServer code
  • public class HelloServer
  • public String HelloWorld(String name)
  • System.out.println(name)
  • return "Hello World!

13
Activating the server
  • org.apache.soap.server.ServiceManagerClienthttp/
    /localhost8080/apache-soap/servlet/rpcrouter
    deploy DeploymentDescriptor.xml
  • DeploymentDescripter.xml
  • ltisdservice xmlnsisd"http//xml.apache.org/xml-
    soap/deployment" id"urnHello"gt
  • ltisdprovider type"java" scope"Application
    methodsHelloWorld"gt
  • ltisdjava class"HelloServer" static"false"/gt
  • lt/isdprovidergt
  • lt/isdservicegt

14
Client-generated call
  • ltsoapEnvelope
  • xmlnssoap"http//schemas.xmlsoap.org/soap/enve
    lope/"
  • xmlnsxsi"http//www.w3.org/1999/XMLSchema-inst
    ance"
  • xmlnsxsd"http//www.w3.org/1999/XMLSchema"gt
  • ltsoapHeadergt
  • lt/soapHeadergt
  • ltsoapBodygt
  • ltns1HelloWorld
  • xmlnsns1"Hello"
  • soapencodingStyle "http//schemas.xmlsoap.org
    /soap/encoding/"gt
  • ltname xsitype"xsdstring"gtArgumentslt/namegt
  • lt/ns1HelloWorldgt
  • lt/soapBodygt
  • lt/soapEnvelopegt

15
Server-generated response
  • ltsoapEnvelope
  • xmlnssoap "http//schemas.xmlsoap.org/soap/env
    elope/"
  • xmlnsxsi"http//www.w3.org/1999/XMLSchema-inst
    ance"
  • xmlnsxsd"http//www.w3.org/1999/XMLSchema"gt
  • ltsoapBodygt
  • ltns1HelloWorld
  • xmlnsns1"Hello"
  • soapencodingStyle "http//schemas.xmlsoap.org
    /soap/encoding/"gt
  • ltreturn xsitype"xsdstring"gtHello
    World!lt/returngt
  • lt/ns1HelloWorldgt
  • lt/soapBodygt
  • lt/soapEnvelopegt

16
DCE vs. Java RMI vs. SOAP
  • Philosophy
  • DCE RPC generic interface
  • Define clean sheet system
  • Port to variety of protocols/systems/languages
  • Java RMI proprietary interface
  • Coupled to single language/run time system
  • Port entire system to multiple platforms
  • SOAP single standard interface
  • Define interface on single protocol
  • Pick protocol that is universal

17
Which do I use?
  • All-JAVA world? RMI
  • Need security / fault tolerance? RPC
  • Need to get through firewalls? SOAP
  • Performance?
  • Objects as arguments?
Write a Comment
User Comments (0)
About PowerShow.com