如何使用for for for for for for foreach/titerate修改肥皂请求主体?

发布于 2025-02-01 10:42:03 字数 6916 浏览 3 评论 0原文

我想从JSON输入数组中添加多个标签。

应该在 ActionProperties 标签下添加它,因此我尝试使用foreach的富集调解器如下:

<payloadFactory media-type="xml">
            <format>
                <soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
                xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <soapenv:Header>
                        <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext">
                            <hd:UsernameToken xmlns:hd="http://schemas.xmlsoap.org/ws/2002/12/secext">
                                <hd:Username>$1</hd:Username>
                                <hd:Password>$2</hd:Password>
                            </hd:UsernameToken>
                        </Security>
                    </soapenv:Header>
                    <soapenv:Body>
                        <p857:ExecuteChangesRequest refresh="1" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema">
                            <p857:ChangeRequest id="1" updateSequenceNumber="0">
                                <p857:TargetSpecification classId="ObjectStore" objectId="$3" serializationDuplicate="0"/>
                                <p857:Action autoUniqueContainmentName="1" classId="$4" defineSecurityParentage="0" xsi:type="p857:CreateAction"/>
                                <p857:Action autoClassify="0" checkinMinorVersion="0" xsi:type="p857:CheckinAction"/>
                                <p857:ActionProperties>

                                    <p857:Property propertyId="DocumentTitle" settable="0" xsi:type="p857:SingletonString">
                                        <p857:Value>$5</p857:Value>
                                    </p857:Property>
                                    <p857:Property propertyId="ContentElements" settable="0" xsi:type="p857:ListOfObject">
                                        <p857:Value accessAllowed="0" classId="ContentTransfer" dependentAction="Insert" newIndex="0" originalIndex="0" serializationDuplicate="0" updateSequenceNumber="0">
                                            <p857:Property propertyId="ContentType" settable="0" xsi:type="p857:SingletonString">
                                                <p857:Value>$7</p857:Value>
                                            </p857:Property>
                                            <p857:Property propertyId="RetrievalName" settable="0" xsi:type="p857:SingletonString">
                                                <p857:Value>$5</p857:Value>
                                            </p857:Property>
                                            <p857:Property propertyId="Content" settable="0" xsi:type="p857:ContentData">
                                                <p857:Value xsi:type="p857:InlineContent">
                                                    <p857:Binary>$6</p857:Binary>
                                                </p857:Value>
                                            </p857:Property>
                                        </p857:Value>
                                    </p857:Property>
                                </p857:ActionProperties>
                                <p857:RefreshFilter levelDependents="0" maxElements="0" maxRecursion="0">
                                    <p857:ExcludeProperties>DateCreated</p857:ExcludeProperties>
                                    <p857:ExcludeProperties>DateLastModified</p857:ExcludeProperties>
                                </p857:RefreshFilter>
                            </p857:ChangeRequest>
                        </p857:ExecuteChangesRequest>
                    </soapenv:Body>
                </soapenv:Envelope>
            </format>
            <args>
                <arg evaluator="xml" expression="get-property('Username')"/>
                <arg evaluator="xml" expression="get-property('Password')"/>
                <arg evaluator="xml" expression="get-property('ObjectStore')"/>
                <arg evaluator="xml" expression="get-property('DocumentClass')"/>
                <arg evaluator="xml" expression="get-property('FileName')"/>
                <arg evaluator="xml" expression="get-property('FileData')"/>
                <arg evaluator="xml" expression="get-property('ContentType')"/>
            </args>
        </payloadFactory>

<foreach expression="//propertiesList">
        <target>
        <sequence>
               <enrich>
                   <source clone="true" type="inline">                                             
                   <p857:Property propertyId="$1" settable="0" 
                    xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" 
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p857:SingletonString">
                        <p857:Value>$2</p857:Value>
                    </p857:Property>
                   <args>
                        <arg evaluator="xml" expression="//name"/>
                        <arg evaluator="xml" expression="//value"/>
                    </args>
                    </source>
                    <target action="child" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" 
                     xpath="//p857:ExecuteChangesRequest/p857:ChangeRequest/p857:ActionProperties"/>
                </enrich>                                                                                                                                           
        </sequence>
        </target>
    </foreach>

