mule java.lang.reflect.Method无法强制转换为java.lang.String(java.lang.ClassCastException)

时间:2014-03-07 14:27:47

标签: mule

使用代理客户端将XML发送到Web服务时出现错误。这是配置:

<flow name="CreateDIMEntry" doc:name="CreateDIMEntry">
    <vm:outbound-endpoint exchange-pattern="one-way" path="DIM_VM" doc:name="VM"/>
    <byte-array-to-string-transformer doc:name="Byte Array to String"/>
    <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="D:\Users\vkamat\Desktop\dim\src\main\resources\addenvelopetopayload.xsl" doc:name="XSLT"/>
    <byte-array-to-string-transformer doc:name="Byte Array to String"/>
    <logger message="I am here..#[message.payload]" level="INFO" doc:name="Logger"/>
    <set-property propertyName="SOAPAction" value="urn:com.org.ProcessActivity" doc:name="Property"/>

    <set-property propertyName="Content-Type" value="application/soap+xml" doc:name="Property"/>
    <!--  <set-property propertyName="SOAPAction" value="urn:com.org.ProcessActivity" doc:name="Property"/> -->
    <cxf:proxy-client doc:name="SOAP" payload="envelope">

    </cxf:proxy-client >

    <http:outbound-endpoint exchange-pattern="request-response" host="${dim.host}" port="${dim.port}" method="POST" doc:name="HTTP" path="${dim.path}">
    </http:outbound-endpoint>
</flow>

当使用如下测试流程调用此流程时,它可以正常工作

<flow name="DimFlow1" doc:name="DimFlow1">
    <file:inbound-endpoint path="D:\Documents\test" responseTimeout="10000" doc:name="File"/>
    <flow-ref name="CreateDIMEntry" doc:name="Flow Reference"/>
</flow>

但是当集成到另一个流程中时,它会产生一个错误,从主要流程中获取主要流的片段

<async doc:name="Async">
    <mulexml:object-to-xml-transformer doc:name="Object to XML"/>
    <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="D:\addenvelopetopayload.xsl" doc:name="XSLT"/>

    <logger message="before DIM-- #[message.payload]" level="INFO" doc:name="Logger"/>
    <flow-ref name="CreateDIMEntry" doc:name="Flow Reference"/>
</async>

遇到的错误是

********************************************************************************
Message               : java.lang.reflect.Method cannot be cast to java.lang.String. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ReversibleXMLStreamReader
--------------------------------------------------------------------------------
Exception stack is:
1. java.lang.reflect.Method cannot be cast to java.lang.String (java.lang.ClassCastException)
  org.mule.module.cxf.CxfOutboundMessageProcessor:338 (null)
2. java.lang.reflect.Method cannot be cast to java.lang.String. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ReversibleXMLStreamReader (org.mule.api.transport.DispatchException)
  org.mule.module.cxf.CxfOutboundMessageProcessor:150 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.ClassCastException: java.lang.reflect.Method cannot be cast to java.lang.String
  at org.mule.module.cxf.CxfOutboundMessageProcessor.getMethodOrOperationName(CxfOutboundMessageProcessor.java:338)
  at org.mule.module.cxf.CxfOutboundMessageProcessor.getOperation(CxfOutboundMessageProcessor.java:356)
  at org.mule.module.cxf.CxfOutboundMessageProcessor.doSendWithClient(CxfOutboundMessageProcessor.java:212)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

1 个答案:

答案 0 :(得分:0)

尝试在CXF客户端之前设置以下内容:

<set-variable value="#[flowVars['cxf_operation'].getLocalPart()]" variableName="operation" />