Created
May 3, 2020 02:40
-
-
Save takahirohonda/a1036bc23da3451db9f6ad50001a0de0 to your computer and use it in GitHub Desktop.
qas-do-search.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const axios = require('axios') | |
| const parseString = require('xml2js').parseString | |
| const qas_token = '<add your token>' | |
| const soap_action = 'http://www.qas.com/OnDemand-2011-03/DoSearch' | |
| const xml = '<?xml version="1.0" encoding="UTF-8" ?> \ | |
| <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ond="http://www.qas.com/OnDemand-2011-03">\ | |
| <soapenv:Header>\ | |
| <ond:QAQueryHeader />\ | |
| </soapenv:Header>\ | |
| <soapenv:Body>\ | |
| <ond:QASearch>\ | |
| <ond:Country>AUS</ond:Country>\ | |
| <ond:Engine Flatten="true" Intensity="Close" PromptSet="Default" Threshold="5" Timeout="10000">Intuitive</ond:Engine>\ | |
| <ond:Layout></ond:Layout>\ | |
| <ond:Search>101 Colll</ond:Search>\ | |
| </ond:QASearch>\ | |
| </soapenv:Body>\ | |
| </soapenv:Envelope>' | |
| const options = { | |
| method: 'post', | |
| url: 'https://ws.ondemand.qas.com/ProOnDemand/V3/ProOnDemandService.asmx?WSDL=', | |
| headers: { | |
| 'Content-Type':'text/xml', | |
| 'Auth-Token':qas_token, | |
| 'SOAPAction': soap_action, | |
| }, | |
| data: xml, | |
| } | |
| axios(options) | |
| .then(response => { | |
| console.log(response.data); | |
| parseString(response.data, (err, result) => { | |
| console.log(result) | |
| // console.log(JSON.stringify(result['soap:Envelope']['soap:Body'])) | |
| var searchResult = result['soap:Envelope']['soap:Body'][0]['QASearchResult'][0]['QAPicklist'][0]['PicklistEntry'] | |
| searchResult.forEach((item) => { | |
| console.dir(item) | |
| }) | |
| }) | |
| }) | |
| .catch( err => { | |
| console.log(err) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment