user2051823
user2051823

Reputation: 177

How to use wsgen tool for SOAP/JMS Web Services

I am following the tutorial [here] to create a Web Services application in RAD. However, when I try to add a new function in EchoSOAPImpl.java:

@WebMethod
public String getInput(String input) {
    return "Your input is: " + input;
}

and then use wsgen to generate the necessary java files:

wsgen -s ejbModule -cp build\classes -d build com.ibm.was.wssample.sei.echo.EchoSOAPImpl

, it failed with this error message:

error: Could not create declaration for annotation type javax.ejb.Stateless

I tried to delete the annotation, but the whole project shows the error:

An EJB module must contain one or more enterprise beans.m

I am so frustrated with building Web Services in RAD. There are very few tutorials or study materials provided. Please also provide any other useful materials about Web Service in RAD.

EchoSOAPImpl.java

package com.ibm.was.wssample.sei.echo;

@javax.ejb.Stateless
@javax.jws.WebService(endpointInterface = "com.ibm.was.wssample.sei.echo.EchoServicePortType", targetNamespace = "http://com/ibm/was/wssample/sei/echo/", serviceName = "EchoService", portName = "EchoServicePort")
public class EchoSOAPImpl implements EchoServicePortType {

@Override
public EchoStringResponse echoOperation(EchoStringInput parameter) {
    ...
    return response;
}

@Override
public String getInput(String input) {
    return "Your input is: " + input;
}

}

EchoServicePortType

@WebService(name = "EchoServicePortType", targetNamespace = "http://com/ibm/was/wssample/sei/echo/")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso( { ObjectFactory.class })
public interface EchoServicePortType {

@WebMethod(action = "echoOperation")
@WebResult(name = "echoStringResponse", targetNamespace = "http://com/ibm/was/wssample/sei/echo/", partName = "parameter")
public EchoStringResponse echoOperation(
        @WebParam(name = "echoStringInput", targetNamespace = "http://com/ibm/was/wssample/sei/echo/", partName = "parameter") EchoStringInput parameter);

@WebMethod(action = "getInput")
@WebResult(name = "getInputResponse", targetNamespace = "http://com/ibm/was/wssample/sei/echo/", partName = "parameter")
public String getInput(@WebParam(name = "getInputInput", targetNamespace = "http://com/ibm/was/wssample/sei/echo/", partName = "parameter") String getInput);

}

Upvotes: 1

Views: 317

Answers (2)

ACV
ACV

Reputation: 10560

You need to add Java EE API jar to the classpath like here: wsgen -wsdl -cp .;javaee-api-6.0.jar com.vvirlan.MyWsEjb

Upvotes: 0

APD
APD

Reputation: 1519

This appears to be a bug in wsgen. I suggest that you add the IBM EJB API jar that contains @Stateless in the wsgen classpath such as:

wsgen -s ejbModule -cp {ibm javaeJB jar}:build\classes -d build com.ibm.was.wssample.sei.echo.EchoSOAPImpl

That is assuming that as you are using RAD that you are using Websphere also. If not add the standard Java EE jar.

Upvotes: 2

Related Questions