【发布时间】:2017-04-09 11:37:33
【问题描述】:
我正在尝试通过 spring-ws 创建 SOAP 服务。我已经预先编写了第三方 wsdl,并且我正在通过 jaxb 插件从该 wsdl(合同优先方法)生成代码。
当我构建项目时,spring 将其成功部署在 host/my-app-context/ws/notification 上。
问题 - 当我通过 SOAP UI 发出请求时,我看到了No endpoint mapping found for [SaajSoapMessage {http://other.company.kz/service/}SendMessage]。
注意 1.http://other.company.kz/service 它是给定 wsdl 中的第三方命名空间。 我的ws部署的主机和它不一样
注意 2. wsdl 中唯一的操作是<wsdl:operation name="SendMessage">
我的端点中的 payloadRoot 和 localPart 配置是否应该与第三方包和操作名称相同,或者它们应该与我的主机名/deploy-url 相同?我试过 @PayloadRoot(namespace = NAMESPACE_URI, localPart = "sendMessage") 在哪里NAMESPACE_URI 是我的服务的地址位置(来自 wsdl),我也尝试了来自 wsdl 命名空间(other.company.kz)的 NAMESPACE_URI,但它们都失败了。
我的配置代码看起来像
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean(name = "notification")
public Wsdl11Definition defaultWsdl11Definition() {
SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
wsdl11Definition.setWsdl(new ClassPathResource("notification.wsdl"));
return wsdl11Definition;
}
来自wsdl的引用
<wsdl:binding name="SomeBinding" type="tns0:bla-bla-bla">
<binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SendMessage">
<operation soapAction=""/>
<wsdl:input name="SendMessageRequest">
<body use="literal"/>
</wsdl:input>
<wsdl:output name="SendMessageResponse">
<body use="literal"/>
</wsdl:output>
<wsdl:fault name="sendMessageFault">
<fault name="sendMessageFault" namespace="" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SomeService">
<wsdl:port binding="tns0:SomeBinding" name="SomePort">
<address location="http://myhost/my-app-context/ws/notification"/>
</wsdl:port>
</wsdl:service>
我的终点
@Endpoint
public class MailEndpoint {
private static final String NAMESPACE_URI = "I tried myhost (address location in wsdl) and other-company"
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "sendMessage")
@ResponsePayload
public SyncSendMessageResponse sendMessage(@RequestPayload SyncSendMessageRequest request) {
SyncSendMessageResponse response = new SyncSendMessageResponse();
ResponseData responseData = new ResponseData();
responseData.setResult("sync");
response.setResponseData(responseData);
return response;
}
【问题讨论】:
标签: java spring soap spring-ws