XFire soap1.2以及默认绑定下的服务发布方式

来源:互联网 发布:淘宝网男凉鞋 编辑:程序博客网 时间:2024/05/17 21:59

利用xfire开发webservice时,在META-INF下的services.xml配置不同绑定的配置方式


1.采用默认绑定方式发布接口的配置:

<?xmlversion="1.0"encoding="UTF-8"?>

<beans>

<!-- http://localhost:8080/IHEWinning/services/HIPMessageService?wsdl -->

<servicexmlns="http://xfire.codehaus.org/config/1.0">

<name>HIPMessageService</name>

<serviceClass>com.ihe.service.IHIPMessageService</serviceClass>

<implementationClass>com.ihe.service.impl.HIPMessageService</implementationClass>

</service>

</beans>

在这种配置下,如果客户端采用http默认方式绑定创建客户端时,可以正常根据wsdl生成客户端接口,并完成接口服务调用。

如果客户端采用soap1.1或者soap1.2绑定方式访问接口则服务器端会报异常信息:

INFO (DefaultFaultHandler.java:39) Fault occurred!
org.codehaus.xfire.fault.XFireFault: Could not find an appropriate Transport Binding to invoke.
at org.codehaus.xfire.handler.LocateBindingHandler.invoke(LocateBindingHandler.java:48)。。。。。。

这是因为服务端端services.xml没有配置soap1.1或者soap1.2绑定。

应该配置如下:


<?xmlversion="1.0"encoding="UTF-8"?>

<beans>

<!-- http://localhost:8080/IHEWinning/services/HIPMessageService?wsdl -->

<servicexmlns="http://xfire.codehaus.org/config/1.0">

<name>HIPMessageService</name>

<serviceClass>com.ihe.service.IHIPMessageService</serviceClass>

<implementationClass>com.ihe.service.impl.HIPMessageService</implementationClass>

<!-- 默认http为true -->

<createDefaultBindings>true</createDefaultBindings>

<bindings>

<!-- SOAP 1.1 -->

<!-- <soap11Binding name="tns:HIPMessageServiceSOAP11Binding" -->

<!-- transport="http://schemas.xmlsoap.org/soap/http" -->

<!-- allowUndefinedEndpoints="true"> -->

<!-- </soap11Binding> -->


<!-- SOAP 1.2 -->

<soap12Bindingname="tns:HIPMessageServiceSOAP12Binding"

transport="http://www.w3.org/2003/05/soap/bindings/HTTP/"

allowUndefinedEndpoints="true">

</soap12Binding>

</bindings>

<!-- <style>document</style> -->

<!-- <use>literal</use> -->

<!-- <scope>application</scope> -->

</service>

</beans>


其中最后注释掉的:

<!--  <style>document</style> -->

<!--  <use>literal</use> -->

<!--  <scope>application</scope> -->

会导致接口方法无法正常在wsdl文件中生成,从而导致客户端访问时,提示服务器找不到对应的服务。
0 0
原创粉丝点击