我使用注释驱动的Spring WS 2.0.2来创建一个简单的Webservice,但是没有找到端点映射。
Input和Output都是jdom元素,尽可能的简单。
Webservice在Tomcat 6.0.29上使用Java 1.6运行,返回一个错误页(请求的资源()不可用)到我的SoapUI服务测试。
下面是我在日志中得到的错误:
WARNING: No endpoint found for [SaajSoapMessage (http://foo.bar/myTest)myRequest]
以下是我认为与Endpoint映射相关的配置部分:(如果有更多相关的部分我遗漏了,请问回来…)
<<p> 模式/strong> (web - inf/xsd/myTest.xsd)targetNamespace="http://foo.bar/myTest"
...
<element name="myRequest" type="tns:string"/>
<element name="myResponse" type="tns:string"/>
web . xml (web - inf/web . xml)
<servlet-class>
org.springframework.ws.transport.http.MessageDispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/config.xml</param-value>
</init-param>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
Spring的配置(/web - inf/Spring/config . xml)
<sws:annotation-driven/>
<sws:dynamic-wsdl id="myTest"
portTypeName="myTest"
localUri="/"
targetNamespace="http://foo.bar/myTest">
<sws:xsd location="/WEB-INF/xsd/myTest.xsd"/>
</sws:dynamic-wsdl>
<<p> 端点/strong> (src/main/java/酒吧/foo/MyEndpoint.java) @Endpoint
public class MyEndpoint{
@PayloadRoot(localPart="myRequest",namespace="http://foo.bar/myTest")
@ResponsePayload
public Element mySearch( @RequestPayload Element myRequest){
return myRequest;
}
}
在寻找解决方案时,我发现它包含在这个答案中
添加...
xmlns:context="http://www.springframework.org/schema/context"
...
xsi:schemaLocation=" ...
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd ... "
<context:component-scan base-package="bar.foo"/>
到我的Spring配置,让servlet找到我的Endpoint
我的问题是,在我找到的spring文档中没有包含示例代码此步骤及其相关性。
实际上我在之前的教程中找到了这个代码片段,但是它有一些我不需要的功能,并且在官方文档中没有解释为什么需要