BookmarkSubscribeRSS Feed
Bilibob
Calcite | Level 5

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

3 REPLIES 3
BillM_SAS
SAS Employee

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.

Bilibob
Calcite | Level 5

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.

gergely_batho
SAS Employee

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2151 views
  • 0 likes
  • 3 in conversation