Web services and Soap

1. Compare and contrast web applications with web services, indicating the need for web
services.

WEB SERVICES
1.Web services are server-side application components ,which provides a set of services.

2.Services of the web service are exposed via an API
                     Modular,well-defined,encapsulated interfaces are used for loosely coupled integration                         between applications and systems.

3. Loosely coupled architecture,and interacts with client-side components via the API

4.Multiple types of clients can communicate with the web service via the API
                    Browser- based- clients ,non- browser- based-clients(mobile apps),other web services

                                                      • Program-to-program
                                                         interaction
                                                      • Dynamic integration of
                                                        components
                                                      • Service aggregation
                                                        (micro-services)
                                                      • Interoperability (RPC/SOAP/REST)

WEB APPLICATIONS

web application is a software application that runs on a remote server. In most cases, Web browsers are used to access Web applications, over a network, such as the Internet. Some web applications are used in intranets, in companies and schools, for example.

                                                     • User-to-program interaction
                                                     • Static integration of components
                                                     • Monolithic service
                                                     • Ad hoc or proprietary
                                                       protocol



2.Discuss what WSDL is and the use of it in the context of web services

WSDL is an XML vocabulary for describing web services allowing developers to describe web services and their other capabilities, in a standard manner.

Description stack is the standard format of describe the web services

Specifies 3 fundamental properties

1.What a service does - what are the operations provide by the service

2.How a service is accessed - data format and protocol details

3.Where a service is located -Address (URL) details



Use of WSDL context to web services.

The document written in WSDL is also simple called a WSDL document

The service provides the WSDL document and the web service client uses the WSDL
document to create the stub


1.use the XML schema language to declare
complex data types and elements that are used
elsewhere in the WSDL document

2. serve as a container for defining any data types
that are not described by the XML schema builtin
types: complex types and custom simple
types,

3. the data types and elements defined in the types
element are used by message definitions when

declaring the parts (payloads) of messages


3.Explain the fundamental properties of a WSDL document and the use of WSDL document in
web services and client development


ElementDescription
<types>Defines the (XML Schema) data types used by the web service
<message>Defines the data elements for each operation
<portType>Describes the operations that can be performed and the messages involved.
<binding>Defines the protocol and data format for each port type





4.Discuss the structure of the WSDL document, explaining the elements in WSDL


WSDL is usually taken to describe the available services which it has. The file contains
  • The location of the web service
  • The methods given by the web service.
The main structure is
  • Definition
  • TargetNamespace
  • DataTypes
  • Messages
  • Porttype
  • Bindings

5. Compare the PortType and operation elements in WSDL with the java equivalences

1. define web service functionality at abstract level
    grouping sets of message exchanges into operations
    contain a set of operations that incorporates input,
    output and fault messages and parameter order
2. WSDL supports at least a single input and output
    message, but permits the declaration of an arbitrary
    number of faults
3. portType element may have one or more operation
    elements, each of which defines an RPC- or documentstyle
    Web service method
4. Java equivalence:
   portType -> java interface
   operation -> method name



<portType
name="net.xmethods.services.stockquote.StockQuotePortType">
<operation name="getQuote" parameterOrder="symbol">
<input message="tns:getQuoteRequest" />
<output message="tns:getQuoteResponse" />
</operation>
</portType>

6. Compare and contrast the binding and service elements in                WSDL


Binding
WSDL Binding to SOAP. WSDLbindings defines the message format and protocol details for a web service. The binding element has two attributes - name and type. ... The soap:binding element has two attributes - style and transport.

