EJB 2.1 Web 服务端点@WebContext



我有一个定义事件操作的WSDL文件。

需要定义一个 SOAP Web 服务端点,该端点由第三方调用,其中包含 WSDL 文件中指定的一些参数。

该项目使用 EJB 2.1

无法使终点正常工作(404 错误(:

http://localhost:28080/myapp/ws/ClassCallBack

下面的类位于 EAR 文件的根文件夹中包含的 JAR 文件中。

有什么问题吗?我是否必须在某个 xml 中将此类声明为 EJB?(在 EJB-jar 中.xml 中,所有 EJB 会话 Bean 都被声明,但这不是会话 Bean(

@WebService
public interface ClassCallBackWs {
@WebMethod
  public void event(@WebParam(name = "event") ClassParameter event) 
      throws Exception;      
}
=====================================
@Stateless(name = "ClassCallBackEjb")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@WebService(name = "ClassCallBackWs", portName = "ClassCallBackWs",
        serviceName = "ClassCallBackWsService",
        targetNamespace = "http://test.serverurl.org.com/",
        endpointInterface = "ClassCallBackWs")
@WebContext(contextRoot = "/myapp/ws/", 
            urlPattern = "/v0/ClassCallBackWsImpl", 
            transportGuarantee = "NONE", secureWSDLAccess = false)
public class ClassCallBackWsImpl implements ClassCallBackWs {
    @WebMethod
    public void event(@WebParam(name = "event") ClassParameter event) throws Exception {
    }
}

下面给出一个可能的解决方案的例子。创建了一个定制 servlet,该 servlet 通过在其 XML 中定义 JAX WS 端点来映射到实现类

(隐瞒了与最终解决办法有关的所有名称,因为私人拥有。抱歉,如果因此而出现错误(。

Servlet mapping/XML:

<servlet-mapping>
    <servlet-name>testws</servlet-name>
    <url-pattern>/myapp/ws/v0/</url-pattern>
</servlet-mapping>

用作端点的 servlet 的 XML 配置:

    <jaxws:endpoint
        id="CallBackWs" implementor="org.test.ClassCallBackWsImpl "
        wsdlLocation="WEB-INF/wsdl/CallBackTest.wsdl"
        address="/ClassCallBackWsImpl"
        bindingUri="ClassCallBackWsImpl">
    </jaxws:endpoint>

终点 Impl 类:

   @WebService(
      portName = "CallBackWs",
      serviceName = "CallBackWsService", 
      targetNamespace = "http://test.server.callback.ws/", 
      endpointInterface = "org.test.CallBackWs") 
   public class ClassCallBackWsImpl implements ClassCallBackWs{    
       public void event(ClassParameter event) throws Exception { 
       } 
   }

接口类:

@WebService(targetNamespace = "http://test.server.callback.ws/", name = "ClassCallBackWs")
public interface Ws {
    @RequestWrapper(localName = "event", targetNamespace = "http://test.server.callback.ws/", className = "org.test.ClassParameter")
    @WebMethod
    public void event(
        @WebParam(name = "event", targetNamespace = "")
        org.test.ClassParameter event
    ) throws Exception;
}

最新更新