Tuesday, October 4, 2011

WebSphere & JAX-WS

What better for a novice like me to learn how to deploy Webservices on WebSphere than to try it using hello world.

Here's my code:

1. Web Service Endpoint Interface

/**
*
*/
package com.singtel.ma.rto;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
/**
* @author Main Masrudyn
*
*/
//Service Endpoint Interface
@WebService
public interface RTO {


@WebMethod String getHelloWorldAsString(String name);

}


2. Web Service Endpoint Implementation

package com.singtel.ma.rto;


import javax.jws.WebMethod;
import javax.jws.WebService;

//Service Implementation
@WebService(endpointInterface = "com.singtel.ma.rto.RTO")
public class RTOImpl implements RTO {

public String getHelloWorldAsString(String name) {
return "Hello World JAX-WS " + name;
}

}

3. Deploy on WebSphere, choose Detailed:


4. Ensure Deploy Webservice


5. Click on Service providers - ensure listener start




6. Check the webservice is running : http://rhel55-32.mydomain.com:9080/RTO/RTOImplService/RTOImplService.wsdl

4 comments:

  1. For Step 5, it should be after you have finished deploying the war file. If you don't see it - it could be that you didn't use wsgen to generate all the artifacts:


    Generate the WSDL and artifacts using the following command:
    "C:\Program Files (x86)\Java\jdk1.6.0_21\bin\wsgen" -cp ../build/classes -r ../WebContent -s . -d ../build/classes -keep com.singtel.ma.rto.RTOImpl -wsdl

    ReplyDelete
  2. Step 4 - Deploy Web Services is not neccessary.

    Also, you can choose "Fast Path - Prompt only when additional information is required. " and do NOT need to choose "Detailed - Show all installation options and parameters."

    ReplyDelete
  3. M:\Development\EclipseWorkspaces\RTO Services\RTOService\src>"C:\Program Files (
    x86)\Java\jdk1.6.0_27\bin\wsgen" -cp ../build/classes;../WebContent/WEB-INF/lib/interact_client.jar;../WebContent/WEB-INF/lib/log4j-1.2.15.jar -r ../WebContent
    -s . -d ../build/classes -keep com.singtel.ma.rto.RTOServiceImpl -wsdl

    ReplyDelete
  4. Hi Mas & Pikachu,

    I know this post & comments are bit old but I am facing the same problem here. Not able to get jax-ws web service running on websphere 8.5. If you could guide me on the issue.

    Regards,
    Ravi

    ReplyDelete