但是没有任何内容插入肥皂请求中。虽然我尝试丰富一个标签,但它可以正常工作,如下所示:

<enrich>
        <source clone="true" type="inline">
            <p857:Property propertyId="isArchived" settable="0" 
            xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p857:SingletonString">
                <p857:Value>1</p857:Value>
            </p857:Property>
        </source>
        <target action="child" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" 
        xpath="//p857:ExecuteChangesRequest/p857:ChangeRequest/p857:ActionProperties"/>
    </enrich>

我该如何实现?

I want to add multiple tags to SOAP request body from JSON input array.

It should be added under the ActionProperties tag, so I tried to use the enrich mediator with foreach as follows :

<payloadFactory media-type="xml">
            <format>
                <soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
                xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <soapenv:Header>
                        <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext">
                            <hd:UsernameToken xmlns:hd="http://schemas.xmlsoap.org/ws/2002/12/secext">
                                <hd:Username>$1</hd:Username>
                                <hd:Password>$2</hd:Password>
                            </hd:UsernameToken>
                        </Security>
                    </soapenv:Header>
                    <soapenv:Body>
                        <p857:ExecuteChangesRequest refresh="1" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema">
                            <p857:ChangeRequest id="1" updateSequenceNumber="0">
                                <p857:TargetSpecification classId="ObjectStore" objectId="$3" serializationDuplicate="0"/>
                                <p857:Action autoUniqueContainmentName="1" classId="$4" defineSecurityParentage="0" xsi:type="p857:CreateAction"/>
                                <p857:Action autoClassify="0" checkinMinorVersion="0" xsi:type="p857:CheckinAction"/>
                                <p857:ActionProperties>

                                    <p857:Property propertyId="DocumentTitle" settable="0" xsi:type="p857:SingletonString">
                                        <p857:Value>$5</p857:Value>
                                    </p857:Property>
                                    <p857:Property propertyId="ContentElements" settable="0" xsi:type="p857:ListOfObject">
                                        <p857:Value accessAllowed="0" classId="ContentTransfer" dependentAction="Insert" newIndex="0" originalIndex="0" serializationDuplicate="0" updateSequenceNumber="0">
                                            <p857:Property propertyId="ContentType" settable="0" xsi:type="p857:SingletonString">
                                                <p857:Value>$7</p857:Value>
                                            </p857:Property>
                                            <p857:Property propertyId="RetrievalName" settable="0" xsi:type="p857:SingletonString">
                                                <p857:Value>$5</p857:Value>
                                            </p857:Property>
                                            <p857:Property propertyId="Content" settable="0" xsi:type="p857:ContentData">
                                                <p857:Value xsi:type="p857:InlineContent">
                                                    <p857:Binary>$6</p857:Binary>
                                                </p857:Value>
                                            </p857:Property>
                                        </p857:Value>
                                    </p857:Property>
                                </p857:ActionProperties>
                                <p857:RefreshFilter levelDependents="0" maxElements="0" maxRecursion="0">
                                    <p857:ExcludeProperties>DateCreated</p857:ExcludeProperties>
                                    <p857:ExcludeProperties>DateLastModified</p857:ExcludeProperties>
                                </p857:RefreshFilter>
                            </p857:ChangeRequest>
                        </p857:ExecuteChangesRequest>
                    </soapenv:Body>
                </soapenv:Envelope>
            </format>
            <args>
                <arg evaluator="xml" expression="get-property('Username')"/>
                <arg evaluator="xml" expression="get-property('Password')"/>
                <arg evaluator="xml" expression="get-property('ObjectStore')"/>
                <arg evaluator="xml" expression="get-property('DocumentClass')"/>
                <arg evaluator="xml" expression="get-property('FileName')"/>
                <arg evaluator="xml" expression="get-property('FileData')"/>
                <arg evaluator="xml" expression="get-property('ContentType')"/>
            </args>
        </payloadFactory>

