Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

SOAP web services using cURL from mainframe

KeithD
Kilo Explorer

Hi all,
I've put together a basic web service script and associated SOAP getRecords message. I can call this successfully using wget from a windows command prompt and it returns expected values. However, I am required to get this running using cURL and BPXBATCH on our IBM mainframe via a proxy server. It is this method I am having trouble with. Tracing the http traffic seems to show all is well but no data is returned. All necessary authentication passes with no http errors. I am inclined to believe that the problem is with the soap envelope that I am passing in with my cURL request but can't be certain and I have made a number of attempts at ensuring that it is UTF-8 encoded before being posted.
If anyone has made the mainframe->cURL->SOAP journey to servicenow successfully, I'd be most grateful if you could offer any suggestions based on the following SOAP cURL script syntax. I have obfuscated our proxy etc to maintain our privacy 🙂 soaphex contains a UTF-8 soap request envelope.

sh /usr/lpp/ported/bin/curl -k -x aaa.bbb.ccc.ddd:8080 -u admin:admin
-d @/soaphex
--header "Content-Type: application/soap+xml; charset=utf-8; SOAPAction: http://www.service-now.com/TESTKD/getRecords"
--trace-ascii /tmp/bpxtrace.txt
"https://demo05.service-now.com/TESTKD.do?SOAP" >>/tmp/soapout.xml

Obviously this web service script and the soap definition get wiped out during the daily demo instance restore but I always make sure that they'ves been reapplied before testing. I also run the wget just to make myself feel more optimistic before trying cURL again.

The working wget command is:
wget -e "https_proxy = https://aaa.bbb.ccc.ddd:8080" -d -q --post-file=c:/SoapRequest.xml --header="Content-Type: application/soap+xml" --user=admin --password=admin --no-check-certificate "https://demo05.service-now.com/TESTKD.do?SOAP" --output-document=f:\soapResponse.csv

I'm confident that I'm connecting to the instance correctly because I do occasionally receive data regarding errors. For example, if I remove the SOAPAction header from the curl parameters I receive html in the response for a servicenow site error with the script.

Any help would be really, really gratefully accepted,
Thanks,
Keith

2 REPLIES 2

KeithD
Kilo Explorer

Sorry for answering this myself but I thought I should note down the resolution.
Removing the charset=utf-8 from the header and ensuring that I FTP'd the UTF-8 text file (that worked with wget) straight into USS with no intermediate z/OS ISPF editing appears to have done the trick. I had previously been FTPing to a non USS file and then copying to one which was introducing occasional 'dodgy' characters.

Thanks,
Keith


lawrence_eng
Administrator
Administrator

Thanks for coming back and sharing your solution!

best,
Lawrence