Help using Base SAS procedures

Call the same Web service multiple time for a list of records

Reply
New Contributor
Posts: 3

Call the same Web service multiple time for a list of records

Hi,

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.

Example:

data technicianlist;

  input idEmpl $6.;

  datalines;

817255

817787

834432

817095

run;

kind of...

filename request temp;

filename response temp;

filename mapRep "web_service_response.map";

libname response xmlv2 xmlmap=mapRep;

data responseListCallWebService;

   *for each record of technician list;

   set technicianlist;

*Create the request xml;

  file request;

  put "<employee>" idEmpl "</employee>"

  *Call the web service;

  webServiceUrl="toto";

  soapaction='getTeamMemberBySystemEmployeeId';

  rc=soapweb("request",webServiceUrl,"response",soapaction,,,,,,,);

  *Read the response XML returning from web service call

   and add read information it into the responseListCallWebService;

   set response.name;

run;

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....

Thanks

SAS Employee
Posts: 31

Re: Call the same Web service multiple time for a list of records

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.

New Contributor
Posts: 3

Re: Call the same Web service multiple time for a list of records

Thanks Bill.

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.

SAS Employee
Posts: 340

Re: Call the same Web service multiple time for a list of records

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.

Ask a Question
Discussion stats
  • 3 replies
  • 849 views
  • 0 likes
  • 3 in conversation