<foreach expression="//propertiesList">
        <target>
        <sequence>
               <enrich>
                   <source clone="true" type="inline">                                             
                   <p857:Property propertyId="$1" settable="0" 
                    xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" 
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p857:SingletonString">
                        <p857:Value>$2</p857:Value>
                    </p857:Property>
                   <args>
                        <arg evaluator="xml" expression="//name"/>
                        <arg evaluator="xml" expression="//value"/>
                    </args>
                    </source>
                    <target action="child" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" 
                     xpath="//p857:ExecuteChangesRequest/p857:ChangeRequest/p857:ActionProperties"/>
                </enrich>                                                                                                                                           
        </sequence>
        </target>
    </foreach>

but nothing gets inserted into the SOAP request. While if I try to enrich a single tag it works fine as follows:

<enrich>
        <source clone="true" type="inline">
            <p857:Property propertyId="isArchived" settable="0" 
            xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p857:SingletonString">
                <p857:Value>1</p857:Value>
            </p857:Property>
        </source>
        <target action="child" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" 
        xpath="//p857:ExecuteChangesRequest/p857:ChangeRequest/p857:ActionProperties"/>
    </enrich>

How can I accomplish that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流心雨 2025-02-08 10:42:03

解决方案01:使用foreach和有效载荷工厂
以下内容应执行您要寻找的事情。由于我不知道如何将您的属性列表带入集成中,所以我只是对其进行了硬编码。

<inSequence>
            <payloadFactory media-type="xml">
                <format>
                    <propertiesList xmlns="">
                        <property>
                            <name>12345</name>
                        </property>
                        <property>
                            <name>23456</name>
                        </property>
                        <property>
                            <name>34567</name>
                        </property>
                    </propertiesList>
                </format>
                <args/>
            </payloadFactory>
            <foreach expression="//propertiesList/property">
                <sequence>
                    <log level="custom">
                        <property name="XXXX" value="In the for each....."/>
                    </log>
                    <payloadFactory media-type="xml">
                        <format>
                            <p857:Property propertyId="$1" settable="0" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p857:SingletonString">
                                <p857:Value>$2</p857:Value>
                            </p857:Property>
                        </format>
                        <args>
                            <arg evaluator="xml" expression="//name"/>
                            <arg evaluator="xml" expression="//value"/>
                        </args>
                    </payloadFactory>
                </sequence>
            </foreach>
            <log level="full"/>
            <enrich>
                <source clone="true" type="body"/>
                <target property="ConvertedPropertiesList" type="property"/>
            </enrich>
            <payloadFactory media-type="xml">
                <format>
                    <soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                        <soapenv:Header>
                            <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext">
                                <hd:UsernameToken xmlns:hd="http://schemas.xmlsoap.org/ws/2002/12/secext">
                                    <hd:Username>$1</hd:Username>
                                    <hd:Password>$2</hd:Password>
                                </hd:UsernameToken>
                            </Security>
                        </soapenv:Header>
                        <soapenv:Body>
                            <p857:ExecuteChangesRequest refresh="1" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema">
                                <p857:ChangeRequest id="1" updateSequenceNumber="0">
                                    <p857:TargetSpecification classId="ObjectStore" objectId="$3" serializationDuplicate="0"/>
                                    <p857:Action autoUniqueContainmentName="1" classId="$4" defineSecurityParentage="0" xsi:type="p857:CreateAction"/>
                                    <p857:Action autoClassify="0" checkinMinorVersion="0" xsi:type="p857:CheckinAction"/>
                                    <p857:ActionProperties>
                                        <p857:Property propertyId="DocumentTitle" settable="0" xsi:type="p857:SingletonString">
                                            <p857:Value>$5</p857:Value>
                                        </p857:Property>
                                        <p857:Property propertyId="ContentElements" settable="0" xsi:type="p857:ListOfObject">
                                            <p857:Value accessAllowed="0" classId="ContentTransfer" dependentAction="Insert" newIndex="0" originalIndex="0" serializationDuplicate="0" updateSequenceNumber="0">
                                                <p857:Property propertyId="ContentType" settable="0" xsi:type="p857:SingletonString">
                                                    <p857:Value>$7</p857:Value>
                                                </p857:Property>
                                                <p857:Property propertyId="RetrievalName" settable="0" xsi:type="p857:SingletonString">
                                                    <p857:Value>$5</p857:Value>
                                                </p857:Property>
                                                <p857:Property propertyId="Content" settable="0" xsi:type="p857:ContentData">
                                                    <p857:Value xsi:type="p857:InlineContent">
                                                        <p857:Binary>$6</p857:Binary>
                                                    </p857:Value>
                                                </p857:Property>
                                            </p857:Value>
                                        </p857:Property>
                                        $8
                                    </p857:ActionProperties>
                                    <p857:RefreshFilter levelDependents="0" maxElements="0" maxRecursion="0">
                                        <p857:ExcludeProperties>DateCreated</p857:ExcludeProperties>
                                        <p857:ExcludeProperties>DateLastModified</p857:ExcludeProperties>
                                    </p857:RefreshFilter>
                                </p857:ChangeRequest>
                            </p857:ExecuteChangesRequest>
                        </soapenv:Body>
                    </soapenv:Envelope>
                </format>
                <args>
                    <arg evaluator="xml" expression="get-property('Username')"/>
                    <arg evaluator="xml" expression="get-property('Password')"/>
                    <arg evaluator="xml" expression="get-property('ObjectStore')"/>
                    <arg evaluator="xml" expression="get-property('DocumentClass')"/>
                    <arg evaluator="xml" expression="get-property('FileName')"/>
                    <arg evaluator="xml" expression="get-property('FileData')"/>
                    <arg evaluator="xml" expression="get-property('ContentType')"/>
                    <arg evaluator="xml" expression="$ctx:ConvertedPropertiesList//p857:Property" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" />
                </args>
            </payloadFactory>
            <log level="full"/>
        </inSequence>

