Java 在使用cxf:jaxws客户端时向soap:body添加soap:encodingStyle属性
我正在从mule中的流访问rpc/文字样式的Web服务 wsdl的绑定部分如下所示:Java 在使用cxf:jaxws客户端时向soap:body添加soap:encodingStyle属性,java,soap,jax-ws,cxf,mule,Java,Soap,Jax Ws,Cxf,Mule,我正在从mule中的流访问rpc/文字样式的Web服务 wsdl的绑定部分如下所示: <binding name="AppWebServiceBinding" type="interface:AppWebService"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> <operation name="submitApplication"
<binding name="AppWebServiceBinding" type="interface:AppWebService">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="submitApplication">
<soap:operation soapAction="" style="rpc" />
<input name="submitApplicationRequest" >
<soap:body
encodingStyle="http://xml.apache.org/xml-soap/literalxml"
namespace="http://tempuri.org/fsg.ejb.webservice.AppWebService"
parts="ele" use="literal" type="soap:tBody" />
</input>
<output name="submitApplicationResponse">
<soap:body
encodingStyle="http://xml.apache.org/xml-soap/literalxml"
namespace="http://tempuri.org/fsg.ejb.webservice.AppWebService" use="literal"/>
</output>
</operation>
</binding>
然后,我通过cxf:jaxws客户端将expectedobject传递给http:outbound
<http:outbound-endpoint exchange-pattern="request-response"
address="http://serviceapp:9080/service_war/servlet/rpcrouter"
doc:name="Generic">
<cxf:jaxws-client clientClass="com.fsg.generated.AppWebServiceService"
wsdlLocation="com/fsg/generated/AppWebServiceService.wsdl"
operation="submitApplication" port="AppWebServicePort"
doc:name="SOAP">
<cxf:inInterceptors >
<spring:bean id="inLogger"
class="org.apache.cxf.interceptor.LoggingInInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<spring:bean id="outLogger"
class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
</cxf:outInterceptors>
</cxf:jaxws-client>
</http:outbound-endpoint>
但是当我查看日志以查看发送到出站的消息时,我没有看到其中的soap:encodingStyle属性。这是导致问题的原因,因为没有此选项,服务无法处理消息
下面是我在日志中看到的出站消息
Outbound Message
---------------------------
ID: 1
Address: http://serviceapp:9080/service_war/servlet/rpcrouter
Encoding: UTF-8
Content-Type: text/xml
Headers: {SOAPAction=[""]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header>
<mule:header xmlns:mule="http://www.muleumo.org/providers/soap/1.0">
<mule:MULE_CORRELATION_ID>dfd31e6c-6575-11e2-9b8a-b1b06bd39882</mule:MULE_CORRELATION_ID> <mule:MULE_CORRELATION_GROUP_SIZE>-1</mule:MULE_CORRELATION_GROUP_SIZE>
<mule:MULE_CORRELATION_SEQUENCE>-1</mule:MULE_CORRELATION_SEQUENCE>
</mule:header>
</soap:Header>
<soap:Body>
<ns1:submitApplication xmlns:ns1="http://tempuri.org/fsg.ejb.webservice.AppWebService">
<ele>
<MyApp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://mysample.org">
<UserAuth> ............
出站消息
---------------------------
身份证号码:1
地址:http://serviceapp:9080/service_war/servlet/rpcrouter
编码:UTF-8
内容类型:text/xml
标题:{SOAPAction=[“”]}
有效载荷:
dfd31e6c-6575-11e2-9b8a-b1b06bd39882-1
-1
............
可以看出,名称空间是从wsdl中选取的,而不是编码样式
预期产量为
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header>
<mule:header xmlns:mule="http://www.muleumo.org/providers/soap/1.0">
.......
</mule:header>
</soap:Header>
<soap:Body>
<ns1:submitApplication xmlns:ns1="http://tempuri.org/fsg.ejb.webservice.AppWebService" soap:encodingStyle="http://xml.apache.org/xml-soap/literalxml" >
<ele>
<MyApp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://mysample.org">
<UserAuth> ............
.......
............
如何在此设置soap:encodingStyle属性?我认为您的问题是encodingStyle属性信息不能出现在body元素中,只能出现在子元素中。我可以看出它不起作用。
可能您可以尝试使用XSLT转换器将编码样式添加到输入中,然后对其进行处理。这只是一个解决方法。不确定这是否有助于您的案例,但您可以尝试以下方法;拉什,我试过这个。但是运气不好(很抱歉听到这个消息。建议按以下方式使用on mule文档。我不确定您是否已经这样尝试过。我也这样尝试过。我甚至尝试过使用不同的作用域。但它没有显示在出站消息中。您希望您的输出是什么样的?我可以看到名称空间被选中了。)d正确地显示在body标签中。但是编码样式没有显示。知道如何解决这个问题吗?目前我已经用这种方式实现了。正在寻找一个直接的解决方案。