Question

Using a small derivative from the following website:

http://servicenowsoap.wordpress.com/2013/10/26/vb-script/

...where I'm implementing the call in VB.Net instead of VBScript. I'm using Microsoft XML 3.0 resource, and during initial testing... it would work fine. I could send a "getKeys" update passing a number, and it would return with the sys_id number needed for ServiceNow.

Now, when I send any SOAP/XML envelope out, the server pretends that I sent it something foreign. It returns a 0 for the count and no sys_id. I've tried using direct XML implementation, and loading the WSDL through web services. Both return the same: Nothing.

BUT, when I try this code on any other machine, it will send and receive the SOAP request using the exact same code, and receives the request as expected.

Example SOAP envelope request on both machines:

 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
     <getKeys xmlns:tns="http://www.service-now.com/sc_req_item">
       <number> examplerequestnumber </number> 
     </getKeys>
  </soap:Body>
  </soap:Envelope>

What returns on anyone else's machine:

  <?xml version="1.0" ?> 
- <SOAP-ENV:Envelope 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">
-   <SOAP-ENV:Body>
-     <getKeysResponse>
       <sys_id>examplesysidnumber</sys_id> 
      <count>1</count> 
  </getKeysResponse>
  </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>

What returns on only my machine:

  <?xml version="1.0" ?> 
- <SOAP-ENV:Envelope 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">
-   <SOAP-ENV:Body>
-     <getKeysResponse>
       </sys_id> 
      <count>0</count> 
  </getKeysResponse>
  </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>

Is there something on my machine that may be blocking the request from completing? I have no antivirus running, no firewall up. I CAN however, send the exact same envelope in SOAPUI, and get a response. This is driving me crazy.

Was it helpful?

Solution

Figured out what the issue was. We have multiple domains on our server, and the account that was tied to the SOAP requests was on our old domain. The new domain had not yet been integrated with ServiceNow, and MSXML (what I was using to send the SOAP request) tried to do passthrough authentication with the new domain.

So, my next goal was to make sure MSXML was doing preemptive authentication, since this account using for SOAP requests was local to the ServiceNow server. I found something similar to my problem, so I tried the following:

  1. First, I ran the query in SOAPUI.
  2. Looking at the RAW tab, I pulled the "Authentication: Basic xxxxxx" header, and copied it directly into my code.
  3. I added the setRequestHeader to my request, and bam! It works.

Example code:

oWSRequest.open("POST", sEndpointURL, False, gServiceNowUser, gServiceNowPass)
oWSRequest.setRequestHeader("Content-Type", "text/xml")
oWSRequest.setRequestHeader("Authorization", "Basic c3J2Y1FsaWt2aWV3X09EQkM6bzc3MzQ4QTI4TnZV")
oWSRequest.send(oWSRequestDoc.xml)

OTHER TIPS

It is possible that you are being blocked by an access control or other security in the ServiceNow instance. You are receiving a valid XML response, which implies that you have established a good connection. I can only think of two things that would give a zero count response. (A) There really is no incident with this number in the database. (B) The incident exists, but ServiceNow is not allowing you to view it because your Web Service user account is failing to pass an access control.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top