解决方案02:XSLT中介
我认为最优雅的方法是使用XSLT调解人。以下是您可以使用XSLT中介器的方式。

首先,创建一个XSLT模板作为本地条目。将以下内容作为样本。

<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="xsltTransformer" xmlns="http://ws.apache.org/ns/synapse">
    <xsl:stylesheet version="1.0" xmlns:ns4="http://nmdp.org/esb/domain/v04" xmlns:ns7="http://nmdp.org/esb/domain/v02" xmlns:ns8="http://nmdp.org/esb/domain/v01" xmlns:sfdc="sfdc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output encoding="UTF-8" indent="yes" method="xml" omit-xml-declaration="yes"/>
        <xsl:param name="Username"/>
        <xsl:param name="Password"/>
        <xsl:template match="/">
            <payload xmlns="">
                <soapenv:Envelope
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <Security
            xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext">
            <hd:UsernameToken
                xmlns:hd="http://schemas.xmlsoap.org/ws/2002/12/secext">
                <hd:Username>
                    <xsl:value-of select="$Username"/>
                </hd:Username>
                <hd:Password>
                    <xsl:value-of select="$Password"/>
                </hd:Password>
            </hd:UsernameToken>
        </Security>
    </soapenv:Header>
    <soapenv:Body>
        <p857:ExecuteChangesRequest refresh="1"
            xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema">
            <p857:ChangeRequest id="1" updateSequenceNumber="0">
                <p857:TargetSpecification classId="ObjectStore" objectId="$3" serializationDuplicate="0"/>
                <p857:Action autoUniqueContainmentName="1" classId="$4" defineSecurityParentage="0" xsi:type="p857:CreateAction"/>
                <p857:Action autoClassify="0" checkinMinorVersion="0" xsi:type="p857:CheckinAction"/>
                <p857:ActionProperties>
                    <p857:Property propertyId="DocumentTitle" settable="0" xsi:type="p857:SingletonString">
                        <p857:Value>$5</p857:Value>
                    </p857:Property>
                    <p857:Property propertyId="ContentElements" settable="0" xsi:type="p857:ListOfObject">
                        <p857:Value accessAllowed="0" classId="ContentTransfer" dependentAction="Insert" newIndex="0" originalIndex="0" serializationDuplicate="0" updateSequenceNumber="0">
                            <p857:Property propertyId="ContentType" settable="0" xsi:type="p857:SingletonString">
                                <p857:Value>$7</p857:Value>
                            </p857:Property>
                            <p857:Property propertyId="RetrievalName" settable="0" xsi:type="p857:SingletonString">
                                <p857:Value>$5</p857:Value>
                            </p857:Property>
                            <p857:Property propertyId="Content" settable="0" xsi:type="p857:ContentData">
                                <p857:Value xsi:type="p857:InlineContent">
                                    <p857:Binary>$6</p857:Binary>
                                </p857:Value>
                            </p857:Property>
                        </p857:Value>
                    </p857:Property>
                    <xsl:for-each select="//propertiesList/property">
                        <p857:Property propertyId="{name}" settable="0"
                            xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p857:SingletonString">
                            <p857:Value>
                                <xsl:value-of select="value"/>
                            </p857:Value>
                        </p857:Property>
                    </xsl:for-each>
                </p857:ActionProperties>
                <p857:RefreshFilter levelDependents="0" maxElements="0" maxRecursion="0">
                    <p857:ExcludeProperties>DateCreated</p857:ExcludeProperties>
                    <p857:ExcludeProperties>DateLastModified</p857:ExcludeProperties>
                </p857:RefreshFilter>
            </p857:ChangeRequest>
        </p857:ExecuteChangesRequest>
    </soapenv:Body>
