1

我正在尝试将 SOAP api 与 SOAPUI 一起使用。WSDL 中描述的“get”操作如下所示:

 <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:MarketingCenter" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
       <soapenv:Header/>
       <soapenv:Body>
          <urn:Get soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
             <Authentication xsi:type="urn:Authentication">
                <!--You may enter the following 6 items in any order-->
                <Username xsi:type="xsd:string">myUserName</Username>
                <Password xsi:type="xsd:string">mypassword</Password>
                <CustomerId xsi:type="xsd:int">29833</CustomerId>
                <Level xsi:type="xsd:int">0</Level>
                <Source xsi:type="xsd:string">?</Source>
                <Options xsi:type="xsd:int">0</Options>
             </Authentication>
             <Method xsi:type="xsd:string">keyword.list</Method>
             <Arguments xsi:type="urn:ArrayOfKeyValuePairs" soapenc:arrayType="urn:KeyValuePair[]"/>
          </urn:Get>
       </soapenv:Body>
    </soapenv:Envelope>

但是,当我运行此操作时,会出现以下错误:

    <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns4="urn:MarketingCenter">
   <SOAP-ENV:Body>
      <ns4:GetResponse>
         <return xsi:type="ns4:GetResponseData">
            <Data xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[0]" xsi:nil="true"/>
            <Status>
               <ErrorCode xsi:type="xsd:int">1</ErrorCode>
               <ErrorString xsi:type="xsd:string">One or more of the arguments were invalid</ErrorString>
               <ErrorDetails xsi:type="xsd:string">One or more of the arguments were invalid</ErrorDetails>
            </Status>
         </return>
      </ns4:GetResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我不确定我应该在哪里,但参数列表,或者如何格式化这个列表。我确实意识到他们想要一个参数数组,但是我应该把这个数组放在哪里?无论我应该在哪里输入其他值,都会有一个“?”,所以我不确定在哪里输入这个 argumentw 数组。

4

1 回答 1

2

希望您在这里输入实际值:

<Authentication xsi:type="urn:Authentication">
    <!--You may enter the following 6 items in any order-->
    <Username xsi:type="xsd:string">myUserName</Username>
    <Password xsi:type="xsd:string">mypassword</Password>
    <CustomerId xsi:type="xsd:int">29833</CustomerId>
    <Level xsi:type="xsd:int">0</Level>
    <Source xsi:type="xsd:string">?</Source>
    <Options xsi:type="xsd:int">0</Options>
</Authentication>

参数列表只是Username, Password,CustomerId等。而不是myUserName,mypassword放入服务所期望的任何内容。

据,直到...为止:

<Arguments xsi:type="urn:ArrayOfKeyValuePairs" soapenc:arrayType="urn:KeyValuePair[]"/>

这可能看起来像:

<urn:Get>
    ...
    <Arguments xsi:type="urn:ArrayOfKeyValuePairs" soapenc:arrayType="urn:KeyValuePair[5]">
        <KeyValuePair>
            <Key xsi:type="xsd:string">foo</Key>
            <Value xsi:type="xsd:string">bar</Value>
        </KeyValuePair>
        <KeyValuePair>...</KeyValuePair>
        <KeyValuePair>...</KeyValuePair>
        <KeyValuePair>...</KeyValuePair>
        <KeyValuePair>...</KeyValuePair>
    </Arguments>
</urn:Get>

其中的内容取决于服务如何定义该类型(根据 WSDL只是一个<Key>元素和一个元素)。<Value>确保方括号 ( [5]) 中的数字与<KeyValuePair>元素的数量相匹配。

于 2012-07-27T15:40:29.793 回答