简体   繁体   中英

Node-soap XML syntax

I'm trying to consume a SOAP WebService defined with this and this WSDLs with node-soap in node.js.

Now, regarding this part of the singlewsdl specification:

<xs:element minOccurs="0" name="AuthToken" nillable="true" type="xs:string"/>
<xs:element xmlns:q1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="NIP" nillable="true" type="q1:ArrayOfstring"/>
...   
<xs:element minOccurs="0" name="DateFrom" nillable="true" type="xs:dateTime"/>

I have no problem querying the service with the AuthToken or DateFrom arguments:

var args = {
    AuthToken: 'yyyy',
    DateFrom: (ISOstringed date variable)
};

yet I have no clue how the syntax for "ArrayOf..." arguments should look like. I've tried:

NIP: 'xxxx'
NIP: {
    element: 'xxxx'
}
NIP: {
    string: 'xxxx'
}

yet only the first one produces a deserialization error, the former only produce timeouts (which is the same as for random arguments).

Any help would be appreciated.

SoapUI helped me to understand that this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GetData>
         <tem:AuthToken>xxxx</tem:AuthToken>
         <tem:NIP>
            <arr:string>yyyy</arr:string>
            <arr:string>zzzz</arr:string>
         </tem:NIP>
      </tem:GetData>
   </soapenv:Body>
</soapenv:Envelope>

is the desired XML request format, so I went to make it as close as possible:

var args = {
    attributes: {
        'xmlns:arr': 'http://schemas.microsoft.com/2003/10/Serialization/Arrays'
    },
    'tns:AuthToken': 'xxxx',
    'tns:NIP': {
        'arr:string': ['yyyy','zzzz']
    },
};

As a word of comment - node-soap defines the http://tempuri.org/ namespace as 'tns' by default, so I skipped the 'tem' definition that SoapUI suggested.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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