- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;