You are on page 1of 13

Web Services - SOAP

What will you learn :

- Components and Architecture of SOAP Web Service
- The Web Service Definition Language (WSDL)
- XML usage in SOAP
- Difference between REST (JSON) vs SOAP (XML)
- Setting up and using wsimport tools
- Using/Consuming SOAP web Service
- Generate WSDL file using Eclipse
SOAP Web Service Architecture

Service Registry

Find Publish

Service Provider


All the components are define inside a file called .wsdl

The file is in XML formatted
SOAP Layers



SOAP, XML Processing SOAP, XML Processing

SOAP Message SOAP Message

Socket Socket
SOAP Messaging Format






Advantages Disadvantages
Has it own security and protocol know as Slow and consume more bandwidth due
WS Security to parsing the XML formatted
Can be written in any language and WSDL file does not have mechanism for
deploy to any platform discovering the service
Object define by WSDL can be WSDL file is not really human readable
autogenerated using certain tools
SOAP Category
RPC Style Document Style
Use method name and parameters Can be define without method
almost similar to REST-JSON
Message is sent as many elements
Message is sent as single document
Tightly coupled need to follow the rules
define in WSDL Message is loosely coupled
Message will keep the operation name Does not keep the operation name
Parameters are send as discrete values Parameters are send in XML format
The Web Service Definition Language
WSDL describe 3 informations:
- The location (URL) of the web service
- Methods/Functions and members that available in the web service
- Ways to access the methods

Sample of WSDL :
WSDL Components
How to analyze .wsdl file?
- To find out the list of method look for:
<wsdl:operation name= > </wsdl:operation>
All the data types used by the Web service
- To find the parameter and return value together with datatype:
Find the <wsdl:input message:tns:request> && <wsdl:output
message Parameters and messages used by method message>
<wsdl:message name=refer_to_wsdl_input_or_output.>
<wsdl:part name=parameter1 type=xsd:> </wsdl:part>
portType Abstract interface definition each operation <wsdl:part name=parameter2 type=xsd:> </wsdl:part>
operation element defines a method signature </wsdl:message>

Binds abstract methods to specific protocols To find the url of the web service :
Look at
A service is a collection of ports.
port A port is a specific method and its URI <wsdl:address location=http://webServiceSoap/soap.php>
Review back

What does WSDL file contain?

Where is the tag/part for defining the location of the SOAP web service?
Which part does contain information about function name?
Where to find the name of the parameter for the function?
Is it possible to move@declare the <service></service> first?
Why Web Service is needed ?
A standardized way for integrating different applications and language
Ignore the differences of version without depending on specific library
Distribute data without having separated database
How the SOAP Works
1. Clients will call and download the WSDL file
2. WSDL will provide the interface of the methods available
3. Client pass the input via the specified parameter name
4. The input will be passed directly to web service Implementation
5. Web Service receive the input and do the process logic
6. Web Service returns the response according to the WSDL return definition
7. Clients receive the data/value

3 5

Clients (C++, Java, C#) WSDL (interface) Web Service

Consuming Java JAX-WS
JAX-WS client can be generated using wsimport
Ensure the environment variable is pointing to [jdk_path]/bin
On window right click on the Computer >> Properties >> Advance System
Settings >> Click Environment Variable button >> PATH and click Edit button

Test the program opening command line and type wsimport

To generate JAX-WS client run command :
wsimport keep s javaSrcFile http://addressWebServce/wsdlFile.wsdl
Steps to consume JAX-WS

1. Ensure the wsimport is installed

2. Identify the location of the wsdl
3. Run the wsimport keep s [folderToSave] [url of the wsdl]
4. Copy the library or the source file to your project
5. Declare and instantiate the class that extends Service at the main program
6. Declare and instantiate the interface class at the main program
7. Call the desired methods and ensure follow the parameter and the return