SOAP(Simple Object Access Protocol) – SOAP is an XML-based protocol that lets you exchange info over a particular protocol (can be HTTP or SMTP, for example) between applications. It stands for Simple Object Access Protocol and uses XML for its messaging format to relay the information.
WSDL(Web Services Definition Language) – A WSDL is an XML document that describes a web service. WSDL tells about the functions that you can implement or exposed to the client. For example: add, delete, subtract, and so on. what is the service called, which methods does it offer, what kind of in parameters and return values do these methods have?
XSD(XML Schema Definition) – describes the static structure of the complex data types being exchanged by those service methods. It describes the types, their fields, any restriction on those fields (like max length or a regex pattern), and so forth.It’s a description of datatypes and thus static properties of the service – it’s about data.
XSD definitions are part of WSDL in the tag
UDDI(Universal Description, Discovery, and Integration)– It is directly that is used to publish and discover public web services. UDDI is an obsolete failure that is almost never used in practice.UDDI works just like a telephone directory where a business can be registered as per its name, geography and the web services it publishes.UDDI registers the WSDL address URL of a web service. A client of the web service searches and finds the WSDL in the UDDI registry. Once received the WSDL can be invoked by using the URL.
WSDL: When we go to a restaurant we see the Menu Items, those are the WSDL’s.
Proxy Classes: Now after seeing the Menu Items we make up our Mind (Process our mind on what to order): So, basically we make Proxy classes based on WSDL Document.
SOAP: Then when we actually order the food based on the Menu’s: Meaning we use proxy classes to call upon the service methods which is done using SOAP
SEI(service endpoint interface): The endpoint is a connection point where HTML files or active server pages are exposed. A web service endpoint is a URL that another program would use to communicate with your program. To see the WSDL, you add WSDL to the web service endpoint URL.
Parts of WSDL
Definitions – variables – ex: myVar, x, y, etc.
Types – data types – ex: int, double, String, myObjectType
Operations – methods/functions – ex: myMethod(), myFunction(), etc.
Messages – method/function input parameters & return types
ex: public myObjectType myMethod(String myVar)
Porttypes – classes (i.e. they are a container for operations) – ex: MyClass{}, etc.
Example of a Endpoint URL
protocol://host:port/partOfThePath
where
host=someIp
port=8080
partOfThePath=/some/service/path
serviceAEndpoint=http://host:port/some/service/path?dynamicParam=
Simple SOAP Request and Response
package com.mugil.org;
import java.util.ArrayList;
import java.util.List;
import javax.jws.WebService;
@WebService
public class Products
{
List<String> arrProducts = new ArrayList<String>();
public Products()
{
arrProducts.add("Books");
arrProducts.add("EReader");
arrProducts.add("PDF");
}
public String getProduct(int index)
{
return arrProducts.get(index);
}
}
SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:org="http://org.mugil.com/">
<soapenv:Header/>
<soapenv:Body>
<org:getProduct>
<arg0>0</arg0>
</org:getProduct>
</soapenv:Body>
</soapenv:Envelope>
SOAP Request
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getProductResponse xmlns:ns2="http://org.mugil.com/">
<return>Books</return>
</ns2:getProductResponse>
</soap:Body>
</soap:Envelope>
Part of WSDL
Typical WSDL document contains the following tags
- service – Contains the port which defines the Endpoint URL, port number
- portType – Contains input and output for an operation.Though there are multiple input and output arguments they would be bundled together as one message
- binding – Defines how the SOAP service could be accessed like over http,https
- types – Type defined as complex type defines the Input and output
- message – Kind of input and output taken as argument, mostly represented as Message
Service
<wsdl:service name="ProductsService">
<wsdl:port binding="tns:ProductsServiceSoapBinding" name="ProductsPort">
<soap:address location="http://localhost:8096/WebService1/Products"/>
</wsdl:port>
</wsdl:service>
Porttype
<wsdl:portType name="Products">
<wsdl:operation name="getProduct">
<wsdl:input message="tns:getProduct" name="getProduct"></wsdl:input>
<wsdl:output message="tns:getProductResponse" name="getProductResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
Binding
<wsdl:binding name="ProductsServiceSoapBinding" type="tns:Products">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getProduct">
<soap:operation soapAction="" style="document" />
<wsdl:input name="getProduct">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="getProductResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
Types
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="http://org.mugil.com/" version="1.0">
<xs:element name="getProduct" type="tns:getProduct" />
<xs:element name="getProductResponse" type="tns:getProductResponse" />
<xs:complexType name="getProduct">
<xs:sequence>
<xs:element name="arg0" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="getProductResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Message
<wsdl:message name="getProduct">
<wsdl:part element="tns:getProduct" name="parameters" />
</wsdl:message>
<wsdl:message name="getProductResponse">
<wsdl:part element="tns:getProductResponse" name="parameters" />
</wsdl:message>
Service(Class name with @WebService Annotation)
|
Port(has Binding which defines portType)
|
PortType(defines Operations)
|
Operations(defines input and output Type)
Annotations for WebService
@Webservice(name="MartCatalogue", portName="MartCataloguePort", serviceName="ProductsService", targetNamespace="MartProducts.com")
.
.
@WebMethod(action="fetch_products", operationName="fetchProducts")
.
name
<wsdl:portType name="MartCatalogue">
.
.
portName and serviceName
wsdl:port binding="tns:productServiceSoapBinding" name="productPort">
<soap:address location="http://localhost:8096/WebService1/productService"/>
</wsdl:port>
.
.
targetNamespace
Defines unique set of operations under namespace.Defaults to package name in java in reverse order
targetNamespace=”MartProducts.com”
targetNamespace
<wsdl:operation name="fetchProducts">
.
.
<wsdl:operation name="fetchProducts">
<soap:operation soapAction="fetch_products" style="document" />
.
.