Please Note: I recently created an update set that makes this process a lot smoother. I recommend you check out that post as it may deprecate the information here. Check out the post and Update Set at: Load and Flatten a Remote WSDL
I am often faced with a dilemma when I am given the URL to a WSDL for me to consume, but the WSDL URL resides behind a customer’s firewall. Since the ServiceNow instance is in the cloud, it cannot get the WSDL in order to setup the SOAP Message record in the instance. Usually I have to email the customer and ask that they download the file for me and email it to me. I then paste the WSDL into the WSDL field of the new SOAP Message record.
In order to bypass this step, I have created a MID Server Background Script that will allow me to get a WSDL that exists behind a firewall. Of course, this requires a MID Server, but you should have one installed if you hope to send SOAP requests to the endpoint as it too will reside behind the firewall.
In order to get the WSDL via the MID Server, follow these quick steps:
1. Browse to the MID Server Background Scripts module & select the correct MID Server
You can set your filter to “MID Server” in the navigation pane. This will bring up the MID Server Application. Click on the “Scripts – Background” link (you have to be a ServiceNow maintenance user to do this). Then select the MID Server that will be grabbing the WSDL contents.
2. Paste and configure the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | //ENTER THE WSDL URL IN THE LINE BELOW var wsdl = "http://137.65.1.25/jjasys/WSDL/public/mapping02/Create_GMP_WSDL"; var httpclient = Packages.org.apache.commons.httpclient; var HttpClient = httpclient.HttpClient; var GetMethod = httpclient.methods.GetMethod; var client = new HttpClient(); var get = new GetMethod( wsdl ); var status = client.executeMethod( get ); // print the status and response var result = ("\n\n"+get.getResponseBodyAsString()); ms.log(result); get.releaseConnection(); |
Once you have pasted this script into the Script field, modify the “wsdl” variable to contain the URL to your WSDL.
3) Execute the Script
Now click the “Run Script” button. You will be redirected to a screen that will pull the ECC Queue for a response to the execution of your script.
Once the MID Server responds with the result, you should see it on the page as shown below:
4) Copy the WSDL and save it in the SOAP Message Record
Copy the WSDL document and paste it into your SOAP Message’s WSDL field:
Make sure that the “Download WSDL” checkbox is unchecked. Also, verify that you copied the WSDL XML properly from the script response, otherwise you will get an XML error.
Good one John. Love it.