Getting Started with WebSphere Application Server
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 7 – Web services 129<br />
7.2.1 Creating a Web Service project in Eclipse<br />
As discussed in earlier sections, you can create a Dynamic Web Project to host Web<br />
Services classes as follows:<br />
Note:<br />
1. From Eclipse main menu, select File -> New -> Dynamic Web Project<br />
2. In the New Dynamic Web Project dialog, input the Project Name, such as<br />
HelloServiceProject, and click Next<br />
3. Keep the default values on the following pages and click Finish.<br />
We do not recommend you to use the Axis2’s Web Services wizard provided by the Eclipse<br />
Web Tools Platform (WTP) to create a Web Services project.<br />
7.2.2 Creating a service endpoint interface<br />
Service endpoint interface (SEI) is a normal Java interface, which is used to describe what<br />
a Web service can do. To develop a SEI, you need to define an interface and annotate it<br />
<strong>with</strong> the @WebService annotation. In this section, you will use the Java First<br />
Development; this means that the WSDL document is not available and therefore you<br />
should not provide the wsdlLocation property; otherwise you will receive a WSDL file not<br />
found exception. This is illustrated in Listing 7.1 below.<br />
package com.ibm.wasce.samples;<br />
import javax.jws.WebService;<br />
@WebService (name="HelloPeople",<br />
targetNamespace="http://samples.wasce.ibm.com")<br />
public interface HelloPeople {<br />
public String sayHello(String targetName);<br />
}<br />
Listing 7.1 – SEI: HelloPeople.java<br />
Though in the above listing the @WebService annotation properties name and<br />
targetNamespace have some values, it is fine to provide the @WebService annotation<br />
<strong>with</strong>out any properties to use defaults.<br />
7.2.3 Providing the service implementation class<br />
After creating a SEI, you need to provide a Java bean to implement it. You have to<br />
designate the endpointInterface property when the service class is implementing a<br />
SEI as shown in Listing 7.2.<br />
package com.ibm.wasce.samples;<br />
import javax.jws.WebService;<br />
@WebService(serviceName = "HelloBillService",