04-20-2015 05:13 PM
We have a lot of SOAP web services in our company. Those Soap web service use a XML file for request and a XML file for response. We use them sometime with SAS program. The issue we got is when we want to call multiple time the same web service for differents values. I would like with data steps to call the same web service for a list of value that we have in a SAS dataset. The goal of all that is to retreive all this information in a single dataset.
input idEmpl $6.;
filename request temp;
filename response temp;
filename mapRep "web_service_response.map";
libname response xmlv2 xmlmap=mapRep;
*for each record of technician list;
*Create the request xml;
put "<employee>" idEmpl "</employee>"
*Call the web service;
*Read the response XML returning from web service call
and add read information it into the responseListCallWebService;
Somebody have a simple way to do that? I know that I can do that with SAS macro, but I use macro only when there is really necessary. Really painfull to debug....
05-08-2015 01:55 PM
I do not have code that does exactly what you want to do. I did present a SAS Global Forum paper that details many of the pieces you will need (SOAP procedure, XML LIBNAME engine, XML Mapper application, etc.). It also includes working code examples. You can download the paper and example code from the SAS Support web site, Technical Papers and Presentations made by SAS staff. Scroll down to the link for the paper, "The Ins and Outs of Web-Based Data with SAS". The examples are available from the link to the zip file.
05-08-2015 02:25 PM
We use the soap procedure, the xml libname and the xml mapper. Those statements are designed for a one time call. If we want to call the same web service multiple time we need to encapsulated those statement in a SAS macro. We can then loop.
05-09-2015 09:34 PM
I suggest first writing all the responses to a temporary file, and than reading that file with the xml libname engine.
Instead of the static filename and file statements you can use the more dynamic filename(), fopen(), etc functions inside the data step. Taking your example you would create 4 temporary files inside the data step and then using them in the soapweb() function.
But maybe you can also re-use the one single file (reqest - in your example) - have you tried that?
If everything is working fine, you could also try to dynamically create xml librefs pointing to dynamically created files inside the data step ( libname() function ). But I think this would be slower then the "first write all responses to a file" approach.
If your xml is simple enough, you could avoid using xml libname engine, and reading the SOAP responses directly with string processing functions.
If you have a working example, that calls a public web service with static methods (PROC SOAP), you could share it here, so we can enhance it.