我目前正在使用 jaxb 实现一个 Spring Web 服务。但是当我尝试使用创建的 Web 服务WebServiceTransportException: Not Found [404]
时遇到错误。我确实尝试搜索网络,但无法找到可能的根本原因。下面我展示了我的源代码。
应用程序上下文.xml
<bean
class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
<constructor-arg ref="marshaller" />
</bean>
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.ph.domain.EightBallRequest</value>
<value>com.ph.domain.EightBallResponse</value>
</list>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="simpleUrlHandlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
lazy-init="true">
<property name="mappings">
<props>
<prop key="/test.asp">LandingController</prop>
</props>
</property>
</bean>
<bean name="LandingController" class="com.ph.controller.LandingController">
<property name="stub" ref="eightBallClient"/>
</bean>
网络服务客户端
public class EightBallClient extends WebServiceGatewaySupport {
private Resource request;
public void setRequest(Resource request) {
this.request = request;
}
public String AskQuestion(String question) throws IOException {
String responseString = null;
EightBallRequest request = new EightBallRequest();
request.setQuestion(question);
EightBallResponse response = new EightBallResponse();
response = (EightBallResponse) getWebServiceTemplate()
.marshalSendAndReceive(request);
responseString = response.getAnswer().toString();
return responseString;
}
}
我的网络服务的定义
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/eightball.xsd" />
</bean>
下面是错误堆栈:
SEVERE: Servlet.service() for servlet dispatcher threw exception
org.springframework.ws.client.WebServiceTransportException: Not Found [404]
at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:626)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:550)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:501)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:350)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:344)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:336)