Help using Base SAS procedures

proc http ssl connection problem

Reply
Contributor
Posts: 36

proc http ssl connection problem

Hi.

I want to connect to a web-service responding on an https://xx address which will return a text file.

- I use authentication to access it

- I use an SSL certificate and created a keystore with the releant certificate

- I set the -jreoptions in sassv9.cfg

Still the server reports "ERROR: java.io.IOException: Server returned HTTP response code: 500 for URL:". I can access the web-service web page manually with the url and it works. I believe there is something strange with the SSL certificate installation.

Do you have any ideas?

I run the following code:

filename in "c:\in.txt";
filename out "c:\out.txt";
filename hdrout "c:\hrdout.txt";
data _null_;
file in;
input;
put _infile_;
datalines4;
start=20101201T000000%2B0100&end=20101202T000000%2B0100
;;;;

proc http
in = in
out = out
headerout = hdrout
url = "https://losts.bio.ma.se/service/customer/events?"
method = "post"
ct = "application/x-www-form-urlencoded"

webusername = "username"
webpassword = "password"
run;

Contributor
Posts: 36

proc http ssl connection problem

I noticed that the XML content which the web-service returns has mixed security. The xml-tags are delivered over http, while the content in the tags are delivered over https.

This may be the reason for the ERROR:java.io.IOException behaviour. Is it possible to make SAS less sensitive to mixed content?

Contributor
Posts: 36

proc http ssl connection problem

Anyone who could figure this out?

Trusted Advisor
Posts: 1,300

proc http ssl connection problem

A response code of 500 means the webserver you contacted encountered an error.  This is a server side issue, not a client side issue.  Mixed security content would not cause this issue.  You should contact the site administator to have them help you sort out the issue.  You should additionally work with SAS tech support to further aide you since you are using sensitive information and public forum users cannot debug your issues with a private site requiring authentication.

Contributor
Posts: 36

proc http ssl connection problem

I have some additional information now.

The web service is a WADL service and it is sugested to access it using Apache HTTP components along with the below WADL file. However, I would like to access the XML file which the WADL service will return using SAS instead.

How would I do this in SAS? (Part of below can be done with SAS XML mapping of the returning XML file, but the issue is the communication with the WADL service to get the XML file)

<application xmlns="http://research.sun.com/wadl/2006/10" xmlns:xs="http://www.w3.org/2001/XMLSchema"><grammars><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified">

<xs:element name="DateIntervalSampleEventReport" type="DateIntervalSampleEventReport"/>
<xs:complexType name="DateIntervalSampleEventReport">
<xs:sequence>
<xs:element minOccurs="0" name="sender" type="xs:string"/>
<xs:element minOccurs="0" name="sendDate" type="xs:dateTime"/>
<xs:element minOccurs="0" name="boundFromDate" type="xs:dateTime"/>
<xs:element minOccurs="0" name="boundToDate" type="xs:dateTime"/>
<xs:element minOccurs="0" name="albs">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="alb" type="sampDTO"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sampDTO">
<xs:sequence>
<xs:element minOccurs="0" name="refId" type="xs:string"/>
<xs:element minOccurs="0" name="barco" type="xs:string"/>
<xs:element minOccurs="0" name="motherSampId" type="xs:string"/>
<xs:element minOccurs="0" name="motherSampTime" type="xs:dateTime"/>
<xs:element minOccurs="0" name="motherSampType" type="xs:string"/>
<xs:element minOccurs="0" name="motherSampArrivalTime" type="xs:dateTime"/>
<xs:element minOccurs="0" name="motherSampV" type="xs:string"/>
<xs:element minOccurs="0" name="donaId" type="xs:string"/>
<xs:element minOccurs="0" name="sampType" type="xs:string"/>
<xs:element minOccurs="0" name="sampStatus" type="xs:string"/>
<xs:element minOccurs="0" name="sampV" type="xs:string"/>
<xs:element minOccurs="0" name="firstHotTime" type="xs:string"/>
<xs:element minOccurs="0" name="concentration" type="xs:string"/>
<xs:element minOccurs="0" name="ratio" type="xs:string"/>
<xs:element minOccurs="0" name="events">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="event" type="event"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="deviations">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="deviation" type="deviation"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="event">
<xs:all>
<xs:element minOccurs="0" name="occuredAt" type="xs:dateTime"/>
<xs:element minOccurs="0" name="type" type="xs:string"/>
</xs:all>
</xs:complexType>
<xs:complexType name="deviation">
<xs:all>
<xs:element minOccurs="0" name="comment" type="xs:string"/>
<xs:element minOccurs="0" name="created" type="xs:dateTime"/>
<xs:element minOccurs="0" name="devType" type="xs:string"/>
<xs:element minOccurs="0" name="reporter" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:schema>
</grammars><resources base="https://lost.temp.test.com/server/"><resource path="/{role}/events"><method name="GET"><request><param name="start" style="query" type="xs:string"/><param name="end" style="query" type="xs:string"/></request><response><representation mediaType="application/xml"/></response></method></resource></resources></application>

