Compare and contrast web applications with web services
WSDL
WSDL is an XML vocabulary for describing Web services allowing developers to describe Web
Services and their capabilities, in a standard manner.
•standard format to describe a Web Service (description stack)
•specifies three fundamental properties:
•What a service does - operations (methods) provided by the service
• How a service is accessed - data format and protocol details
•Where a service is located - Address (URL) details
•The document written in WSDL is also simple called a WSDL (or WSDL document)
•WSDL is a contract between the XML(SOAP) Web service and the client who wishes to use
this service
•The service provides the WSDL document and the Web service client uses the WSDL
document to create the stub (or to dynamically decode messages)
Fundamental properties of a WSDL document and the use of WSDL document in web services and client development
Three fundamental properties:
•What a service does - operations (methods) provided by the service
• How a service is accessed - data format and protocol details
•Where a service is located - Address (URL) details
WSDL is often used in combination with SOAP and an XML Schema to provide Web services over the Internet. A clientprogram connecting to a Web service can read the WSDL fileto determine what operations are available on the server. Any special datatypes used are embedded in the WSDL file in the form of XML Schema.
Structure of the WSDL document, explaining the elements in WSDL
name
is optional.targetNamespace
is the logical namespace for information about this service. WSDL documents can import other WSDL documents, and setting targetNamespace to a unique value ensures that the namespaces do not clash.xmlns
is the default namespace of the WSDL document, and it is set tohttp://schemas.xmlsoap.org/wsdl/
.- All the WSDL elements, such as
<definitions>
,<types>
and<message>
reside in this namespace. xmlns:xsd
andxmlns:soap
are standard namespace definitions that are used for specifying SOAP-specific information as well as data types.xmlns:tns
stands for this namespace.xmlns:ns1
is set to the value of theschema targetNamespace
, in the<types>
section.
http://tempuri.org
in namespaces to ensure that the namespaces are unique.Compare the PortType and operation elements in WSDL with the java equivalences
PortType element may have one or more operation elements, each of which defines an RPC- or documentstyle Web service method
• Java equivalence:
• portType -> java interface
• operation -> method name
Compare and contrast the binding and service elements in WSDL
Binding
•map a PortType to a specific protocol, typically SOAP over http, using a specific data
encoding style
•one portType can be bound to several different protocols by using more than one
port
•bindings refer back to portTypes by name, just as operations point to messages.
•binding styles may be either “RPC” or “Document”(SOAP).
•also specify SOAP encoding
<binding name="net.xmethods.services.stockquote.StockQuoteBinding"
type="tns:net.xmethods.services.stockquote.StockQuotePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getQuote">
<soap:operation soapAction="urn:xmethods-delayed-quotes#getQuote" />
<input>
<soap:body use="encoded"
namespace="urn:xmethods-delayed-quotes"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded"
namespace="urn:xmethods-delayed-quotes"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
Service
• it binds the Web service to a specific network-addressable location, i.e. it takes the bindings declared previously and ties them to a port, which is a physical network endpoint to which clients bind over the specified protocol,
• contain one or more port elements, each of which represents a different Web service and the port element assigns the URL to a specific binding,
• reference a particular binding, and along with addressing information is wrapped together into a service element to form the final physical, network addressable Web service,
• access point for each port
• port type - The operations performed by the web service.
• message - The messages used by the web service.
• types - The data types used by the web service.
• binding - The communication protocols used by the web service.
<service
name="net.xmethods.services.stockquote.StockQuoteService">
<documentation>net.xmethods.services.stockquote.StockQuote web service
</documentation>
<port
name="net.xmethods.services.stockquote.StockQuotePort"
binding="tns:net.xmethods.services.stockquote.StockQuoteBinding">
<soap:address
location="http://64.39.29.211:9090/soap" />
</port>
</service>
Explain how SOAP is used with HTTP
OAP ( Simple Object Access Protocol) is a message protocol that allows distributed elements of an application to communicate. SOAP can be carried over a variety of lower-level protocols, including the web-related Hypertext Transfer Protocol (HTTP). SOAP defines a header structure that identifies the actions that various SOAP nodes are expected to take on the message, in addition to a payload structure for carrying information. The concept of routing a message through a string of nodes that perform different functions is how SOAP supports things like addressing, security and format-independence. Essentially, the headers identify roles, which in turn provide the SOA features which SOAP then routes to. Stringing messages through a sequence of steps is uncommon in today’s microservice-centric development environments.
Structure of SOAP message in message oriented communication
• Envelope
• wraps entire message and contains header and body
• defines an overall framework for expressing what is in a message; who should deal with it, and whether it is optional or mandatory
• Header
• optional element with additional info such as security or routing
• Body
• application-specific message content being communicated as arbitrary XML payloads in the request and response messages
• fault element provides information about errors that occurred while processing the message
Importance of the SOAP attachments, explaining the MIME header
•SOAP messages may have one or more attachments
• each AttachmentPart object has a MIME header to indicate the type of data it contains.
• it may also have additional MIME headers to identify it or to give its location, which can be useful when there are multiple attachments
•when a SOAP message has one or more AttachmentPart objects, its SOAPPart object may or may not contain message content
Annotations in JAX-WS
Annotation class | Annotation | Properties |
---|---|---|
javax.jws. WebService | The @WebService annotation marks a Java class as implementing a Web service or marks a service endpoint interface (SEI) as implementing a web service interface.
Important
|
|
javax.jws. WebMethod | The @WebMethod annotation denotes a method that is a web service operation.
Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class.
|
|
javax.jws. Oneway | The @Oneway annotation denotes a method as a web service one-way operation that only has an input message and no output message.
Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class.
|
|
javax.jws. WebParam | The @WebParam annotation customizes the mapping of an individual parameter to a web service message part and XML element.
Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class.
|
|
javax.jws. WebResult | The @WebResult annotation customizes the mapping of a return value to a WSDL part or XML element.
Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class.
|
|
javax.jws. HandlerChain | The @HandlerChain annotation associates the web service with an externally defined handler chain.
You can only configure the server side handler by using the @HandlerChain annotation on the Service Endpoint Interface (SEI) or the server endpoint implementation class.
Use one of several ways to configure a client side handler. You can configure a client side handler by using the @HandlerChain annotation on the generated service class or SEI. Additionally, you can programmatically register your own implementation of the HandlerResolver interface on the Service, or programmatically set the handler chain on the Binding object.
|
|
javax.jws. SOAPBinding | The @SOAPBinding annotation specifies the mapping of the web service onto the SOAP message protocol.
Apply this annotation to a type or methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class.
The method level annotation is limited in what it can specify and is only used if the style property is DOCUMENT. If the method level annotation is not specified, the @SOAPBinding behavior from the type is used.
|
|
No comments:
Post a Comment