gpt4 book ai didi

java - Mule TransformerException : An invalid return type "class [B" was specified for transformer "JAXBMarshallerTransformer"

转载 作者:行者123 更新时间:2023-11-30 08:11:03 26 4
gpt4 key购买 nike

我正在使用 Mule CXF 组件从本地主机调用 Web 服务。被调用的Web服务返回一个SoapResult类型的对象,但Mule在转换它时,检测到返回类型为“[B”。最后,选择了 JAXBMarshallerTransformer,并且转换因以下堆栈而失败:

org.mule.api.transformer.TransformerException: An invalid return type "class [B" was specified for transformer "JAXBMarshallerTransformer"
at org.mule.module.xml.transformer.jaxb.JAXBMarshallerTransformer.doTransform(JAXBMarshallerTransformer.java:119)
at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:420)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:377)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

我的 Mule 流程:

<http:listener-config name="HTTP_Listener_Configuration_2" host="0.0.0.0" port="5556" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="localhost" port="6543" basePath="ws" doc:name="HTTP Request Configuration"/>
<mulexml:jaxb-context name="JAXB_Context" packageNames="soap.cxf.helloworld" doc:name="JAXB Context"/>
<flow name="helloworldsoapFlow">
<http:listener config-ref="HTTP_Listener_Configuration_2" path="/hello" doc:name="HTTP"/>
<set-payload value="#[{&quot;David&quot;,&quot;Rose&quot;}]" doc:name="Set Payload"/>
<cxf:jaxws-client operation="getHelloWorld" serviceClass="soap.cxf.helloworld.IHelloWorld" doc:name="helloWorldSoap"/>
<http:request config-ref="HTTP_Request_Configuration" path="hello" method="POST" doc:name="HTTP"/>
<logger level="INFO" doc:name="Logger" message="#[payload]"/>
</flow>

我的 WSDL:

<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://cxfsoapservice.iais.ir/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://cxfsoapservice.iais.ir/" name="HelloWorldService">
<types>
<xsd:schema>
<xsd:import namespace="http://cxfsoapservice.iais.ir/" schemaLocation="http://localhost:6543/ws/hello?xsd=1"/>
</xsd:schema>
</types>
<message name="getHelloWorld">
<part name="name1" type="xsd:string"/>
<part name="name2" type="xsd:string"/>
</message>
<message name="getHelloWorldResponse">
<part name="return" type="tns:soapResult"/>
</message>
<portType name="IHelloWorld">
<operation name="getHelloWorld" parameterOrder="name1 name2">
<input wsam:Action="http://cxfsoapservice.iais.ir/IHelloWorld/getHelloWorldRequest" message="tns:getHelloWorld"/>
<output wsam:Action="http://cxfsoapservice.iais.ir/IHelloWorld/getHelloWorldResponse" message="tns:getHelloWorldResponse"/>
</operation>
</portType>
<binding name="HelloWorldPortBinding" type="tns:IHelloWorld">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="getHelloWorld">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://cxfsoapservice.iais.ir/"/>
</input>
<output>
<soap:body use="literal" namespace="http://cxfsoapservice.iais.ir/"/>
</output>
</operation>
</binding>
<service name="HelloWorldService">
<port name="HelloWorldPort" binding="tns:HelloWorldPortBinding">
<soap:address location="http://localhost:6543/ws/hello"/>
</port>
</service>
</definitions>

我的 XSD:

<xs:schema xmlns:tns="http://cxfsoapservice.iais.ir/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://cxfsoapservice.iais.ir/">
<xs:element name="soapResult" type="tns:soapResult"/>
<xs:complexType name="soapResult">
<xs:sequence>
<xs:element name="names" type="xs:string" minOccurs="0"/>
<xs:element name="message" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

我的 Mule Flow 图像:

enter image description here

最佳答案

datamapper 转换器仅在企业版中可用,您也可以使用 <mulexml:object-to-xml-transformer doc:name="Object to XML"/>将您的对象转换为 XML。

关于java - Mule TransformerException : An invalid return type "class [B" was specified for transformer "JAXBMarshallerTransformer",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30387759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com