繁体   English   中英

在WSO2序列或代理中添加头中介

[英]Adding header mediator in WSO2 sequence or proxy

我正在尝试为序列添加自定义soap标头,但是eclipse设计视图不喜欢它并且不会让我保存它。

我想在“标题标记”下添加以下代码(使用标题介体)

<p1:Header xmlns:p1="http://www.XYZ.com/XSD"> 
                    <Version>1.5</nVersion> 
                    <Code>XYZ</Code> 
                    <Type>ABC</Type> 
                    <Ver>1.1/1.2</Ver> 
                    <Org>DIS</Org> 
</p1:Header>

我知道标头中介语法是“header name =”xyz“action =”“value =”“但我想构建这个自定义标题作为对请求的响应。非常感谢任何帮助。非常感谢你的时间和精力。

您可以使用Header Mediator为SOAP Header指定自己的XML。 从ESB 4.5.0开始支持此功能。

只需在<header>指定自定义标<header>

您可以使用源视图或用户界面来定义代理。 如果您正在尝试Eclipse,它可能不支持这个新功能。 我必须检查一下。

但您可以使用独立的ESB产品定义代理。

这是我刚刚使用WSO2 ESB 4.6.0测试的示例代理。

<proxy name="Test"
      transports="https http"
      startOnLoad="true"
      trace="disable">
  <target>
     <inSequence>
        <header>
           <p1:Header xmlns:p1="http://www.XYZ.com/XSD">
              <p1:Version>1.5</p1:Version>
              <p1:Code>XYZ</p1:Code>
              <p1:Type>ABC</p1:Type>
              <p1:Ver>1.1/1.2</p1:Ver>
              <p1:Org>DIS</p1:Org>
           </p1:Header>
        </header>
        <send>
           <endpoint>
              <address uri="http://localhost:8899/services/SimpleStockQuoteService?wsdl"/>
           </endpoint>
        </send>
     </inSequence>
     <outSequence>
        <header>
           <p2:Header xmlns:p2="http://www.ABC.com/XSD">
              <p2:Hello>World</p2:Hello>
           </p2:Header>
        </header>
        <send/>
     </outSequence>
  </target>
  <publishWSDL uri="http://localhost:8899/services/SimpleStockQuoteService?wsdl"/>
</proxy>

以下是从WSO2 ESB发送请求并返回响应的方式

请求:

POST /services/SimpleStockQuoteService?wsdl HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml; charset=UTF-8
SOAPAction: "urn:getQuote"
userAgent: Synapse-PT-HttpComponents-NIO
Transfer-Encoding: chunked
Host: 127.0.0.1:8899
Connection: Keep-Alive

2f3
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://services.samples/xsd" xmlns:ser="http://services.samples">
   <soapenv:Header><p1:Header xmlns:p1="http://www.XYZ.com/XSD">
              <p1:Version>1.5</p1:Version>
              <p1:Code>XYZ</p1:Code>
              <p1:Type>ABC</p1:Type>
              <p1:Ver>1.1/1.2</p1:Ver>
              <p1:Org>DIS</p1:Org>
           </p1:Header></soapenv:Header>
   <soapenv:Body>
      <ser:getQuote>
     <!--Optional:-->
     <ser:request>
        <!--Optional:-->
        <xsd:symbol>WSO2</xsd:symbol>
     </ser:request>
      </ser:getQuote>
   </soapenv:Body>
</soapenv:Envelope>
0

响应:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header>
      <p2:Header xmlns:p2="http://www.ABC.com/XSD">
     <p2:Hello>World</p2:Hello>
      </p2:Header>
   </soapenv:Header>
   <soapenv:Body>
      <ns:getQuoteResponse xmlns:ns="http://services.samples">
     <ns:return xsi:type="ax21:GetQuoteResponse" xmlns:ax21="http://services.samples/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <ax21:change>4.14429919417878</ax21:change>
        <ax21:earnings>13.29119739059685</ax21:earnings>
        <ax21:high>-84.84231581484899</ax21:high>
        <ax21:last>85.60273864169663</ax21:last>
        <ax21:lastTradeTimestamp>Sun Jul 28 00:31:19 IST 2013</ax21:lastTradeTimestamp>
        <ax21:low>88.1046394678485</ax21:low>
        <ax21:marketCap>-6540210.216549877</ax21:marketCap>
        <ax21:name>WSO2 Company</ax21:name>
        <ax21:open>89.52770935798549</ax21:open>
        <ax21:peRatio>24.07637499909879</ax21:peRatio>
        <ax21:percentageChange>-5.198506483420408</ax21:percentageChange>
        <ax21:prevClose>-79.72095845982282</ax21:prevClose>
        <ax21:symbol>WSO2</ax21:symbol>
        <ax21:volume>9801</ax21:volume>
     </ns:return>
      </ns:getQuoteResponse>
   </soapenv:Body>
</soapenv:Envelope>

请注意<header>标记中的值。

我希望这有帮助。

谢谢!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM