Unable to construct a SOAP request with NodeJS - node.js

The WSDL in question is under the following URL: https://bmdweb.bmd.at/bmdntcswsdev/bmdntcsws.dll/wsdl/IBMDSOAPNTCS
I was provided with a sample log-output of how the XML should be constructed.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.bmd.at/" xmlns:types="http://www.bmd.at/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<q1:Login xmlns:q1="http://www.bmd.at/wws">
<ALoginRequest href="#id1" />
</q1:Login>
<q2:TBMDLoginRequest id="id1" xsi:type="q2:TBMDLoginRequest" xmlns:q2="http://www.bmd.at/soap">
<Auth href="#id2" />
</q2:TBMDLoginRequest>
<q3:TBMDPlainText id="id2" xsi:type="q3:TBMDPlainText" xmlns:q3="http://www.bmd.at/soap">
<Username xsi:type="xsd:string">xxxxUSER</Username>
<Password xsi:type="xsd:string">xxxxPASSWORD</Password>
<DBAlias xsi:type="xsd:string">xxxxDBALIAS</DBAlias>
</q3:TBMDPlainText>
</soap:Body>
</soap:Envelope>
Problem
I simply cannot figure out how to construct this XML using https://www.npmjs.com/package/soap. The part, where ALoginRequest is within the Login element, while everything else is outside of it, confuses me.
Efforts
When I try this: const login = await client.LoginAsync({ALoginRequest: {Auth: {TBMDPlainText: auth}}}), I get the following output.
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://www.bmd.at/" xmlns:ns1="http://www.bmd.at/soap" xmlns:ns2="http://www.bmd.at/wws"><soap:Body><tns:Login><ALoginRequest><Auth><TBMDPlainText><Username>xxxx</Username><Password>xxxx</Password><DBAlias>xxxx</DBAlias></TBMDPlainText></Auth></ALoginRequest></tns:Login></soap:Body></soap:Envelope>
Can anyone provide me any hints?

Related

XMLHTTPRequest - can't do anything with response

I'm new to Javascript, but we all was at sometime. I'm Stuck!
I can get my XMLHTTPRequest response ok from a gov site in xml format (no JSON available). I can't get it to console log or display to my html page.
I can only see it in the firefox>developertools>network>response
What am I doing wrong?
I want to see it in my console log and get it to my html page.
MY RESPONSE - IN FIREFOX: >developerTools>network>response
<?xml version="1.0" encoding="UTF-8"?>
<response xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:noNamespaceSchemaLocation="http://www.aviationweather.gov/static/adds/schema/metar1_2.xsd">
<request_index>174466304</request_index>
<data_source name="metars" />
<request type="retrieve" />
<errors />
<warnings />
<time_taken_ms>14</time_taken_ms>
<data num_results="6">
<METAR>
<raw_text>KCRX 161655Z AUTO 29010KT 9SM BKN012 OVC017 03/00 A3000 RMK AO2</raw_text>
<station_id>KCRX</station_id>
<observation_time>2020-12-16T16:55:00Z</observation_time>
<latitude>34.92</latitude>
<longitude>-88.6</longitude>
<temp_c>3.0</temp_c>
<dewpoint_c>0.0</dewpoint_c>
<wind_dir_degrees>290</wind_dir_degrees>
<wind_speed_kt>10</wind_speed_kt>
<visibility_statute_mi>9.0</visibility_statute_mi>
<altim_in_hg>30.0</altim_in_hg>
<quality_control_flags>
<auto>TRUE</auto>
<auto_station>TRUE</auto_station>
</quality_control_flags>
<sky_condition sky_cover="BKN" cloud_base_ft_agl="1200" />
<sky_condition sky_cover="OVC" cloud_base_ft_agl="1700" />
<flight_category>MVFR</flight_category>
<metar_type>METAR</metar_type>
<elevation_m>128.0</elevation_m>
</METAR>
</data>
</response>
MY XMLHTTPRequest:
const request = new XMLHttpRequest();
request.open('GET', 'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=KCRX&hoursBeforeNow=2',);
request.onload = function() {
console.log(request);
};
request.send();
My Console shows:
enter image description here
MY Header:
enter image description here

