WSO2 ESB 无法提取 soap 元素值

WSO2 ESB can not extract a soap element value

我无法从以下肥皂信封中获取 clinicID 的值:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms">
      <soapenv:Header/>
      <soapenv:Body>
         <tfom:get_single_inserted_branch_by_id>
            <tfom:clinicID>6048820</tfom:clinicID>
         </tfom:get_single_inserted_branch_by_id>
      </soapenv:Body>
</soapenv:Envelope>

<property xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms"
                   name="CLINIC_ID"
                   expression="//clinicID/text()"
                   scope="axis2"
                   type="STRING"/>

这就是我记录 CLINIC_ID 值的方式:

<log level="custom">
    <property name="1" expression="get-property('CLINIC_ID')"/>
</log>

这是 CLINIC_ID 的值:

1 = null

您可以使用 $body synapse xpath 变量来访问负载的主体。所以对于 属性 中介的表达式将是

$body/tfom:get_single_inserted_branch_by_id/tfom:clinicID/test()

如果您的发送请求格式如下

   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">  
    <soapenv:Header/>  
     <soapenv:Body>  
       <ser:getQuote>  
     <!--Optional:-->  
       <ser:request>  
     <!--Optional:-->  
   <xsd:symbol>wso2</xsd:symbol>  
  </ser:request>  
</ser:getQuote>  


你需要写一个代理

         <property xmlns:m1="http://services.samples/xsd"
               xmlns:m0="http://services.samples"
               name="symbol"
               expression="//m0:getQuote/m0:request/m1:symbol"
               scope="default"
               type="STRING"/>
     <property xmlns:ns="http://org.apache.synapse/xsd"
               name="REST_URL_POSTFIX"
               expression="fn:concat('?symbol=',get-property('symbol1'))"
               scope="axis2"
               type="STRING"/>

详情请参考here or here

您的 xpath 表达式有问题。如果你使用

<property xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms"
                   name="CLINIC_ID"
                   expression="//tfom:clinicID/text()"
                   scope="axis2"
                   type="STRING"/>

应该可以。缺少的部分是表达式中的名称空间前缀。

您可以使用http://www.freeformatter.com/xpath-tester.html

等在线工具试试xpath表达式的准确性

我确实使用过它并且能够将 clinicID 值作为输出。

试试这个方法

<property name="CLINIC_ID" expression="//*[local-name()='clinicID']/text()" type="STRING" scope="default"/>