DATA Step, Macro, Functions and more

SOAP-request against Riksbanken doesn´t work

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

SOAP-request against Riksbanken doesn´t work

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
Solution
‎12-11-2017 07:49 AM
Occasional Contributor
Posts: 6

Re: SOAP-request against Riksbanken doesn´t work

Posted in reply to MagnusGustavsson

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


All Replies
SAS Super FREQ
Posts: 810

Re: SOAP-request against Riksbanken doesn´t work

Posted in reply to MagnusGustavsson

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

 

Occasional Contributor
Posts: 6

Re: SOAP-request against Riksbanken doesn´t work

Posted in reply to Bruno_SAS

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

 

 

Community Manager
Posts: 3,384

Re: SOAP-request against Riksbanken doesn´t work

Posted in reply to MagnusGustavsson

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.

SAS Super FREQ
Posts: 810

Re: SOAP-request against Riksbanken doesn´t work

Posted in reply to MagnusGustavsson

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

Occasional Contributor
Posts: 6

Re: SOAP-request against Riksbanken doesn´t work

Posted in reply to Bruno_SAS

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.

 

Solution
‎12-11-2017 07:49 AM
Occasional Contributor
Posts: 6

Re: SOAP-request against Riksbanken doesn´t work

Posted in reply to MagnusGustavsson

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;

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 187 views
  • 1 like
  • 3 in conversation