0

私は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でサーブレットとして構成できることを読みましたが、注釈が付けられていない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用に1つの方法、GlassFish用に1つの方法、JBoss用に1つの方法、WebSphere用に1つの方法など)。

Webサービスのパスを指定するために使用できる注釈はありますか?または、web.xmlファイルの構成パラメーター?

ありがとう!

エリック

4

1 に答える 1

0

私が得ていたJBossエラーは、Webサービスモジュールが有効になっていないことが原因であることがわかりました。JBoss7.0 / 7.1では、standalone-preview.xml構成を実行して、すぐに使用できるダウンロード用のWebサービスを取得する必要があります。つまり、standalone.sh --server-config=standalone-preview.xmlです。これにより、ClassCast/Servlet例外が排除されました。ただし、web.xmlでサーブレットとして宣言するよりも、(おそらくアノテーションを介して)これを実現するためのより良い/他の方法がない場合は、まだ私の質問が残っています。

于 2012-08-15T20:33:46.740 に答える