0

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.

  • To clarify: SOAPUI succeeds from same machine on which VB.NET fails? – Joey Mar 21 '14 at 20:44
  • Would also be beneficial to see the logs on the remote ServiceNow site, and make sure that the elementFormDefault property there is set as expected per http://wiki.servicenow.com/index.php?title=Web_Services_C_Sharp_.NET_End_to_End_Tutorial – Joey Mar 21 '14 at 20:46
  • SoapUI works on the machine where vb.net fails. I looked into that property, and that's probably why the web service API is failing, but that doesn't explain why there's others able to submit the exact same script and get results, would it? – Mr. Dot Walker Mar 21 '14 at 22:47
  • As clarification, the property is set to true, and I am not the system admin for our company to approve that change. But if there's no explanation as to why this is happening, I could probably squeeze something with them – Mr. Dot Walker Mar 21 '14 at 22:48
  • Ya, if you're seeing other people using .NET to make the same SOAP call to the same SOAP endpoint successfully, I would probably agree with you, but it's still probably worthwhile to ask your ServiceNow admin to adjust the property per the wiki, if you plan on using .NET to consume web services. – Joey Mar 22 '14 at 00:51
  • Is there any link as to what disabling that will also do? I've looked around but I can't seem to find the risk associated. Is there any reason this should be set to true? – Mr. Dot Walker Mar 22 '14 at 02:59
  • This link explains a little about elementFormDefault, and also shows an ad-hoc boolean property that can be specified in the URL: http://wiki.servicenow.com/?title=Direct_Web_Services#elementFormDefault – Joey Mar 22 '14 at 22:07

2 Answers2

1

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)
Community
  • 1
  • 1
0

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.

gflewis
  • 58
  • 1
  • 6
  • Would access control still be a valid argument if the user account being uses is the same on all machines? Is there anything that could cause one computer refusal, compared to another? I've tried with multiple accounts that have been setup to have SOAP permissions... same issue. :( – Mr. Dot Walker Apr 03 '14 at 15:45