WSO2 ESB代理服务outSequence转换无法正常运行

时间:2014-04-10 04:47:11

标签: wso2 wso2esb

我创建了一个涉及服务链的ProxyService,其中第一个服务的输出用于迭代和调用第二个服务。首先,我尝试了以下代理配置:

    <?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ListingProxyService"
       transports="https,http"
       startOnLoad="true">
   <target>
      <inSequence>
         <log>
            <property name="sequence" value="IN SEQ LISTINGPROXY"/>
         </log>
        <property name="uri.var.apiUrl" value="https://api.srwd83.com" scope="default" type="STRING"/>
        <property name="uri.var.accessToken" value="9afc63fe80b7b770b1b2293af4f398c" scope="default" type="STRING"/>
        <property name="uri.var.userGuid" value="89A2530728201ABCE04400144FB7AE36" scope="default" type="STRING"/>
        <property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Bearer ', get-property('uri.var.accessToken'))" scope="transport" type="STRING"/>
         <log>
            <property name="sequence" value="IN SEQ GETLISTINGS REQUEST"/>
         </log>
         <send>
            <endpoint>
               <http method="get"
                     uri-template="{uri.var.apiUrl}/accountmanagement/listings/v1/seller/{uri.var.userGuid}"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <log level="full">
            <property name="sequence" value="OUT SEQ GETLISTINGS RESPONSE"/>
         </log>
         <xslt key="GetListingToCreateListingTransformation"/>
         <log level="full">
            <property name="sequence" value="OUT SEQ AFTER TRANSFORMATION"/>
         </log>      
         <iterate expression="//listings" preservePayload="true" attachPath="//listing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
         <target>
         <sequence>
            <log>
                <property name="sequence" value="OUT SEQ CREATE LISTING"/>
            </log>
            <send/>
        </sequence>
        </target>
        </iterate>       
      </outSequence>
   </target>
   <description/>
</proxy>

这是用于转换有效载荷的localEntry:

<localEntry key="GetListingToCreateListingTransformation">
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      version="2.0"
                      exclude-result-prefixes="xsl xsi soapenv">
         <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
         <!-- Root template matcher --><xsl:template match="/">
            <listings>
               <xsl:for-each select="//soapenv:Envelope/soapenv:Body/jsonObject/listings/listing">
                  <xsl:call-template name="createListingTemplate">
                     <xsl:with-param name="listingparam" select="."/>
                  </xsl:call-template>
               </xsl:for-each>
            </listings>
         </xsl:template>
         <!-- Template to create listing request object --><xsl:template name="createListingTemplate">
            <xsl:param name="listingparam"/>
            <listing><xsl:value-of select="$listingparam/id"/></listing>
         </xsl:template>
      </xsl:stylesheet>
      <description>XSL used for transforming getListings output to a list of nodes that can be used for createListing operation.</description>
   </localEntry>

我看到在inSequence调用之后,outSequence里面的日志条目正在正确地转储Envelope。以下是来自inSequence调用的响应有效负载:

2014-04-09 21:08:12,177 [-] [PassThroughMessageProcessor-11]  INFO ListingProxyService To: /services/ListingProxyService.ListingProxyServiceHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:ba858d67-3a42-4310-af7d-4add3cea4f27, Direction: request, sequence = IN SEQ LISTINGPROXY

2014-04-09 21:08:12,178 [-] [PassThroughMessageProcessor-11]  INFO ListingProxyService To: /services/ListingProxyService.ListingProxyServiceHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:ba858d67-3a42-4310-af7d-4add3cea4f27, Direction: request, sequence = IN SEQ GETLISTINGS REQUEST

2014-04-09 21:08:14,018 [-] [PassThroughMessageProcessor-12]  INFO ListingProxyService To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:858b292d-496e-4351-99e5-43ec8417e80f, Direction: response, sequence = OUT SEQ GETLISTINGS RESPONSE, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><jsonObject><listings><listing><id>1068540737</id><status>INACTIVE</status></listing><listing><id>1067213811</id><status>INACTIVE</status></listing><listing><id>1070845353</id><status>INACTIVE</status></listing><listing><id>522269067</id><status>INACTIVE</status></listing><listing><id>1070845354</id><status>INACTIVE</status></listing></listings></jsonObject></soapenv:Body></soapenv:Envelope>

2014-04-09 21:08:14,050 [-] [PassThroughMessageProcessor-12]  INFO ListingProxyService To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:858b292d-496e-4351-99e5-43ec8417e80f, Direction: response, sequence = OUT SEQ AFTER TRANSFORMATION, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><listings xmlns="http://ws.apache.org/ns/synapse"></listings></soapenv:Body></soapenv:Envelope>

但转型后,我在改造后看不到合适的价值观。如果我在IDE中单独使用xsl内容进行转换,那么它的工作正常。它只能通过这个流程才能在第一次调用时处理该信封。

1 个答案:

答案 0 :(得分:1)

您的转换必须应用于正文的第一个子节点,xslt不会看到节点Envelope和Body