BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

I´m trying to get some exchange-rates from the "Riksbanken" see <https://swea.riksbank.se/sweaWS/docs/api/index.htm>. I´m doing this with the following code:

 


filename request "%sysfunc(getoption(work))\request.xml";
filename response "%sysfunc(getoption(work))\response.xml";

data _null_;
file request;
input;
put _infile_;
datalines4;
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://swea.riksbank.se/xsd">
<soap:Header/>
<soap:Body>
<xsd:getInterestAndExchangeRates>
<searchRequestParameters>
<aggregateMethod>W</aggregateMethod>
<datefrom>2017-01-01</datefrom>
<dateto>2017-02-01</dateto>
<languageid>en</languageid>
<min>false</min>
<avg>true</avg>
<max>true</max>
<ultimo>false</ultimo>
<!--1 or more repetitions:-->
<searchGroupSeries>
<groupid>6</groupid>
<seriesid>SETB1MBENCHC</seriesid>
</searchGroupSeries>
</searchRequestParameters>
</xsd:getInterestAndExchangeRates>
</soap:Body>
</soap:Envelope>
;;;;
run;

%let request=request;
%let response=response;
proc soap
in=&request
out=&response
url="https://swea.riksbank.se:443/sweaWS/services/SweaWebServiceHttpSoap12Endpoint";
run;

 

The error code that is returend "403" is stated to be due to wrong parameters - but when I tried in another tool - the same soap request worked fine.

 

Any help is appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
MagnusGustavsson
Fluorite | Level 6

This is now solved.

The solution was to add a "soapaction" => soapaction="urn:getInterestAndExchangeRates" and also to change the xmlns: so that the full request is:

 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://swea.riksbank.se/xsd">
<soap:Header/>
<soap:Body>
<xsd:getInterestAndExchangeRates>
<searchRequestParameters>
<aggregateMethod>W</aggregateMethod>
<datefrom>2017-01-01</datefrom>
<dateto>2017-12-01</dateto>
<languageid>en</languageid>
<min>false</min>
<avg>true</avg>
<max>true</max>
<ultimo>false</ultimo>
<!--1 or more repetitions:-->
<searchGroupSeries>
<groupid>6</groupid>
<seriesid>SETB1MBENCHC</seriesid>
</searchGroupSeries>
</searchRequestParameters>
</xsd:getInterestAndExchangeRates>
</soap:Body>
</soap:Envelope>

 

and proc soap code:

 

proc soap
in=request
out=response
url="https://swea.riksbank.se:443/sweaWS/services/SweaWebServiceHttpSoap12Endpoint"
soapaction="urn:getInterestAndExchangeRates";
run;

 

View solution in original post

6 REPLIES 6
BrunoMueller
SAS Super FREQ

Run your code with the DEBUG= option, see below

proc soap
in=request
out=response
url="https://swea.riksbank.se:443/sweaWS/services/SweaWebServiceHttpSoap12Endpoint"
debug="c:\temp\soap.txt"
;
run;

According to the doc you also need tp specify some options to make the HTTPS protocol work, see here

http://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=proc&docsetTarget=n0ugstrmu2wf...

 

MagnusGustavsson
Fluorite | Level 6

Hi and thanks for the reply.

There´s also an other url that can be used without https - "http://swea.riksbank.se:80/sweaWS/services/SweaWebServiceHttpSoap12Endpoint".

I tried that also but the same error.

 

From the debug log I can see the following information:

 

2017-12-06 10:49:18,679 DEBUG [httpclient.wire.header] << "HTTP/1.1 403 Forbidden[\r][\n]"
2017-12-06 10:49:18,679 DEBUG [httpclient.wire.header] << "HTTP/1.1 403 Forbidden[\r][\n]"
2017-12-06 10:49:18,679 DEBUG [httpclient.wire.header] << "Date: Wed, 06 Dec 2017 09:49:18 GMT[\r][\n]"
2017-12-06 10:49:18,679 DEBUG [httpclient.wire.header] << "Server: Apache[\r][\n]"
2017-12-06 10:49:18,679 DEBUG [httpclient.wire.header] << "Content-Length: 257[\r][\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.header] << "Content-Type: text/html; charset=iso-8859-1[\r][\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.header] << "[\r][\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.content] << "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">[\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.content] << "<html><head>[\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.content] << "<title>403 Forbidden</title>[\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.content] << "</head><body>[\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.content] << "<h1>Forbidden</h1>[\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.content] << "<p>You don't have permission to access /sweaWS/services/SweaWebServiceHttpSoap12Endpoint[\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.content] << "on this server.<br />[\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.content] << "</p>[\n]"
2017-12-06 10:49:18,680 DEBUG [httpclient.wire.content] << "</body></html>[\n]"

 

But as I mentioned above - it works fine to fetch from other tools than SAS...

 

 

ChrisHemedinger
Community Manager

Does your network require a proxy server to get to the internet?  Usually this is handled automatically, with proxy scripts, from any browser-based tools. But SAS is its own HTTP client, and you might need to specify PROXYHOST= and related options on the PROC SOAP statement.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
BrunoMueller
SAS Super FREQ

I suggest to contact SAS Technical Support

 

I suspect it has something to do with how Proc SOAP calls the web Service, SOAP 1.1 vs 1.2

MagnusGustavsson
Fluorite | Level 6

Hi Bruno,

 

Thanks for your reply.

Yes I did that just now and I if they come up with a solution I will post it here for others to know.

 

MagnusGustavsson
Fluorite | Level 6

This is now solved.

The solution was to add a "soapaction" => soapaction="urn:getInterestAndExchangeRates" and also to change the xmlns: so that the full request is:

 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://swea.riksbank.se/xsd">
<soap:Header/>
<soap:Body>
<xsd:getInterestAndExchangeRates>
<searchRequestParameters>
<aggregateMethod>W</aggregateMethod>
<datefrom>2017-01-01</datefrom>
<dateto>2017-12-01</dateto>
<languageid>en</languageid>
<min>false</min>
<avg>true</avg>
<max>true</max>
<ultimo>false</ultimo>
<!--1 or more repetitions:-->
<searchGroupSeries>
<groupid>6</groupid>
<seriesid>SETB1MBENCHC</seriesid>
</searchGroupSeries>
</searchRequestParameters>
</xsd:getInterestAndExchangeRates>
</soap:Body>
</soap:Envelope>

 

and proc soap code:

 

proc soap
in=request
out=response
url="https://swea.riksbank.se:443/sweaWS/services/SweaWebServiceHttpSoap12Endpoint"
soapaction="urn:getInterestAndExchangeRates";
run;

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 1784 views
  • 1 like
  • 3 in conversation