【问题标题】:SOAP mediation Wso2 ESBSOAP 中介 Wso2 ESB
【发布时间】:2012-08-31 03:10:47
【问题描述】:

您好,我收到以下消息:

 <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
      <soapenv:Header>
         <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="true">
            <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-11">
               <wsu:Created>2012-09-06T09:59:04.031Z</wsu:Created>
               <wsu:Expires>2012-09-06T10:04:04.031Z</wsu:Expires>
            </wsu:Timestamp>
            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-12">
               <wsse:Username>admin</wsse:Username>
               <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</wsse:Password>
            </wsse:UsernameToken>
         </wsse:Security>
      </soapenv:Header>
      <soapenv:Body />
   </soapenv:Envelope>

我想使用 XPath 从传入消息中获取用户名 &lt;wsse:Username&gt;admin&lt;/wsse:Username&gt;

有什么建议吗?

编辑:

我试过了:

<inSequence xmlns="http://ws.apache.org/ns/synapse">
   <property xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" name="p1" expression="$header/wsse:Username" scope="default" />
   <log>
      <property name="output*********" expression="get-property('p1')" />
   </log>
</inSequence>

但它不输出用户名:

MessageID: urn:uuid:68f95493-7dfd-416a-b
455-f77f4fd5c9c5, Direction: request, output********* =

【问题讨论】:

  • 在您的情况下,它应该是“$header/wsse:Security/wsse:UsernameToken/wsse:Username”。这是一个 XPath 语句,在检索 xml 节点的值时正在此处评估

标签: soap xpath wso2 wso2esb orchestration


【解决方案1】:

否则你可以选择使用这个xpath:"//wsse:Username/text()" 我认为它会对你有所帮助我也是这个wso2 工具的新手。

希望这能带你..

【讨论】:

    【解决方案2】:

    努维奥,

    您可以使用表达式“$header/wsse:Security”,其中“wsse”作为 Security 标头元素携带的命名空间的前缀。下面显示了如何将其保存到 Synapse 消息上下文属性。

    <property xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" name="Security" expression="$header/wsse:Security" />
    

    仅供参考,您可以使用语法“$header/header_name”来提取 SOAP 消息中存在的任何 SOAP 标头元素。

    希望这会有所帮助!

    干杯, 普拉巴斯

    【讨论】:

    • 所以在我的情况下应该是这样的: $header/wsse:Username ?
    • 在您的情况下,它应该是“$header/wsse:Security/wsse:UsernameToken/wsse:Username”。这是一个 XPath 语句,在检索 xml 节点的值时在此处进行评估。
    猜你喜欢
    • 2012-08-08
    • 1970-01-01
    • 2012-08-31
    • 1970-01-01
    • 1970-01-01
    • 2012-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多