1

我有一个简单的字符串作为输入,并在调用将字符串添加到数组的 Web 服务之后。现在我必须将数组分配给输出(我已在模式中将其设置为字符串数组)。企业经理给出了一个错误并说结果包含给定 XPath 表达式的多个节点。分配活动显示为挂起。所以基本上我如何将数组或列表分配给也设置为数组的输出变量。使用的 wsdl 文件是:

<?xml version = '1.0' encoding = 'UTF-8'?>

<definitions
     name="ReturnTypeService"
     targetNamespace="http://examples2/"
     xmlns="http://schemas.xmlsoap.org/wsdl/"
     xmlns:tns="http://examples2/"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    >
    <types>
        <xsd:schema>
            <xsd:import namespace="http://examples2/" schemaLocation="http://localhost:7101/Examples2-Examples2-context-root/ReturnTypePort?xsd=1"/>
        </xsd:schema>
    </types>
    <message name="display">
        <part name="parameters" element="tns:display"/>
    </message>
    <message name="displayResponse">
        <part name="parameters" element="tns:displayResponse"/>
    </message>
    <portType name="ReturnType">
        <operation name="display">
            <input message="tns:display"/>
            <output name="displayResponse"
            message="tns:displayResponse"/>
        </operation>
    </portType>
    <binding name="ReturnTypePortBinding" type="tns:ReturnType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="display">
            <soap:operation soapAction=""/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>
    <service name="ReturnTypeService">
        <port name="ReturnTypePort" binding="tns:ReturnTypePortBinding">
            <soap:address location="http://localhost:7101/Examples2-Examples2-context-root/ReturnTypePort"/>
        </port>
    </service>
</definitions>

@vanto有没有办法将输入变量中的数组分配给invoke_input变量?问题是我的Web服务中有多个输入,所以我无法将输入变量中的包装元素复制到调用变量中的包装变量。将复制这里的代码片段:

<assign name="Assign1">
            <copy>
                <from variable="inputVariable" part="payload"
                      query="/ns2:process/ns2:dsaName"/>
                <to variable="Invoke1_processList_InputVariable"
                    part="parameters" query="/ns1:processList/dsaName"/>
            </copy>
            <copy>
                <from variable="inputVariable" part="payload"
                      query="/ns2:process/ns2:linesOfData"/>
                <to variable="Invoke1_processList_InputVariable"
                    part="parameters" query="/ns1:processList/linesOfData"/>
            </copy>
            <copy>
                <from variable="inputVariable" part="payload"
                      query="/ns2:process/ns2:description"/>
                <to variable="Invoke1_processList_InputVariable"
                    part="parameters" query="/ns1:processList/description"/>
            </copy>
            <copy>
                <from variable="inputVariable" part="payload"
                      query="/ns2:process/ns2:application"/>
                <to variable="Invoke1_processList_InputVariable"
                    part="parameters" query="/ns1:processList/application"/>
            </copy>
        </assign>

问题是只有一个是列表类型,所有其他都是字符串类型。用于此的 XML 是:

<element name="process">
            <complexType>
                <sequence>
                     <element name="dsaName" type="string" minOccurs="0"/>
                    <element name="linesOfData" type="string" minOccurs="0" maxOccurs="unbounded"/>

                    <element name="description" type="string" minOccurs="0"/>
            </sequence>
    </complexType>
        </element>
    <element name="processResponse">
        <complexType>
            <sequence>
                <element name="result" type="string" minOccurs="0" maxOccurs="unbounded"/>
            </sequence>
        </complexType>
    </element>
</schema>
4

1 回答 1

1

from-spec 和 to-spec 不能选择多个元素或属性。在您的情况下,它似乎选择了<return>变量部分中的所有元素(即数组的项目)。尝试复制包装项目的元素(即 ns1:displayResponse 元素)并将此元素复制到 ns2:processResponse(to-variable 中的包装元素)。

由于源元素和目标元素似乎都在不同的名称空间中并且属于不同的类型,因此您可能需要通过 XSLT 脚本(使用doXSLTransform)运行它以将其从源模式转换为目标模式。

于 2011-10-20T09:42:34.847 回答