This post will be a quick run down on coding Web Services with Java. This content can be found in David’s Malan’s cs259 class and feel free to watch lecture 11 for a better understand than I can provide.
Architecture of Web Services
- The web services architecture is an evolution of existing technologies
- The Internet enables hosts to communicate and information to be published and retrieved
- Distributed computing platforms allow programmatic components to communicate
- XML closes the barriers between platforms and technologies
What’s Remote Procedure Calls?
- Two pieces of code (client and server) talk over the network, generally using TCP/IP sockets
- The client need not be aware that it is not using a local class
- Client-side stub implements the service interface and takes care of serializing/marshalling the arguments for transmission over the network. The stub makes the network call and hands the response back to the caller
- The remote object (server) need not be aware that it is not called by a local class
- Server-side skeleton handles deserializing/unmarshalling the arguments and calling the local class, sending back the result to the remote client
- SOAP (Simple Object Access Protocol) is used to serialize a remote procedure call (RPC) across the network
- SOAP is a lightweight mechanism for exchanging structured and typed information between peers in a decentralized, distributed environment using XML
- SOAP is an XML-based protocol that consists of three parts
- An envelope that defines a framework for describing what is in a message and how to process it
- A set of encoding rules for expressing instances of application-defined datatypes (i.e., how to serialize data structures)
- A convention for representing remote procedure calls and responses
- Has its roots in distributed computing technologies: DCOM, CORBA, & Java RM
SOAP Encoding Rules
- The SOAP specification describes how to serialize application-specific data-types into and out of an XML representation
- XML Schema primitive types (int, byte, short, boolean, string, float, double, date, time, and URL) are sent as-is
- More complicated objects (e.g., Java classes) must have a matching schema and a mechanism for serializing into/out of schema
What’s a SOAP Router?
- Listens on the appropriate protocol
- Receives SOAP request
- Has a binding between service’s URN and implementing class
- Calls appropriate class to handle request
- Returns response to sender
What’s a WSDL (Web Services Description Language)?
- Describes what a web service can do
- where it resides
- how to invoke it
WSDL is usually used with SOAP as a transport protocol, although it can work with other protocols as well.
Document Style of WSDL
- Web service designers/users often think of the XML representation merely as the “wire format”
- They want RPC-style invocation, with binding to programmatic objects on both sides via serialization
- But sometimes, we want to just use WSDL/SOAP to send an XML document, without the RPC semantics
- To do this, we specify <soap:binding style=”document”>in the WSDL file