SOAP1.1 and SOAP1.2

在用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 。 
Java代码   收藏代码
  1. if (soapVersion == Soap12.getInstance()  
  2.     && version == Soap11.getInstance()) {  
  3.     throw new SoapFault(new Message("INVALID_11_VERSION", LOG, ns, xmlReader.getLocalName()),  
  4.                         Soap11.getInstance().getVersionMismatch());                      
  5. }  
 
回头看看CXF 在初始化的是否可以将 Soap12 设置进去 , ok 。
Java代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="  
  5.           http://www.springframework.org/schema/beans   
  6.           http://www.springframework.org/schema/beans/spring-beans.xsd  
  7.           http://cxf.apache.org/jaxws   
  8.           http://cxf.apache.org/schemas/jaxws.xsd">  
  9.               
  10.     <bean id="jaxWsProxyFatory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">  
  11.         <property name="bindingId" value="http://www.w3.org/2003/05/soap/bindings/HTTP/" />  
  12.         <property name="serviceClass" value="net.carefx.cds.v1.services.core.CdsCoreServices" />  
  13.         <property name="address" value="http://localhost:8181/cxf/coreServices" />  
  14.     </bean>  
  15.   
  16.     <bean id="soapSerivces" class="net.carefx.cds.testtool.proxy.SoapServices">  
  17.         <property name="factory" ref="jaxWsProxyFatory" />  
  18.     </bean>  
  19.       
  20. </beans>    
 
 
Java代码   收藏代码
  1. <span style="font-weight: normal;">  
  2. public class SoapServices  
  3. {  
  4.   
  5.     private static final Logger logger = new Logger (SoapServices.class.getName ());  
  6.   
  7.     private JaxWsProxyFactoryBean m_factory;  
  8.   
  9.     private CdsCoreServices cdsCoreServices;  
  10.   
  11.     public JaxWsProxyFactoryBean getFactory ()  
  12.     {  
  13.         return m_factory;  
  14.     }  
  15.   
  16.     public void setFactory (JaxWsProxyFactoryBean factory)  
  17.     {  
  18.         m_factory = factory;  
  19.     }  
  20.   
  21.     public CdsCoreServices getCdsCoreServices ()  
  22.     {  
  23.         if (cdsCoreServices == null)  
  24.         {  
  25.             cdsCoreServices = (CdsCoreServices) m_factory.create ();  
  26.         }  
  27.         return cdsCoreServices;  
  28.     }  
  29.   
  30.       
  31. }</span>  
 
---------------------------------------------------------------------------------------------------------------------------------------------------------------

C# java JAX-WS 问题

webservices 是java写的,用 JDK自带的EndPoint发布,客户端是用C#调用,

在服务器端抛出异常,尽管执行是正常的。

Unsupported Content-Type: application/soap+xml;charset=UTF-8 Supported ones are: [text/xml]

请问这是什么问题? 怎么解决呢? Google 了半天也没找到答案

----------------------

经试验,是C#生成客户端的过程中抛出的,用wsimport 没问题。 是soap版本的问题? 

 

这个问题是解决了, 确实版本问题, jdk6默认是soap1.1

增加 @BindingType("http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/")

高亮的地址真是难找,SOAPBinding 里面定义的是 http://www.w3.org/2003/05/soap/bindings/HTTP/, 但不能用,提示找不到

 ----------------------------------------------------------------------------------------------------------------------------------------------------
I think, I set everything to SOAP 1.2. I have attached a sevrver-client
communication, my WSDL and here is also my sun-jaxws.xml:
<?xml
version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns=" http://java.sun.com/xml/ns/jax-ws/ri/runtime">
 
<endpoint
  name="FormDataService"
 
implementation="de.bolsys.netcon.gatewaydb.wsdl.DefaultFormDataService"
 
wsdl="WEB-INF/wsdl/netgateway.wsdl"
  binding=" http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"

  url-pattern="/FormDataService"
  enable-mtom="true"/>

</endpoints>

My service annotations:
@WebService(name =
"formDataPortType", targetNamespace = " http://bolsys.de/netcon/gatewaydb/wsdl")

@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)

@BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_MTOM_BINDING)

@XmlSeeAlso({
    ObjectFactory.class
})

My client
annotations:
@WebServiceClient(name = "FormDataService", targetNamespace =
" http://bolsys.de/netcon/gatewaydb/wsdl")

Did I
forget anything?
[Message sent by forum member 'radovana' (radovana)]
-------------------------------------------------------------------------------------------------------------------------------------
I have same problem with one of my web services. Here is the solution

It
is because your wsdl using soap11 binding, you can either change the binding to
soap12
like this " xmlns:soapbind=" http://schemas.xmlsoap.org/wsdl/soap12/"

or simply
remove binding=" http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"
from your deploy descriptor

 

你可能感兴趣的:(SOAP)