Trusted Advisor
Posts: 1,300

proc http ssl connection problem

You are talking about something completely different now.  WADL (Web Application Description Language) is an XML framework that basically provides a description of how to interact programmtically with a web RESTful Web Service.  This WADL example you posts basically just provides a description of how to interact with the widget hosted at https://lost.temp.test.com/server/{role}/events (which is different than the first address you provided).  You do not interact with WADL, it is not a service.  The WADL document should be hosted on the webpage for you to retrieve if you desire, should it exist.  WADL is pretty uncommon in my experience.

Contributor
Posts: 36

proc http ssl connection problem

Finally I found the problem. It seems to be about how proc http handles url encoding of the "+" sign, i.e. "%2B".

This does not work.

filename in "c:\in.txt";
filename out "c:\out.txt";
filename hdrout "c:\hrdout.txt";
data _null_;
file in;
input;
put _infile_;
datalines4;
start=20101201T000000%2B0100&end=20101202T000000%2B0100
;;;;

proc http
in = in
out = out
headerout = hdrout
url = "https://losts.bio.ma.se/service/customer/events?"
method = "post"
ct = "application/x-www-form-urlencoded"

webusername = "username"
webpassword = "password"
run;

But this works:

filename in "c:\in.txt";
filename out "c:\out.txt";
filename hdrout "c:\hrdout.txt";
data _null_;
file in;
input;
put _infile_;
datalines4;
start=20101201T000000%2B0100&end=20101202T000000%2B0100
;;;;

proc http
/*in = in*/
out = out
headerout = hdrout
url = "https://losts.bio.ma.se/service/customer/events?

start=20101201T000000%2B0100&

end=20101202T000000%2B0100"
method = "post"
ct = "application/x-www-form-urlencoded"

webusername = "username"
webpassword = "password"
run;

Trusted Advisor
Posts: 1,300

proc http ssl connection problem

First let me start by appoligizing for not noticing this sooner...

The problem is most likely due to you improper inclusion of the question mark at the end of your url.  The HTTP procedure will iteself add this to the URL string so by having it there you are in essence submitting the URL with a double question mark (https://losts.bio.ma.se/service/customer/events??start=20101201T000000%2B0100&end=20101202T000000%2B0100).  I am surprised this works as you are not escaping what SAS should assume are macro's after the percent signs.  It doesn't have to do with URL Encoding, as it is properly encoded as %2B.  Using cards statement is safer because it will not try to resolve a macro with the percent sign:

filenameurl_parms temp;

data_null_;

fileurl_parms;

input;

put_infile_;

cards4;

start=20101201T000000%2B0100&end=20101202T000000%2B0100

;;;;

run;

/* could use this instead also

data _null_;

file url_parms;

input;

_infile_=urlencode(_infile_);

put _infile_;

cards4;

start=20101201T000000+0100&end=20101202T000000+0100

;;;;

run;

*/

filenameout temp;

prochttp url='https://losts.bio.ma.se/service/customer/events'

in=url_parms

out=out

method='post'

ct='application/x-www-form-urlencoded'

webusername='username'

webpassword='password';

run;

Contributor
Posts: 36

proc http ssl connection problem

It seems reasonable, but it does not work here. The one I showed works.

Trusted Advisor
Posts: 1,300

proc http ssl connection problem

That doesn't make a lot of sense to me.  The plus signs should work unencoded as well.  Please try:

filename url_parms temp;

data _null_;

file url_parms;

input;

put _infile_;

cards4;

start=20101201T000000+0100&end=20101202T000000+0100

;;;;

run;

filename out temp;

proc http url='https://losts.bio.ma.se/service/customer/events'

in=url_parms

out=out

method='post'

ct='application/x-www-form-urlencoded'

webusername='username'

webpassword='password';

run;

If you continue to have issues getting this type of code to work you should contact SAS Tech Support to have them help you resolve the issue as this should work.

Try executing this example, from a previous posting on the forum, which I can run myself and know is successful:

filename file temp;

filename infile temp;

data _null_;

  input;

  file infile;

  put _infile_;

  datalines4;

type=ALL&name=&sanction_date_from=&submit=Get+Actions+%3E%3E

;;;;

proc http

  in=infile

  url="http://www.health.ri.gov/lists/disciplinaryactions/results.php"

   method="post"

   ct="application/x-www-form-urlencoded"

  out=file;

run;

Ask a Question
Discussion stats
  • 9 replies
  • 1586 views
  • 0 likes
  • 2 in conversation