我目前正在使用jaxb實現一個spring web服務。但是當我嘗試使用創建的WebServiceTransportException: Not Found [404]
錯誤時,Web服務被遇到。我確實嘗試搜索網絡,但無法找到可能的根本原因。下面我顯示我的源代碼。我的web服務的WebServiceTransportException:未找到[404]
應用程序的context.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>
客戶端的web服務
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)
請檢查lib文件夾是否包含此jar spring-oxm-1.5.6.jar? – Ami
@ILLA - 是,彈簧OXM-1.5.6.jar是包括以及下面罐字段:\ n 彈簧OXM虎 彈簧-WS 彈簧-WS-芯 彈簧-WS-芯 - tiger – plandi07
@ILLA - 您知道一個網站,它提供了使用JAXB創建Spring Web服務的完整教程/實現,直到客戶端使用服務爲止。我有點混淆了客戶端如何使用spring webservice ...我對需要公開彈簧mvc應用程序的現有服務層以便其他應用程序可以使用它的項目很感興趣。任何想法?先謝謝了。 – plandi07