XMLStreamReader解析器影响MuleEventContext

XMLStreamReader解析器影响MuleEventContext,mule,xmlstreamreader,Mule,Xmlstreamreader,我正在使用Mule Studio(Mule 3.2.1CE)配置一个代理服务,该服务只调用远程web服务。通过调用并获得正确的响应(使用soapUI),一切都很好。我想记录ESB中接收到的SOAP消息。正如CXF组件所期望的那样,我得到了一条DepthXMLStreamReader消息,但是当我使用XMLStreamReader对象的next()方法时,我遇到了一个奇怪的行为。以下是我使用的代码: public Object onCall(MuleEventContext context) th

我正在使用Mule Studio(Mule 3.2.1CE)配置一个代理服务,该服务只调用远程web服务。通过调用并获得正确的响应(使用soapUI),一切都很好。我想记录ESB中接收到的SOAP消息。正如CXF组件所期望的那样,我得到了一条DepthXMLStreamReader消息,但是当我使用XMLStreamReader对象的next()方法时,我遇到了一个奇怪的行为。以下是我使用的代码:

public Object onCall(MuleEventContext context) throws Exception {
    MuleMessage message = context.getMessage();
    DepthXMLStreamReader streamReader = new DepthXMLStreamReader((XMLStreamReader) message.getPayload());

    while(streamReader.hasNext()){
                streamReader.next();
                if(streamReader.getEventType() == XMLStreamReader.START_ELEMENT)
                {
                    System.out.println(streamReader.getLocalName());
                }
            }
    return context.getMessageAsString();
上面的代码可以工作并打印XML元素,但之后出现以下错误:

 org.apache.cxf.interceptor.Fault: Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=..., connector=HttpConnector
...
    Caused by: org.mule.transport.http.HttpResponseException: Internal Server Error, code: 500
我尝试使用StaxUtils.nextEvent和StaxUtils.toNextElement,但结果没有差异。我想知道为什么用next()方法解析XML会影响mule上下文。如果我使用System.out.println(context.getMessageAsString());在返回语句之前,它打印“[Messaage无法转换为字符串]”,但在上述代码中,它在while语句之前工作

这是我的mule配置:

<flow name="wsFlow1" doc:name="wsFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" contentType="text/xml" doc:name="HTTP"/>
    <cxf:proxy-service bindingId="..." namespace="http://..." service="..." payload="body" wsdlLocation="..." enableMuleSoapHeaders="false" doc:name="SOAP"/>
    <component class="mule.ws.SoapLogging" doc:name="Java"/>
    <http:outbound-endpoint exchange-pattern="request-response" address="http://..." contentType="text/xml" doc:name="HTTP"/>
</flow>


谢谢

我认为这与MuleEventContext无关

飞行中的有效载荷是XMLStreamReader。您在组件中使用这个XMLStreamReader,然后尝试返回它的字符串表示形式,这是不可能的,因为您已经使用了它

在组件中尝试以下操作:

  • 将XMLStreamReader序列化为字符串
  • 记录此字符串或其一部分
  • 从组件返回此字符串