Service elements
<types>
Defines the (XML Schema) data types used by the web service
<message>
Defines the data elements for each operation
<portType>
Describes the operations that can be performed and the messages involved.
<binding>
Defines the protocol and data format for each port type
7.Explain how SOAP is used with HTTP.
SOAP is an integral part of the service-oriented architecture and the Web services specifications associated with SOA. Because it allows the sender to create a message route based on the logical services that have to be applied to the message on the way to its destination, it lends itself to providing secure and compliant connections, controlling access, offering reliable delivery and failure recovery, and supporting dynamic service discovery. SOA without SOAP is difficult to imagine.
SOAP’s messages are defined at a high level in XML, but most SOAP applications use Web Services Definition Language (WSDL), which is authored in XML.  The XML structure of SOAP makes it handy for applications that expect their information to be provided in XML form, and the fact that SOAP can ride on a variety of network protocols, including HTTP, means it’s easily passed through firewalls, where other protocols might require special accommodation.
The data structure of SOAP is based on XML, which is similar in many ways to the HTML used to define web pages. Like HTML, XML is largely human-readable, which makes it fairly easy to understand a SOAP message, but also makes the messages relatively large in comparison to the Common Object Request Broker Architecture  and its Remote Procedure Call protocol that will accommodate binary data.

8. Discuss how SOAP can be used for functional oriented communication?
SOAP ( 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 .  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 micro service-centric development environments.

9. Explain the structure of SOAP message in message oriented communication, indicating the elements used
SOAP is intended to be a simple yet powerful extensible protocol for distributed messaging based on XML. A key element of SOAP is its concept of having a message envelope and a set of headers. The envelope contains the message body that can be XML data or parameters and is intended for the recipient.

In this example, a Get Last Trade Price SOAP request is sent to a Stock Quote service. The request takes a string parameter, ticker symbol, and returns a float in the SOAP response. The SOAP Envelope element is the top element of the XML document representing the SOAP message. XML namespaces are used to disambiguate SOAP identifiers from application specific identifiers. 


Example 1 SOAP Message Embedded in HTTP Request
10. Discuss the importance of the SOAP attachments, explaining the MIME header
This document defines a SOAP feature that represents an abstract model for SOAPattachments. It provides the basis for the creation of SOAP bindings that transmit such attachments along with a SOAP envelope, and provides for reference of those attachments from the envelope.
                             
11.Identify different set of frameworks/libraries for SOAP web service development, in different environments (Java, .Net, PHP, etc…)
Java
WS-Reliable Messaging, WS-Security, WS- Atomic Transaction, WS-Addressing, MTOM, WS-Policy, WS-Metadata Exchange

.Net
WS-Addressing, WS-Metadata Exchange, WS-Security, WS-Policy, WS-Security Policy, WS-Trust, WS-Secure Conversation, WS-Reliable Messaging, WS-Coordination, WS-Atomic Transaction,WS-Discovery

PHP
SOAP MTOM, WS-Addressing, WS-Security, WS-Security Policy, WS-Secure Conversation, WS-Reliable Messaging

C and C++
WS-Addressing, WS-Discovery, WS-Policy, WS-Reliable Messaging, WS-Security, WS-Security Policy.
12.Explain the annotations in JAX-WS, providing examples of their use
The starting point for developing a JAX-WS web service is a Java class annotated with the javax.jws.WebService annotation. The Web Service annotation defines the class as a web service endpoint.
service endpoint interface  is a Java interface that declares the methods that a client can invoke on the service. An SEI is not required when building a JAX-WS endpoint. The web service implementation class implicitly defines a SEI.
You may specify an explicit SEI by adding the endpoint Interface element to the WebService annotation in the implementation class. You must then provide a SEI that defines the public methods made available in the endpoint implementation class.
You use the endpoint implementation class and the wsgen tool to generate the web service artifacts and the stubs that connect a web service client to the JAX-WS run time. For reference documentation on wsgen, see the Application Server man pages at .
Together, the wsgen tool and the Application Server provide the Application Server's implementation of JAX-WS.
These are the basic steps for creating the web service and client:

  1. Code the implementation class.

  2. Compile the implementation class.

  3. Deploy the WAR file. The tie classes (which are used to communicate with clients) are generated by the Application Server during deployment.

  4. Code the client class.

  5. Use ws import to generate and compile the stub files.

  6. Compile the client class.

  7. Run the client.
The sections that follow cover these steps in greater detail.


JAX-WS Example

Now that we have gone through the web services terminologies, let’s go ahead and create a JAX-WS web service. We will create a web service that will expose methods to add, delete and get person objects. So first of all we will create a model bean for our data.

Comments