You can do that by following this Steps:
-Add annotation of both Rest and Soap on class implementation.
-Creating interface to hold the method annotation for Soap.
-Put Rest annotation on method in class implementation.
-Configure "web.xml" file to add "servlet" for Rest implementation you use.
-Don't forget to create class extend Application like [ApplicationConfiguration.class].
1- Class Implementation
@javax.jws.WebService(endpointInterface = "com.test.ebpp.autopayment.tess.ejb.GService", targetNamespace = "http://ejb.test.autopayment.ebpp.tess.com/", serviceName = "ApplicationBusinessFacadeService", portName = "ApplicationBusinessFacadePort")
@Path(value = "/ApplicationBusinessFacadeService")
public class ApplicationBusinessFacadePortBindingImpl implements
ApplicationBusinessFacade {
@Override
@POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ProcessResponse process(Process request) {
//type your code
}
}
2- Service Interface
@WebService(name = "ApplicationBusinessFacade", targetNamespace = "http://ejb.gateway.ebpp.com/")
@XmlSeeAlso({
com.ebpp.gateway.ejb.ObjectFactory.class,
com.ebpp.ifxmessages.ObjectFactory.class
})
public interface ApplicationBusinessFacade {
@WebMethod
@WebResult(targetNamespace = "")
@RequestWrapper(localName = "process", targetNamespace = "http://ejb.gateway.ebpp.com/", className = "com.ebpp.gateway.ejb.Process")
@ResponseWrapper(localName = "processResponse", targetNamespace = "http://ejb.gateway.ebpp.com/", className = "com.ebpp.gateway.ejb.ProcessResponse")
public ProcessResponse process(
@WebParam(name = "arg0", targetNamespace = "")
Process arg0);
}
3- web.xml
<servlet>
<servlet-name>com.ebpp.core.rs.config.ApplicationConfiguration</servlet-name>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>com.ebpp.core.rs.config.ApplicationConfiguration</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</servlet>