Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mule:转换出站端点的结果_Mule_Mule Studio - Fatal编程技术网

Mule:转换出站端点的结果

Mule:转换出站端点的结果,mule,mule-studio,Mule,Mule Studio,下面的流将传入的JSON负载转换为SOAP消息,该消息在子流中用于发出webservice请求。一切正常——我能够为原始(传入)请求发送回响应,但我想添加最后一步,在将SOAP结果发送回客户端之前将其转换为JSON 以下是流程: <mule ...> <data-mapper:config name="json2xml_grf" transformationGraphPath="json2xml.grf" doc:name="DataMapper"/> &

下面的流将传入的JSON负载转换为SOAP消息,该消息在子流中用于发出webservice请求。一切正常——我能够为原始(传入)请求发送回响应,但我想添加最后一步,在将SOAP结果发送回客户端之前将其转换为JSON

以下是流程:

<mule ...>
    <data-mapper:config name="json2xml_grf" transformationGraphPath="json2xml.grf" doc:name="DataMapper"/>
    <flow name="simpleFlow" doc:name="simpleFlow">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
        <set-property propertyName="Access-Control-Allow-Origin" value="*" doc:name="Property"/>
        <choice doc:name="Choice">
            <when expression="#[message.inboundProperties['http.method'] != 'OPTIONS']">
                <data-mapper:transform config-ref="json2xml_grf" doc:name="DataMapper"/>
                <flow-ref name="invokeCalculatorService" doc:name="invokeCalculator"/>
            </when>
            <otherwise>
                <http:response-builder status="200" doc:name="HTTP Response Builder">
                ...
                </http:response-builder>
            </otherwise>
        </choice>
    </flow>
    <flow name="invokeService" doc:name="invokeService">
        <cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="Proxy Client">
        </cxf:proxy-client>
        <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="/Users/jsleeuw/MuleStudio/workspace/calc/src/main/resources/transformsoap.xslt" doc:name="XSLT"/>
        <http:outbound-endpoint exchange-pattern="request-response" doc:name="CalculatorService" method="POST" host="service-host" port="30001"/>
    </flow>
</mule>
而将数据映射器放在子流的末尾会阻塞响应


我应该如何转换我的响应?

prolog中不允许使用
内容,异常情况是
似乎不返回可解析为XML的有效负载

此子流返回一个
org.apache.cxf.staxutils.DepthXMLStreamReader
,它是一个
javax.xml.stream.XMLStreamReader
。据我所知,唯一可以将这种类型反序列化为XML字符串的转换器是:


能否在
数据映射器
元素之前添加一个。。看起来我得到了一个字节数组:。我第一次使用调试器,信不信由你。。方便的酷:)您介意在
数据映射器
元素之前添加
吗?好的,下面是调试器控制台的几个快照。首先显示字节数组到字符串转换器上的断点:,这是我在字节数组到字符串转换器后立即添加的回音上的断点:。仍然没有得到预期的结果,呃:(哦,是的,现在有效负载是一个等于“org.mule.module.cxf…”的字符串,不起作用:“
invokeCalculatorService
流中有什么?问题中没有显示它。哦..invokeCalculatorService的内容与invokeService相同。这是一个非常简单的web服务调用。
...
<flow-ref name="invokeCalculatorService" doc:name="invokeCalculator"/>
<data-mapper:transform config-ref="xml2json_grf" doc:name="DataMapper"/>
...
********************************************************************************
Message               : Error executing graph: ERROR (com.mulesoft.mule.module.datamapper.api.exception.DataMapperExecutionException). Message payload is of type: DepthXMLStreamReader
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Content is not allowed in prolog. (org.xml.sax.SAXParseException)
  org.apache.xerces.util.ErrorHandlerWrapper:-1 (null)
2. org.xml.sax.SAXParseException: Content is not allowed in prolog. (net.sf.saxon.trans.DynamicError)
  net.sf.saxon.event.Sender:308 (null)
3. XPath evaluation failed (org.jetel.exception.JetelRuntimeException)
  org.jetel.component.tree.reader.xml.XmlXPathEvaluator:81 (null)
4. Error executing graph: ERROR (com.mulesoft.mule.module.datamapper.api.exception.DataMapperExecutionException)
  com.mulesoft.mule.module.datamapper.impl.DefaultGraphExecutor:83 (null)
5. Error executing graph: ERROR (com.mulesoft.mule.module.datamapper.api.exception.DataMapperExecutionException). Message payload is of type: DepthXMLStreamReader (com.mulesoft.mule.module.datamapper.processors.DataMapperMessageExecutionException)
  com.mulesoft.mule.module.datamapper.processors.DataMapperMessageProcessor:135 (null)
--------------------------------------------------------------------------------