CXF-CODEGEN生成的客户端需要在SOAP信封
的CXF生成客户端发送以下SOAP请求不从他们身边返回记录的命名空间:CXF-CODEGEN生成的客户端需要在SOAP信封
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<PersonSearch xmlns="http://tlo.com/">
<genericSearchInput>
....
</genericSearchInput>
</PersonSearch>
</soap:Body>
</soap:Envelope>
soapUI的请求如下所示,并没有返回记录:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tlo="http://tlo.com/">
<soapenv:Header/>
<soapenv:Body>
<tlo:PersonSearch>
<!--Optional:-->
<tlo:genericSearchInput>
...
</tlo:genericSearchInput>
</tlo:PersonSearch>
</soapenv:Body>
</soapenv:Envelope>
我看到的唯一区别是,而不是在SOAP信封的命名空间声明和使用命名空间前缀的默认命名空间声明。我尝试了几种不同的方法来让CXF生成的客户端创建相同类型的soap请求。任何人都可以提供一些指针,或者我需要使用其他的东西吗?
我使用org.apache.cxf:CXF-CODEGEN-插件:2.5.2在JDK 6
你使用JAXB数据绑定?我能够通过使用XMLBEANS来解决相同的问题。见DB标志的WSDL2Java:http://cxf.apache.org/docs/wsdl-to-java.html
我仍然在寻找的不仅仅是改变绑定一个更好的解决方案。
更新20012-04-18:布林和阿贵从CXF用户邮件列表是如此客气告诉我CXF的TransformationFeature。在客户端使用以下代码适用于我:
MyService myService = new MyService();
myPort = myService.getMyServiceHttpSoap11Endpoint();
// See http://cxf.apache.org/docs/transformationfeature.html
Client client = ClientProxy.getClient(myPort);
Map<String, String> outTransformMap = Collections.singletonMap(
"{http://myNamespace}*",
"{http://myNamespace}*");
org.apache.cxf.interceptor.transform.TransformOutInterceptor transformOutInterceptor =
new org.apache.cxf.interceptor.transform.TransformOutInterceptor();
transformOutInterceptor.setOutTransformElements(outTransformMap);
client.getOutInterceptors().add(transformOutInterceptor);
我将此与CXF 2.5.2配合使用。根据Aki的2.5.3和2.5.6,你必须使用defaultNamespace属性。
你能帮助我在这个问题上,http://*.com/questions/31181207/how-can-i-add-namespace-decalarations-in-soap-envelope – 2015-07-02 10:09:16
两者都是正确的方式做SOAP消息,但一些服务显然解释很奇怪的方式SOAP标准。他们显然似乎想要通过纯粹的字符串操作去除信封,而这种操作是非常错误的。什么服务框架在做服务器端绑定? – 2012-04-17 14:09:38