</soapenv:Envelope>
            </payload>
       </xsl:template>
    </xsl:stylesheet>
</localEntry>

然后,您可以在主序列中引用上述内容。

<?xml version="1.0" encoding="UTF-8"?>
<api context="/xslt" name="xslt" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET">
        <inSequence>
            <log/>
            <property name="username" value="abcd"></property>
            <property name="pass" value="1233456"></property>
            <payloadFactory media-type="xml">
                <format>
                    <propertiesList xmlns="">
                        <property>
                            <name>12345</name>
                        </property>
                        <property>
                            <name>23456</name>
                        </property>
                        <property>
                            <name>34567</name>
                        </property>
                    </propertiesList>
                </format>
                <args/>
            </payloadFactory>
            <xslt key="xsltTransformer">
                <property name="Username" expression="$ctx:username"></property>
                <property name="Password" expression="$ctx:pass"></property>
            </xslt>
            <log level="full"></log>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>

Solution 01: With Foreach and Payload Factory
The following should do what you are looking for. Since I didn't know how your property list is brought into the integration I Just hardcoded it.

<inSequence>
            <payloadFactory media-type="xml">
                <format>
                    <propertiesList xmlns="">
                        <property>
                            <name>12345</name>
                        </property>
                        <property>
                            <name>23456</name>
                        </property>
                        <property>
                            <name>34567</name>
                        </property>
                    </propertiesList>
                </format>
                <args/>
            </payloadFactory>
            <foreach expression="//propertiesList/property">
                <sequence>
                    <log level="custom">
                        <property name="XXXX" value="In the for each....."/>
                    </log>
                    <payloadFactory media-type="xml">
                        <format>
                            <p857:Property propertyId="$1" settable="0" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p857:SingletonString">
                                <p857:Value>$2</p857:Value>
                            </p857:Property>
                        </format>
                        <args>
                            <arg evaluator="xml" expression="//name"/>
                            <arg evaluator="xml" expression="//value"/>
                        </args>
                    </payloadFactory>
                </sequence>
            </foreach>
            <log level="full"/>
            <enrich>
                <source clone="true" type="body"/>
                <target property="ConvertedPropertiesList" type="property"/>
            </enrich>
            <payloadFactory media-type="xml">
                <format>
                    <soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                        <soapenv:Header>
                            <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext">
                                <hd:UsernameToken xmlns:hd="http://schemas.xmlsoap.org/ws/2002/12/secext">
                                    <hd:Username>$1</hd:Username>
                                    <hd:Password>$2</hd:Password>
                                </hd:UsernameToken>
                            </Security>
                        </soapenv:Header>
                        <soapenv:Body>
                            <p857:ExecuteChangesRequest refresh="1" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema">
                                <p857:ChangeRequest id="1" updateSequenceNumber="0">
                                    <p857:TargetSpecification classId="ObjectStore" objectId="$3" serializationDuplicate="0"/>
                                    <p857:Action autoUniqueContainmentName="1" classId="$4" defineSecurityParentage="0" xsi:type="p857:CreateAction"/>
                                    <p857:Action autoClassify="0" checkinMinorVersion="0" xsi:type="p857:CheckinAction"/>
                                    <p857:ActionProperties>
                                        <p857:Property propertyId="DocumentTitle" settable="0" xsi:type="p857:SingletonString">
                                            <p857:Value>$5</p857:Value>
                                        </p857:Property>
                                        <p857:Property propertyId="ContentElements" settable="0" xsi:type="p857:ListOfObject">
                                            <p857:Value accessAllowed="0" classId="ContentTransfer" dependentAction="Insert" newIndex="0" originalIndex="0" serializationDuplicate="0" updateSequenceNumber="0">
                                                <p857:Property propertyId="ContentType" settable="0" xsi:type="p857:SingletonString">
                                                    <p857:Value>$7</p857:Value>
                                                </p857:Property>
                                                <p857:Property propertyId="RetrievalName" settable="0" xsi:type="p857:SingletonString">
                                                    <p857:Value>$5</p857:Value>
                                                </p857:Property>
                                                <p857:Property propertyId="Content" settable="0" xsi:type="p857:ContentData">
                                                    <p857:Value xsi:type="p857:InlineContent">
                                                        <p857:Binary>$6</p857:Binary>
                                                    </p857:Value>
                                                </p857:Property>
                                            </p857:Value>
                                        </p857:Property>
                                        $8
                                    </p857:ActionProperties>
                                    <p857:RefreshFilter levelDependents="0" maxElements="0" maxRecursion="0">
                                        <p857:ExcludeProperties>DateCreated</p857:ExcludeProperties>
                                        <p857:ExcludeProperties>DateLastModified</p857:ExcludeProperties>
                                    </p857:RefreshFilter>
                                </p857:ChangeRequest>
                            </p857:ExecuteChangesRequest>
                        </soapenv:Body>
                    </soapenv:Envelope>
                </format>
                <args>
                    <arg evaluator="xml" expression="get-property('Username')"/>
                    <arg evaluator="xml" expression="get-property('Password')"/>
                    <arg evaluator="xml" expression="get-property('ObjectStore')"/>
                    <arg evaluator="xml" expression="get-property('DocumentClass')"/>
                    <arg evaluator="xml" expression="get-property('FileName')"/>
                    <arg evaluator="xml" expression="get-property('FileData')"/>
                    <arg evaluator="xml" expression="get-property('ContentType')"/>
                    <arg evaluator="xml" expression="$ctx:ConvertedPropertiesList//p857:Property" xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema" />
                </args>
            </payloadFactory>
            <log level="full"/>
        </inSequence>

