16.10.2015 Views

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.

130 <strong>Getting</strong> <strong>Started</strong> <strong>with</strong> <strong>WebSphere</strong> <strong>Application</strong> <strong>Server</strong> Community Edition<br />

portName = "HelloBillPort",<br />

endpointInterface = "com.ibm.wasce.samples.HelloPeople",<br />

targetNamespace = "http://samples.wasce.ibm.com")<br />

public class HelloBill implements HelloPeople {<br />

public String sayHello(String targetName) {<br />

return "Hello " + targetName;<br />

}<br />

}<br />

Listing 7.2 – SEI’s implementation: HelloBill.java<br />

The @WebService annotation properties serviceName, portName, and<br />

targetNamespace shown in the above listing are sample values. It is fine to provide the<br />

@WebService annotation only <strong>with</strong> values for the endpointInterface property and use<br />

defaults for the rest.<br />

7.2.4 Deploying the Web Service in Community Edition<br />

To publish a Web Service in Community Edition, you need to add some information under<br />

the and elements in the Web project’s WEB-<br />

INF/web.xml file. However, this does not mean that the service class must be a Servlet,<br />

which must extend the HttpServlet. The Web service is never a real servlet; the deployer of<br />

Community Edition can distinguish whether or not it is a Web service implementation class.<br />

Listing 7.3 provides an example of the contents of web.xml.<br />

<br />

Hello<br />

com.ibm.wasce.samples.HelloBill<br />

<br />

<br />

Hello<br />

/Hello<br />

<br />

Listing 7.3 - The web.xml file<br />

The element defines how to invoke the Web service from a browser and<br />

also the path to retrieve its WSDL file.<br />

After deploying the Web project to Community Edition, launch a browser and go to the<br />

following URL: http://localhost:8080/HelloServiceProject/Hello<br />

You should see a message from the Axis2 engine as shown in Figure 7.2 below.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!