Transmit XML document via HTTP Request

geoff3
Giga Expert

Hi,

 

I have been asked to set up an interface to an external website. It will be used to submit reports to the website, which will return a success/fail response and a reference number. The information being transmitted will be extracted from one of our custom tables.   The response then needs to be recorded in the records on the custom table.

 

The documentation for the external website says:

File transmission of an XML document can be initiated through a HTTP request conforming to RFC 1867. This request consists of <a bunch of parameters, including>: userId, password, reNumber, fileName, uploadUrl.

 

How do I do this in ServiceNow?   I have been going through the wiki for Web Services, but there isn't really a step-by-step or how-to instruction on how to set this up. Can someone please point me in the right direction?   How do I transmit the xml document, and how do I process the response?

 

I've been searching through the community posts, but all the posts I read are answering very specific questions, not really providing a big-picture view of how these things work.

 

Cheers,

Geoffrey

3 REPLIES 3

david_loo
Tera Contributor

Have you tried using the REST Message function for POST ?



http://wiki.servicenow.com/index.php?title=REST_Message



I believe the Content field does not care whether it is JSON or XML, just make sure that you have the correct HTTP header set for content-type: text/XML



You can use variable substitution to construct your XML



You can the script the REST message to be called and get its return value and use GlideRecord to update your custom table.


Thanks, David.   This looks like what I'm after.


Jake Gillespie
Mega Guru

Hi Geoffrey,



Have a look at the following wiki links if you haven't already.


Getting Started with REST - ServiceNow Wiki


REST Message - ServiceNow Wiki


REST API - ServiceNow Wiki


SOAP Web Service - ServiceNow Wiki



I recently used the SOAP API to send requests to an external web service and process the results into custom tables. The SOAP message must be called from a server side script (e.g Business Rule, Script Include etc), however I wanted to call it from the client page, and have the response returned to the client page without form save. To do this, I created a GlideAjax script include to handle communication between the client and server, and a SOAP function to handle the external communications. Even though I scripted the trigger and processing of these SOAP messages, they consisted of XML which was defined as a "SOAP Message" record in ServiceNow. If you configure your request envelope in that application you can trigger/test the integration by clicking a button (no coding!). Once you have it working there, you can look at scripting it to fit your overall objective.