reading soap header element in payload

偶尔善良 提交于 2019-12-13 20:51:57

问题


I need to read contents of wsse:Username(which is part of soap header) from following soap payload in mule using message-properties-transformer. I would like to use this variable somewhere else.

Soap Webservice request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:spel="http://mobistar.be/spellchecker/">
   <soapenv:Header> 
      <wsse:Security soapenv:mustUnderstand="1" >
         <wsse:UsernameToken wsu:Id="UsernameToken-1">
           <wsse:Username>Tester01</wsse:Username>
         </wsse:UsernameToken>
       </wsse:Security>
   </soapenv:Header> 
   <soapenv:Body>
     <spel:CheckSpellingRequest>
        <spel:Text>Please test this blabla</spel:Text>
      </spel:CheckSpellingRequest>
   </soapenv:Body>
</soapenv:Envelope>

Please let me know if we can achieve this in mule?


回答1:


  • Declare the "soapenv" and "wsse" namespaces in Mule's namespace manager: http://www.mulesoft.org/documentation/display/current/XML+Namespaces
  • Use XPath in a MEL expression to extract the value(s) you need: http://www.mulesoft.org/documentation/display/current/MEL+Cheat+Sheet#MELCheatSheet-XPathSupport

Also use set-variable, set-session-variable or set-property instead of the old message-properties-transformer.



来源:https://stackoverflow.com/questions/17201528/reading-soap-header-element-in-payload

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!