sample Soap Message that calls a SavedSearch by the ID

I was wondering if someone has an example using SuiteTalk, i was searching but could not find any examples.
Here's a SOAP request that executes a customer search with the internal ID of the search.
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<tokenPassport xmlns="urn:messages_2019_2.platform.webservices.netsuite.com">
<account xmlns="urn:core_2019_2.platform.webservices.netsuite.com">**********</account>
<consumerKey xmlns="urn:core_2019_2.platform.webservices.netsuite.com">****************************************************************</consumerKey>
<token xmlns="urn:core_2019_2.platform.webservices.netsuite.com">****************************************************************</token>
<nonce xmlns="urn:core_2019_2.platform.webservices.netsuite.com">b591c9bfb56c406c9cf79252783dac7f</nonce>
<timestamp xmlns="urn:core_2019_2.platform.webservices.netsuite.com">1605312585</timestamp>
<signature algorithm="HMAC_SHA256" xmlns="urn:core_2019_2.platform.webservices.netsuite.com">********************************************</signature>
</tokenPassport>
</soap:Header>
<soap:Body>
<search xmlns="urn:messages_2019_2.platform.webservices.netsuite.com">
<searchRecord savedSearchId="366" xsi:type="q1:CustomerSearchAdvanced" xmlns:q1="urn:relationships_2019_2.lists.webservices.netsuite.com"/>
</search>
</soap:Body>
</soap:Envelope>
It looks like this with C#
var search = new CustomerSearchAdvanced()
{
savedSearchId = "366"
};
var results = ns.search(search);

Groovy get xml tags attribute value

