Important Update: Some Community URL Redirects are Under Maintenance. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP call from programmatically (JS) --- Status = 0

matthancock
Contributor III

Attempting to get a session token, but I am not getting any data back. I am using below xml call in a JavaScript node.js setup.

When I run in POSTMAN I get the token as expected.

I am getting a status 0 in the script.

 

<?xml version="1.0" encoding="utf-8"?>
  <soap:Body>
    <CreateUserSessionFromInstance xmlns="http://archer-tech.com/webservices/">
      <userName>username</userName>
      <instanceName>50000</instanceName>
      <password>password</password>
    </CreateUserSessionFromInstance>
  </soap:Body>
</soap:Envelope>
12 REPLIES 12

Anonymous
Not applicable

That is good documentation but it doesn't resolve my issue. The above code is ran in POSTMAN and returns a session token but when used in a Node.js script I get a status = 0.

Is there something I may be missing?

Anonymous
Not applicable

In NODE JS did u try REST authentication call? Also it depends on what is your complete code. I remember I was able successfully using Eclipse EE+NodeJS for API calls to Archer, though long time ago.

Thanks for getting back to me so quickly on this. 

My complete code is below. I am running in VSCode with the node modules. I have ran this successfully in other instances but not with an xml call like mentioned and not to ARCHER API.

 

var XMLHttpRequest = require('xhr2');
var xmlhttp = new XMLHttpRequest();

// build SOAP request
var sr =
'<?xml version="1.0" encoding="utf-8"?>' +
  '<soap:Body>' +
    '<CreateUserSessionFromInstance xmlns="http://archer-tech.com/webservices/">' +
      '<userName>username</userName>' +
      '<instanceName>50000</instanceName>' +
      '<password>password</password>' +
    '</CreateUserSessionFromInstance>' +
  '</soap:Body>' +
'</soap:Envelope>';

xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState == 4) {
        console.log("- status: " + xmlhttp.status);
    }
}
// Send the POST request
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
console.log("- sending token request...");
xmlhttp.send(sr);

 

Anonymous
Not applicable

I was using either ajax or require libs, I remember.

Also, are u sure your credentials correct and XML request correct by using Jeff's tool or postman? Like to be sure that there is no issue with domain, credentials, API node in IIS, etc.

Anonymous
Not applicable

And address your URL not to ?WDSL but only general.asmx. Because if you use ?WDSL, you are using SOAP 1.1 which requires SOAPAction in the header:

https://help.archerirm.cloud/platform_612/en-us/content/api/webapi/createusersessionfrominstance.htm

Ilya_0-1674759492608.png

So, main recommendation, define header as in the Archer Help above, and user URL: https://cms-uatw2019.bankofamerica.com/ws/general.asmx

Made the recommended changes and same result.

My POSTMAN call does not have headers except for content type and works great.

code changes added headers...

xmlhttp.setRequestHeader('POST', '/archer/ws/general.asmx HTTP/1.1');
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.setRequestHeader('SOAPAction', 'http://archer-tech.com/webservices/CreateUserSessionFromInstance');
 
the host and content length were not accepted.

Anonymous
Not applicable

Did u use different URL by removing ?WDSL?

Yes and that does work in POSTMAN but not in my code call.