TechnoBuzz

A Techno Blog, mainly about Java

Soap Web Services Begin To End Part 2

Create a Dynamic Web project in eclipse. In my case I called it NumbersService.

Create a new class :
learn.webservices.numbers.ElectricCompanyService :

public class ElectricCompanyService {

public int multiply(int number1, int number2)
{
return number1 * number2;
}

public int add(int number1, int number2)
{
return number1 – number2;
}

}

Right click in the siderbar on ElectricCompanyService

WebService-> Create Web Service

On the screen that comes up, move the selector up one notch where it shows Test Service

In Web Content you can find a folder named WSDL with the WSDL file

<?xml version=”1.0″ encoding=”UTF-8″?>
<wsdl:definitions targetNamespace=”http://numbers.webservices.learn&#8221; xmlns:apachesoap=”http://xml.apache.org/xml-soap&#8221; xmlns:impl=”http://numbers.webservices.learn&#8221; xmlns:intf=”http://numbers.webservices.learn&#8221; xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/&#8221; xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema”&gt;
<!–WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)–>
<wsdl:types>
<schema elementFormDefault=”qualified” targetNamespace=”http://numbers.webservices.learn&#8221; xmlns=”http://www.w3.org/2001/XMLSchema”&gt;
<element name=”add”>
<complexType>
<sequence>
<element name=”number1″ type=”xsd:int”/>
<element name=”number2″ type=”xsd:int”/>
</sequence>
</complexType>
</element>
<element name=”addResponse”>
<complexType>
<sequence>
<element name=”addReturn” type=”xsd:int”/>
</sequence>
</complexType>
</element>
<element name=”multiply”>
<complexType>
<sequence>
<element name=”number1″ type=”xsd:int”/>
<element name=”number2″ type=”xsd:int”/>
</sequence>
</complexType>
</element>
<element name=”multiplyResponse”>
<complexType>
<sequence>
<element name=”multiplyReturn” type=”xsd:int”/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>

<wsdl:message name=”multiplyResponse”>

<wsdl:part element=”impl:multiplyResponse” name=”parameters”>

</wsdl:part>

</wsdl:message>

<wsdl:message name=”multiplyRequest”>

<wsdl:part element=”impl:multiply” name=”parameters”>

</wsdl:part>

</wsdl:message>

<wsdl:message name=”addResponse”>

<wsdl:part element=”impl:addResponse” name=”parameters”>

</wsdl:part>

</wsdl:message>

<wsdl:message name=”addRequest”>

<wsdl:part element=”impl:add” name=”parameters”>

</wsdl:part>

</wsdl:message>

<wsdl:portType name=”ElectricCompanyService”>

<wsdl:operation name=”add”>

<wsdl:input message=”impl:addRequest” name=”addRequest”>

</wsdl:input>

<wsdl:output message=”impl:addResponse” name=”addResponse”>

</wsdl:output>

</wsdl:operation>

<wsdl:operation name=”multiply”>

<wsdl:input message=”impl:multiplyRequest” name=”multiplyRequest”>

</wsdl:input>

<wsdl:output message=”impl:multiplyResponse” name=”multiplyResponse”>

</wsdl:output>

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name=”ElectricCompanyServiceSoapBinding” type=”impl:ElectricCompanyService”>

<wsdlsoap:binding style=”document” transport=”http://schemas.xmlsoap.org/soap/http”/&gt;

<wsdl:operation name=”add”>

<wsdlsoap:operation soapAction=””/>

<wsdl:input name=”addRequest”>

<wsdlsoap:body use=”literal”/>

</wsdl:input>

<wsdl:output name=”addResponse”>

<wsdlsoap:body use=”literal”/>

</wsdl:output>

</wsdl:operation>

<wsdl:operation name=”multiply”>

<wsdlsoap:operation soapAction=””/>

<wsdl:input name=”multiplyRequest”>

<wsdlsoap:body use=”literal”/>

</wsdl:input>

<wsdl:output name=”multiplyResponse”>

<wsdlsoap:body use=”literal”/>

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name=”ElectricCompanyServiceService”>

<wsdl:port binding=”impl:ElectricCompanyServiceSoapBinding” name=”ElectricCompanyService”>

<wsdlsoap:address location=”http://localhost:8080/NumbersService/services/ElectricCompanyService”/&gt;

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

:

Advertisements

October 21, 2012 - Posted by | Uncategorized

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: