What is Web Service?
A Web service is a method of communication between two electronic devices over the World Wide Web. A Web service is a software function provided at a network address over the web or the cloud, it is a service that is "always on" as in the concept of utility computing.
The W3C defines a "Web service" as "a software system designed to support interoperable machine-to-machine interaction over a network". It has an interface described in a machine-processable format (specifically Web Services Description Language, known by the acronym WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.
Web services creation process
1. To create webservice you have to Download axis2.1.x
2. Open eclipse-> windows ->preferences as shown in screen print.
3. In preferences->web Services-> Axis 2 Preferences
4. Set Location
5. Navigate to Server and runtime -> set Web service runtime o Apache Axis2.
6. Apply and click ok
7. Now create dynamic web project.
8. Create class as :
9. Now Right click on the created class -> click on New -> Web service as shown in fig
10. Now, if server is not set then set the installed server and click finish to create web service.
11. Below shown is that the web service is created with following wsdl link as http://localhost:8081/SampleWebService/services/MyWebServiceClass?wsdl and generated wsdl file for the same
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://webserviceSample.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://webserviceSample.com">
<wsdl:documentation>Please Type your service description here</wsdl:documentation>
- <wsdl:types>
- <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://webserviceSample.com">
- <xs:element name="square">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="num" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="squareResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
- <wsdl:message name="squareRequest">
<wsdl:part name="parameters" element="ns:square" />
</wsdl:message>
- <wsdl:message name="squareResponse">
<wsdl:part name="parameters" element="ns:squareResponse" />
</wsdl:message>
- <wsdl:portType name="MyWebServiceClassPortType">
- <wsdl:operation name="square">
<wsdl:input message="ns:squareRequest" wsaw:Action="urn:square" />
<wsdl:output message="ns:squareResponse" wsaw:Action="urn:squareResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="MyWebServiceClassSoap11Binding" type="ns:MyWebServiceClassPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="square">
<soap:operation soapAction="urn:square" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="MyWebServiceClassSoap12Binding" type="ns:MyWebServiceClassPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="square">
<soap12:operation soapAction="urn:square" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="MyWebServiceClassHttpBinding" type="ns:MyWebServiceClassPortType">
<http:binding verb="POST" />
- <wsdl:operation name="square">
<http:operation location="MyWebServiceClass/square" />
- <wsdl:input>
<mime:content type="text/xml" part="square" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" part="square" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="MyWebServiceClass">
- <wsdl:port name="MyWebServiceClassHttpSoap11Endpoint" binding="ns:MyWebServiceClassSoap11Binding">
<soap:address location="http://127.0.0.1:8081/SampleWebService/services/MyWebServiceClass.MyWebServiceClassHttpSoap11Endpoint/" />
</wsdl:port>
- <wsdl:port name="MyWebServiceClassHttpSoap12Endpoint" binding="ns:MyWebServiceClassSoap12Binding">
<soap12:address location="http://127.0.0.1:8081/SampleWebService/services/MyWebServiceClass.MyWebServiceClassHttpSoap12Endpoint/" />
</wsdl:port>
- <wsdl:port name="MyWebServiceClassHttpEndpoint" binding="ns:MyWebServiceClassHttpBinding">
<http:address location="http://127.0.0.1:8081/SampleWebService/services/MyWebServiceClass.MyWebServiceClassHttpEndpoint/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
8. Create class as :
9. Now Right click on the created class -> click on New -> Web service as shown in fig
10. Now, if server is not set then set the installed server and click finish to create web service.
11. Below shown is that the web service is created with following wsdl link as http://localhost:8081/SampleWebService/services/MyWebServiceClass?wsdl and generated wsdl file for the same
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://webserviceSample.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://webserviceSample.com">
<wsdl:documentation>Please Type your service description here</wsdl:documentation>
- <wsdl:types>
- <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://webserviceSample.com">
- <xs:element name="square">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="num" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="squareResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
- <wsdl:message name="squareRequest">
<wsdl:part name="parameters" element="ns:square" />
</wsdl:message>
- <wsdl:message name="squareResponse">
<wsdl:part name="parameters" element="ns:squareResponse" />
</wsdl:message>
- <wsdl:portType name="MyWebServiceClassPortType">
- <wsdl:operation name="square">
<wsdl:input message="ns:squareRequest" wsaw:Action="urn:square" />
<wsdl:output message="ns:squareResponse" wsaw:Action="urn:squareResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="MyWebServiceClassSoap11Binding" type="ns:MyWebServiceClassPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="square">
<soap:operation soapAction="urn:square" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="MyWebServiceClassSoap12Binding" type="ns:MyWebServiceClassPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="square">
<soap12:operation soapAction="urn:square" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="MyWebServiceClassHttpBinding" type="ns:MyWebServiceClassPortType">
<http:binding verb="POST" />
- <wsdl:operation name="square">
<http:operation location="MyWebServiceClass/square" />
- <wsdl:input>
<mime:content type="text/xml" part="square" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" part="square" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="MyWebServiceClass">
- <wsdl:port name="MyWebServiceClassHttpSoap11Endpoint" binding="ns:MyWebServiceClassSoap11Binding">
<soap:address location="http://127.0.0.1:8081/SampleWebService/services/MyWebServiceClass.MyWebServiceClassHttpSoap11Endpoint/" />
</wsdl:port>
- <wsdl:port name="MyWebServiceClassHttpSoap12Endpoint" binding="ns:MyWebServiceClassSoap12Binding">
<soap12:address location="http://127.0.0.1:8081/SampleWebService/services/MyWebServiceClass.MyWebServiceClassHttpSoap12Endpoint/" />
</wsdl:port>
- <wsdl:port name="MyWebServiceClassHttpEndpoint" binding="ns:MyWebServiceClassHttpBinding">
<http:address location="http://127.0.0.1:8081/SampleWebService/services/MyWebServiceClass.MyWebServiceClassHttpEndpoint/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Comments
Post a Comment