1
votes

I'm using SAS 9.2 and trying to retrieve an array of long values from a .NET web service. Here is my setup and call:

filename websvc url 'http://path.to/my/webservice?WSDL';
libname websvc xml92 xmltype=WSDL;

Data d;
    dataSchema = "blah";
    module = "blah";
run;

data strata;
    SET websvc.GetStrataForModuleResponse(parms=d);
run;

The webservice returns XML like this when I invoke it manually without SAS:

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfLong>
   <long>1</long>
</ArrayOfLong>

note I snipped the xmlns stuff from the above snippet.

When I call the web service from SAS I get a dataset with 1 variable and 1 observation. The name of the variable is "datatype=string" and the value is blank. With the parameters I should get back exactly what I see above.

I would expect to see a dataset with 1 variable and 1 observation where the variable is named long and the value of the observation is 1.

Is there something I am missing here?

Thanks in advance!

1

1 Answers

1
votes

The SAS libname engine is very restricted in the structure is requires. If your XML is not conform the required structure you need to create an XML to tell SAS how to read the XML file. The easiest way to do this is by using the SAS XML Mapper. For you current service the XML map would be like this:

<?xml version="1.0" encoding="UTF-8"?>
<SXLEMAP xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="webservice" version="1.2" xsi:noNamespaceSchemaLocation="http://www.sas.com/xml/schema/sxle12.xsd">
    <TABLE name="ArrayOfLong">
        <TABLE-PATH syntax="XPath">/ArrayOfLong</TABLE-PATH>
        <COLUMN name="long">
            <PATH syntax="XPath">/ArrayOfLong/long</PATH>
            <TYPE>numeric</TYPE>
            <DATATYPE>integer</DATATYPE>
        </COLUMN>
    </TABLE>
</SXLEMAP>

In your SAS code you should add a filename statement to your map and add the map to your libname statement.

filename wdslmap 'webservice.map';
libname websvc xml92 xmltype=WSDL xmlmap=wdslmap;