Validation 如何在Mule中使用is-xml过滤器验证SOAP请求

Validation 如何在Mule中使用is-xml过滤器验证SOAP请求,validation,soap,mule,mule-studio,Validation,Soap,Mule,Mule Studio,我有一个主流程,它公开了一个Web服务:- <flow name="ServiceFlow" doc:name="ServiceFlow"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/> <cxf:jaxws-service serviceClass="com.te

我有一个主流程,它公开了一个Web服务:-

<flow name="ServiceFlow" doc:name="ServiceFlow">

<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>

<cxf:jaxws-service  serviceClass="com.test.services.schema.maindata.v1.MainData"  doc:name="SOAP"/>

<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl"/>

</flow>
以及以下SOAP响应:-

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>Couldn't parse stream.</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

soap:服务器
无法分析流。

请帮忙。。。如何使用
验证SOAP请求,以及异常对于有效的SOAP请求意味着什么?

问题在于过滤器消耗流,因此cxf代理服务没有任何数据可处理

在筛选器之前向字符串转换器添加一个对象,以将请求加载到内存中。然后,它可以被cxf代理服务重新读取

大概是这样的:

<http:inbound-endpoint exchange-pattern="request-response"
            host="localhost" port="8086" path="proxy/mainData" doc:name="HTTP" />

    <!-- Transform to String so we can reread the payload multiple times -->
    <object-to-string-transformer />
    <!-- This is for SOAP Request validation -->
    <message-filter  onUnaccepted="ValidationFailFlow" doc:name="filter to validate xml against xsd" throwOnUnaccepted="true" >
     <mulexml:is-xml-filter /> 
    </message-filter>
    <!-- ends -->

java.lang.RuntimeException: Couldn't parse stream.
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1262)
    at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:105)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
    at org.mule.module.cxf.CxfInboundMessageProcessor.sendToDestination(CxfInboundMessageProcessor.java:338)
    at org.mule.module.cxf.CxfInboundMessageProcessor.process(CxfInboundMessageProcessor.java:144)
    at org.mule.module.cxf.config.FlowConfiguringMessageProcessor.process(FlowConfiguringMessageProcessor.java:48)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)

Caused by: com.ctc.wstx.exc.WstxIOException: Attempted read from closed stream.
    at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:536)
    at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:585)
    at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:610)
    at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:316)
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1260)
    ... 97 more
Caused by: java.io.IOException: Attempted read from closed stream.
    at org.apache.commons.httpclient.ContentLengthInputStream.read(ContentLengthInputStream.java:160)
    at com.ctc.wstx.io.BaseReader.readBytes(BaseReader.java:155)
    at com.ctc.wstx.io.UTF8Reader.loadMore(UTF8Reader.java:368)
    at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:111)
    at com.ctc.wstx.io.ReaderBootstrapper.initialLoad(ReaderBootstrapper.java:250)
    at com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.java:133)
    at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:531)
    ... 101 more
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>Couldn't parse stream.</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>
<http:inbound-endpoint exchange-pattern="request-response"
            host="localhost" port="8086" path="proxy/mainData" doc:name="HTTP" />

    <!-- Transform to String so we can reread the payload multiple times -->
    <object-to-string-transformer />
    <!-- This is for SOAP Request validation -->
    <message-filter  onUnaccepted="ValidationFailFlow" doc:name="filter to validate xml against xsd" throwOnUnaccepted="true" >
     <mulexml:is-xml-filter /> 
    </message-filter>
    <!-- ends -->