I am trying to get the value of the attribute IntegratorCode AND ProductType using groovy.
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAPNYK1="http://www.w3.org/2001/XMLSchema"
xmlns:SOAPNYK2="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAPNYK3="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<Authentication
xmlns="urn:iQQ:API:22:iQQMessages.xsd" EmployeeCode="*****" IntegratorCode="GENERIC" Pwd="******" Usr="SYSUSER"/>
</soap:Header>
<soap:Body>
<CanOfferProduct
xmlns="urn:iQQ:API:22:iQQMessages.xsd">
<OnQuotePackage
xmlns="" ProductType="GAP" QuoteNumber="74859">test
</OnQuotePackage>/>
</CanOfferProduct>
</soap:Body>
</soap:Envelope>
I tried the following method using XmlSlurpur
def result = new XmlSlurper().parseText(xml)
println(result.Envelope.Header[1].Authentication.#IntegratorCode)
//output = IntegratorCode
I wanted to print the value of IntegratorCode which is "GENERIC".
I am not sure what I am doing wrong in this case. please help.
what you called result is soap:Envelope, so you essentially had Envelope.Envelope... This works:
println result.Header.Authentication.#IntegratorCode
As a precaution I normally use it like this:
def Envelope = new XmlSlurper().parseText(xml)

Cannot parse kml file to be treated as xml

I want to parse a kml file to be treated like a xml file :
var parser = require('xml2json');
router.get('/', function (req, res) {
var xml = "D:/Axes2019.kml";
var json = parser.toJson(xml);
console.log("to json -> %s", json);
res.render("index");
});
At runtime I get There are errors in your xml file: not well-formed (invalid token)
Here is the kml :
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="root_doc">
<Schema name="Axes_2K19" id="Axes_2K19">
<SimpleField name="Name" type="string"></SimpleField>
<SimpleField name="Denomin" type="string"></SimpleField>
</Schema>
<Folder><name>Axes_2K19</name>
<Placemark>
<name>9O_6</name>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
<ExtendedData><SchemaData>
<SimpleData name="Denomin">Antanimena</SimpleData>
</SchemaData></ExtendedData>
<MultiGeometry><Polygon><outerBoundaryIs><LinearRing><coordinates>47.5282959843938,-18.8881931524494 47.5273060204005,-18.8883147269749 47.525771678897,-18.8898762249651 47.525391488082,-18.8909217497064 47.5247125759123,-18.8915497434633 47.5244138545577,-18.8919299342784 47.5243188068539,-18.8924866422575 47.5259255656555,-18.8935536658841 47.5268466231657,-18.8952758397545 47.5265207453242,-18.8961312690883 47.5276816851343,-18.8957442891516 47.5279871956107,-18.8964978816599 47.529947,-18.89907 47.52965,-18.901435 47.5292802275261,-18.9017841358174 47.5286065539348,-18.9019002864366 47.5276076586099,-18.9018770563128 47.5269339850186,-18.9021906629845 47.5268062193375,-18.9027481859566 47.526667,-18.903358 47.526247,-18.903399 47.525913,-18.903094 47.525489,-18.903003 47.524572,-18.902694 47.523774,-18.902588 47.523368,-18.9026 47.522878,-18.902871 47.522666,-18.903034 47.5223273311563,-18.9027936605133 47.521073,-18.901036 47.520669,-18.900556 47.518254,-18.89732 47.5166722429164,-18.8951662207165 47.516752829692,-18.8950896025168 47.5168139317873,-18.8943258263259 47.5166917275968,-18.8930121312776 47.5173638506447,-18.8917595383246 47.5187879970001,-18.8904753419999 47.516371167,-18.887820824 47.5151030731197,-18.8858937371787 47.5153169304532,-18.8838162659395 47.5165084213109,-18.8805396660807 47.5159890535012,-18.8784851081272 47.5159886221055,-18.8784787989658 47.5193198602536,-18.8783563269751 47.521029,-18.877701 47.5222222097789,-18.8787229395467 47.5236810223034,-18.8789367968802 47.526064004019,-18.8796089199281 47.529757529473,-18.8805918742828 47.5292090646449,-18.8815425466514 47.5290563094068,-18.8836505689382 47.5292090646449,-18.8857662289869 47.5285674926446,-18.8872937813686 47.5282959843938,-18.8881931524494</coordinates></LinearRing></outerBoundaryIs></Polygon></MultiGeometry>
</Placemark>
...
</Folder>
</Document></kml>
So how to fix it ?
I checked your sample KML for XML and KML Schema validity, and it looked fine to me. Maybe your parser wants more of the namespaces defined? See below for what I usually include at the top of my KMLs:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
...
</kml>
Or maybe some of the rest of your file (which you replaced with "..." contains XML errors? Make sure all your IDs are valid too (start with a letter, no forbidden characters, etc.).

groovy XmlSlurper parse XML

I get a XML file like this:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:udb="http://somenamespace>
<soap:Header/>
<soap:Body>
<udb:ProvideUDBIdentityInformationRequest>
<udb:RequestID>1</udb:RequestID>
<udb:IDnumber>1</udb:IDnumber>
<udb:UnifiedNumber>3</udb:UnifiedNumber>
</udb:ProvideUDBIdentityInformationRequest>
</soap:Body>
</soap:Envelope>
I want to save the below string to another file.
<soap:Body>
<udb:ProvideUDBIdentityInformationRequest>
<udb:RequestID>1</udb:RequestID>
<udb:IDnumber>1</udb:IDnumber>
<udb:UnifiedNumber>3</udb:UnifiedNumber>
</udb:ProvideUDBIdentityInformationRequest>
</soap:Body>
How can I achieve that ?
In fact, I've refer to some tutorial like this one ,http://groovy.codehaus.org/Reading+XML+using+Groovy%27s+XmlSlurper, but cannot find such a method in XmlSlurper.
Thanks in advance!
Assuming you have the original xml in a variable called xml, you can do:
String output = new groovy.xml.StreamingMarkupBuilder().bind {
mkp.yield new XmlSlurper().parseText( xml ).Body
}
Then, output equals:
<soap:Body xmlns:soap='http://www.w3.org/2003/05/soap-envelope'>
<udb:ProvideUDBIdentityInformationRequest xmlns:udb='http://somenamespace'>
<udb:RequestID>1</udb:RequestID>
<udb:IDnumber>1</udb:IDnumber>
<udb:UnifiedNumber>3</udb:UnifiedNumber>
</udb:ProvideUDBIdentityInformationRequest>
</soap:Body>

Resources