Solution 02: XSLT Mediator
I think the most elegant way to do this is by using the XSLT mediator. Following is how you can use XSLT mediator.

First, create an XSLT template as a local entry. Use the following as a sample.

<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="xsltTransformer" xmlns="http://ws.apache.org/ns/synapse">
    <xsl:stylesheet version="1.0" xmlns:ns4="http://nmdp.org/esb/domain/v04" xmlns:ns7="http://nmdp.org/esb/domain/v02" xmlns:ns8="http://nmdp.org/esb/domain/v01" xmlns:sfdc="sfdc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output encoding="UTF-8" indent="yes" method="xml" omit-xml-declaration="yes"/>
        <xsl:param name="Username"/>
        <xsl:param name="Password"/>
        <xsl:template match="/">
            <payload xmlns="">
                <soapenv:Envelope
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <Security
            xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext">
            <hd:UsernameToken
                xmlns:hd="http://schemas.xmlsoap.org/ws/2002/12/secext">
                <hd:Username>
                    <xsl:value-of select="$Username"/>
                </hd:Username>
                <hd:Password>
                    <xsl:value-of select="$Password"/>
                </hd:Password>
            </hd:UsernameToken>
        </Security>
    </soapenv:Header>
    <soapenv:Body>
        <p857:ExecuteChangesRequest refresh="1"
            xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema">
            <p857:ChangeRequest id="1" updateSequenceNumber="0">
                <p857:TargetSpecification classId="ObjectStore" objectId="$3" serializationDuplicate="0"/>
                <p857:Action autoUniqueContainmentName="1" classId="$4" defineSecurityParentage="0" xsi:type="p857:CreateAction"/>
                <p857:Action autoClassify="0" checkinMinorVersion="0" xsi:type="p857:CheckinAction"/>
                <p857:ActionProperties>
                    <p857:Property propertyId="DocumentTitle" settable="0" xsi:type="p857:SingletonString">
                        <p857:Value>$5</p857:Value>
                    </p857:Property>
                    <p857:Property propertyId="ContentElements" settable="0" xsi:type="p857:ListOfObject">
                        <p857:Value accessAllowed="0" classId="ContentTransfer" dependentAction="Insert" newIndex="0" originalIndex="0" serializationDuplicate="0" updateSequenceNumber="0">
                            <p857:Property propertyId="ContentType" settable="0" xsi:type="p857:SingletonString">
                                <p857:Value>$7</p857:Value>
                            </p857:Property>
                            <p857:Property propertyId="RetrievalName" settable="0" xsi:type="p857:SingletonString">
                                <p857:Value>$5</p857:Value>
                            </p857:Property>
                            <p857:Property propertyId="Content" settable="0" xsi:type="p857:ContentData">
                                <p857:Value xsi:type="p857:InlineContent">
                                    <p857:Binary>$6</p857:Binary>
                                </p857:Value>
                            </p857:Property>
                        </p857:Value>
                    </p857:Property>
                    <xsl:for-each select="//propertiesList/property">
                        <p857:Property propertyId="{name}" settable="0"
                            xmlns:p857="http://www.filenet.com/ns/fnce/2006/11/ws/schema"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="p857:SingletonString">
                            <p857:Value>
                                <xsl:value-of select="value"/>
                            </p857:Value>
                        </p857:Property>
                    </xsl:for-each>
                </p857:ActionProperties>
                <p857:RefreshFilter levelDependents="0" maxElements="0" maxRecursion="0">
                    <p857:ExcludeProperties>DateCreated</p857:ExcludeProperties>
                    <p857:ExcludeProperties>DateLastModified</p857:ExcludeProperties>
                </p857:RefreshFilter>
            </p857:ChangeRequest>
        </p857:ExecuteChangesRequest>
    </soapenv:Body>
</soapenv:Envelope>
            </payload>
       </xsl:template>
    </xsl:stylesheet>
</localEntry>

Then you can refer the above in you main sequence.

<?xml version="1.0" encoding="UTF-8"?>
<api context="/xslt" name="xslt" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET">
        <inSequence>
            <log/>
            <property name="username" value="abcd"></property>
            <property name="pass" value="1233456"></property>
            <payloadFactory media-type="xml">
                <format>
                    <propertiesList xmlns="">
                        <property>
                            <name>12345</name>
                        </property>
                        <property>
                            <name>23456</name>
                        </property>
                        <property>
                            <name>34567</name>
                        </property>
                    </propertiesList>
                </format>
                <args/>
            </payloadFactory>
            <xslt key="xsltTransformer">
                <property name="Username" expression="$ctx:username"></property>
                <property name="Password" expression="$ctx:pass"></property>
            </xslt>
            <log level="full"></log>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文