如何使用rich mediator在wso2 esb中添加标题部分

时间:2018-04-09 13:10:52

标签: wso2 wso2esb

这是现有标题

<s:Header>
  <ActivityId xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics" CorrelationId="10018d27-2573-4d6b-8bcb-b49f6c686f1a">5d827c1d-bd7b-437f-904f-5f82c9844022</ActivityId>
 </s:Header>    

我需要使用enrich mediator

在标题部分添加以下安全性
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
     <o:UsernameToken u:Id="uuid-05a278f7-0f00-4710-b81c-4401fd280d6d-3">
        <o:Username>FISEPAY_DEV</o:Username>
        <o:Password>RaDrup5E4awreP</o:Password>
     </o:UsernameToken>
  </o:Security>

所以我需要如何添加使用rich mediator

2 个答案:

答案 0 :(得分:0)

尝试使用以下代码。

   <enrich>
 <source type="inline" clone="true">
            <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <o:UsernameToken u:Id="uuid-05a278f7-0f00-4710-b81c-4401fd280d6d-3">
            <o:Username>FISEPAY_DEV</o:Username>
            <o:Password>RaDrup5E4awreP</o:Password>
         </o:UsernameToken>
      </o:Security>
  </source>
            <target xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
                    xpath="//<s:Header>"/>
         </enrich>
    <log level="full"/>

答案 1 :(得分:0)

使用属性介体,如下所示

    using System;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Windows;


namespace App1 {
    static void Main(string [] args) {
          NamedPipeClientStream client = new NamedPipeClientStream(".", "TestPipe", PipeDirection.InOut);
       while(!client.IsConnected);
       Streamreader reader = new StreamReader(client);
       StreamWriter writer = new StreamWriter(client);
       string line = "";
       writer.AutoFlush = true;
       while((line = reader.readLine()) != null) {
          if(line.Contains("Hello!")  {
            writer.writeLine("1.2.3.4"); // input for the next prompt
          }
          else if(line.Contains("Text1") {
            writer.writeLine("2.3.4.5"); // input for next prompt of Text2
          }
          writer.Flush();
          writer.WaitForPipeDrain();
       }
    }
}

现在这个变量&#34;测试&#34;可以用于富集调解员。

相关问题