在用cxf 做webservice客户端的时候碰到的:
javax.xml.ws.soap.SOAPFaultException: A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.
在网上上找了一些资料但是还是不能解决我的问题,但是还是要感谢下, 不然太不厚道了
写道
看来是soap协议不匹配
在接口或实现类上声明
@BindingType(value = "http://www.w3.org/2003/05/soap/bindings/HTTP/")
或者
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
注意要引入geronimo-jaxws_2.2_spec-1.0.jar包
生成的wsdl文件我们可以看到
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/
在这些前提下 依然返回 同样的错误
于是我试着找源码,发现原来是这里 version 默认的就是 Soap11 instance 。
if (soapVersion == Soap12.getInstance()
&& version == Soap11.getInstance()) {
throw new SoapFault(new Message("INVALID_11_VERSION", LOG, ns, xmlReader.getLocalName()),
Soap11.getInstance().getVersionMismatch());
}
回头看看CXF 在初始化的是否可以将 Soap12 设置进去 , ok 。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="jaxWsProxyFatory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="bindingId" value="http://www.w3.org/2003/05/soap/bindings/HTTP/" />
<property name="serviceClass" value="net.carefx.cds.v1.services.core.CdsCoreServices" />
<property name="address" value="http://localhost:8181/cxf/coreServices" />
</bean>
<bean id="soapSerivces" class="net.carefx.cds.testtool.proxy.SoapServices">
<property name="factory" ref="jaxWsProxyFatory" />
</bean>
</beans>
public class SoapServices
{
private static final Logger logger = new Logger (SoapServices.class.getName ());
private JaxWsProxyFactoryBean m_factory;
private CdsCoreServices cdsCoreServices;
public JaxWsProxyFactoryBean getFactory ()
{
return m_factory;
}
public void setFactory (JaxWsProxyFactoryBean factory)
{
m_factory = factory;
}
public CdsCoreServices getCdsCoreServices ()
{
if (cdsCoreServices == null)
{
cdsCoreServices = (CdsCoreServices) m_factory.create ();
}
return cdsCoreServices;
}
}
将 bindingId 设置进去就可以了 告诉 cxf 需要用 Soap12 获取返回数据。搞定。
分享到:
相关推荐
CXF SOAP 应用实例
cxf soap header cxf soap header cxf soap header cxf soap header
CXF soap例子源码
用于使用CXF打印SOAP报文,记录WebService日志~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
通过CXF添加soap头验证,亲测可用。。。。。。
Soap1.1和soap1.2区别: 跟踪soap协议 综合案例: 使用webservice传输xml数据(重点掌握) 第二天: Jaxws的深入开发: 常用注解 测试jaxws传输复杂对象类型 CXF开发webservice: CXF入门程序 Spring+...
赠送jar包:cxf-rt-bindings-soap-3.0.1.jar; 赠送原API文档:cxf-rt-bindings-soap-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-bindings-soap-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-bindings-soap-...
<import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
NULL 博文链接:https://huiseyiyu.iteye.com/blog/1172161
Spring+CXF+Maven+SOAP方式搭建WebService服务端demo测试用例
NULL 博文链接:https://mljavalife.iteye.com/blog/1388766
启动后访问http://localhost:8080/cxf-ws-restful-spring-server/ws63
neethi-2.0.1.jar xml-resolver-1.2.jar XmlSchema-1.1.jar
CXF整合spring实现SOAP接口开发
rest soap cxf webservice maven springmvc
基于Soap协议下CXF框架开发Webservice
基于 cxf 2.7.5 开发的 webservice [soap restful]
以前做java的初步理解了下...实现了3个接口服务,1个接口服务端提供登录是用的传统webservice,用的cxf。1个接口只是测试,测试了双向json数据传输解析。还一个接口是网络上提供的手机归属地查询,实现了它的接口。
使用JAX-WS RI和JAXB的Apache CXF和SpringBoot的SOAP-Webservices-仅注释,绝对没有XML 作为Example SOAP-Service,我做了一些研究,但是毕竟(或因为?)几乎所有教程都使用了众所周知的 ,它是最好的用例。 在...