シンプルな Spring MVC Web アプリケーションを作成し、 JAX-WS コモンズ RI実装を使用して SOAP ベースの JAX-WS サービスとしてサービスを公開しようとしました。
アプリケーションを Tomcat 7 にデプロイした後、Web サービスにアクセスしようとすると、404 Not Found: Invalid Request というメッセージが表示されます。以下は私の構成です。これを解決するのに親切に助けてください。
web.xml
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes SOAP Web Service requests -->
<servlet>
<servlet-name>jaxws-servlet</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jaxws-servlet</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
WEB-INF/spring/appServlet/servlet-context.xml
<beans:bean id="customerService" class="com.home.service.CustomerService" />
<!-- Web Service definition -->
<beans:bean id="customerWS" class="com.home.ws.CustomerWS">
<beans:property name="customerService" ref="customerService" />
</beans:bean>
<wss:binding url="/ws/CustomerServ">
<wss:service>
<ws:service bean="#customerWS" />
</wss:service>
</wss:binding>
CustomerWS.java
@WebService
@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL)
public class CustomerWS {
private CustomerService customerService;
@WebMethod
public Customer read(long id) {
return customerService.read(id);
}
public void setCustomerService(CustomerService customerService) {
this.customerService = customerService;
}
}
CustomerService.java
@Service
public class CustomerService {
public Customer read(long id) {
Customer cust = null;
System.out.println("CustomerService.read invoked");
return cust;
}
}
pom.xml - jaxws-spring の依存関係を含めました
<dependency>
<groupId>org.jvnet.jax-ws-commons.spring</groupId>
<artifactId>jaxws-spring</artifactId>
<version>1.9</version>
</dependency>
アプリケーションのビルドまたはデプロイ中にエラーは発生しません。URL にアクセスしても、サーバー ログ ファイルにエラーは表示されません。ただし、ブラウザにはメッセージが表示されます - 404 Not Found: Invalid Request
私が試しているURLは -http://localhost:8080/crrs/ws/CustomerServ?wsdl
HomeController にアクセスすると、問題なく動作します。ホームページが期待どおりに読み込まれます。
どんな助けにも感謝します。前もって感謝します。