0

我正在尝试使用 xpath 从传入的 SOAP 请求中提取一个值,但由于某种原因,Mule 不会将其识别为 xml。在这里的代码示例中,我只是想记录信息,我怀疑 Mule 只是将 Mule 消息转换为字符串,这会导致类似 "[B4FEfea"; toString() 的标准输出。并且 xpath 表达式在那个上失败了。

流程本身工作正常,我可以从 SOAP-UI 发送一个请求,并且在没有记录器组件的情况下返回一个响应,但在响应内部我还想添加一部分输入,但失败了。

这是流程:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd 
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd ">
    <mulexml:namespace-manager includeConfigNamespaces="false">  
        <mulexml:namespace prefix="soapenv" uri="http://schemas.xmlsoap.org/soap/envelope/"/>  
        <mulexml:namespace prefix="mob" uri="http://mobistar.be/spellchecker/"/> 
    </mulexml:namespace-manager>

    <flow name="spellcheckerFlow2" doc:name="spellcheckerFlow2" processingStrategy="synchronous">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="spellcheck" contentType="text/xml" doc:name="SOAP Spell check"/>
        <logger message="#[xpath://mob:Text]" level="INFO" doc:name="Logger"/>
        <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="E:\Projects\Mobistar\Mule\spellchecker\src\main\resources\Request2GoogleAPI.xslt" doc:name="XSLT"/>
        <response>
            <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="E:\Projects\Mobistar\Mule\spellchecker\src\main\resources\GoogleAPI2Response.xslt" doc:name="XSLT"/>
        </response>
        <http:outbound-endpoint exchange-pattern="request-response" host="www.google.com" port="80" path="tbproxy/spell?lang=en" contentType="text/xml" doc:name="Google API"/>
    </flow>
</mule>

我发送的请求是这样的:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:spel="http://mobistar.be/spellchecker/">
   <soapenv:Header/>
   <soapenv:Body>
      <spel:CheckSpellingRequest>
         <spel:Text>Please test this blabla</spel:Text>
      </spel:CheckSpellingRequest>
   </soapenv:Body>
</soapenv:Envelope>

我希望你能帮助我。

4

1 回答 1

0

似乎 XPath 不正确,您应该尝试

/soapenv:信封/soapenv:正文/拼写:CheckSpellingRequest/拼写:文本

如果您想存储一个值以供以后使用,您可以使用消息属性:

存储属性:

<message-properties-transformer scope="session">    
<add-message-property key="incomingText"
    value="#[xpath://soapenv:Envelope/soapenv:Body/spel:CheckSpellingRequest/spel:Text]" />
</message-properties-transformer>

读取属性:

<logger message="#[header:session: incomingText]" level="INFO" doc:name="Logger"/>
于 2012-05-27T23:48:43.780 回答