我是编写 Web 服务的新手,并且正在努力理解如何指定上下文根。
我的班级用
@Service
@javax.jws.WebService(endpointInterface= "com.domain.clientservices.lendingsimulation.model.v1.LendingSimulationServicePortType", targetNamespace="http://www.domain.com/ClientServices/LendingSimulation/V1.2", serviceName="LendingSimulationService", portName="LendingSimulationServicePort")
但我不确定如何为其配置上下文根/路径。我读到我可以将它配置为 web.xml 中的 servlet,但对于没有注释的 Web 服务似乎就是这种情况。我错了吗?我在 web.xml 中尝试了以下配置:
<servlet>
<description>This is the description for the LendingSimulation Service</description>
<display-name>Lending Simulation Service</display-name>
<servlet-name>LendingSimulationService</servlet-name>
<servlet-class>com.domain.clientservices.lendingsimulation.service.LendingSimulationServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LendingSimulationService</servlet-name>
<url-pattern>/WebService</url-pattern>
</servlet-mapping>
但是,当我在 JBoss 中启动时,我收到一条错误消息:
17:39:33,710 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/LendingSimulationService].[LendingSimulationService]] (http--127.0.0.1-8080-2) Allocate exception for servlet LendingSimulationService: java.lang.ClassCastException: com.domain.clientservices.lendingsimulation.service.LendingSimulationServiceImpl incompatible with javax.servlet.Servlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1156) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
... (omitted for brevity)
我读过我可以专门配置 jboss-web.xml,但我认为有一种更通用的方法可以应用于所有应用程序服务器 - 不是吗?或者我必须独立配置服务,具体取决于我要部署到的 AS(即:Tomcat 的一种方式,GlassFish 的一种方式,JBoss 的一种方式,WebSphere 的一种方式等......)。
是否有可以用来指定 Web 服务路径的注释?还是 web.xml 文件中的配置参数?
谢谢!
埃里克