I need your help on how to create a stored process to output data stream (xml) and deploy it as web service? SAS stored process need to stream outout a dataset as xml.
But when I test it on soap UI as a webservice no value was displayed on xml.
Kindly see the code below and the output from SOAP UI. I also attached the screenshots of the properties of the stored process.enter code here
CODE:
data chartxml; input price sell; datalines; 20 250 30 180 40 130 50 250 60 250 ; run; libname _webout XML XMLmeta=schemadata; data _webout.chartxml; set chartxml; run;
SOAP OUTPUT
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" <soapenv:Body <n:chartResponse xmlns:n="http://tempuri.org/Chart"> <n:chartResult/ </n:chartResponse> </soapenv:Body> </soapenv:Envelope>
Thanks,
Krishna
I wasn't able to run your example, but can advise that you are mixing up the (automatically available) _webout fileref by using it as a (manually defined) libref.
If you want to stream web output, you can do so by using it in a file statement, as follows:
data _null_;
file _webout;
put '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"' #;
put '<soapenv:Body <n:chartResponse xmlns:n="http://tempuri.org/Chart">' #;
put '<n:chartResult/ </n:chartResponse> </soapenv:Body> </soapenv:Envelope>';
run;
To 'deploy as a web service' your SAS code needs to be registered as a Stored Process (using SAS Management Console) with streaming output selected. You can then execute the STP by using a URL with the metadata location of the STP in the _PROGRAM parameter - like so:
http://YOURMACHINE:8080/SASStoredProcess/do?_PROGRAM=/MetaLoc/STP_Name
Related
Am trying to invoke campaign via SOAP request ,which is suppose to insert data into data warehouse,but it's not happening.am using DS2 code for it
When I try run the same campaign in test mode in SAS CI it's happening
I want the log that gets generated via SOAP request.can anyone let me know the path for the same.
Thanks in advance.
You need to check the log files on your application & mid-tier servers. Search the log files for the time you ran your request.
Start by checking the ObjectSpawner log to see if any connections were made the SAS environment at that time: ex. C:\SASHome\Lev1\ObjectSpawner\Logs
I am opening a new program in SAS Enterprise Guide using file -> new -> program.
Now I would like to a load .csv file from my desktop using the following code:
proc import datafile="C:\Users\M.van.der.Peet\Desktop\test.csv"
out=shoes
dbms=csv
replace;
getnames=no;
run;
proc print;
run;
When I run this I get the following error however:
ERROR: Physical file does not exist, C:\Users\M.van.der.Peet\Desktop\test.csv.
But the file is there :). Any thoughts on how I get a better understanding of why this is not working? Is there an ls() like function to see which files are stored in a dir?
If your EG session is connected to a remote SAS server (such as a Linux server) your code will not work.
Basically, when you press submit in EG, it uploads the code to the SAS server, executes the code, and downloads the results and log to the EG client. Since the remote server cannot see files on your local C: drive, you will get an error if you try to read a file on C:.
You can upload the file to the remote server, and it will work. Or if you look at the EG tasks in the menus, I'm sure there is an IMPORT task or similar name which would work. The task works by uploading the input file for you before the SAS code is submitted. I don't use the menus, so can't give you the details.
Enterprise Guide is typically installed on UNIX/Linux Server. You have to FTP the file i.e. upload the file using a FTP client like WinSCP or UltrEdit from Windows to a location on UNIX. Then you have to provide that path on your program.
I have created a SAS stored process and I need to attach it to a web service link which I intend to use it as an input in a python program .
I would really appreciate if I could get help in creating a web service from a SAS stored process .
Thank you,
Nishant
You need to create a Stored Process in SAS Management Console, and assign it to use the Stored Process Server (not Workspace Server). Ensure it has the 'streaming output' checkbox selected.
The SAS code behind this Stored Process should then send the output (that you wish to receive from your python program) to the _webout fileref, eg:
data _null_;
file _webout;
put 'Hello python!';
run;
The %stpbegin and %stpend macros should NOT be used.
To reference the Stored Process just call the URL with your Stored Process name & path in the _program parameter, as follows:
http://[yourMachineName]:8080/SASStoredProcess/do?_PROGRAM=/Your/MetadataPath/YourSTPName
Easiest is to use the SAS Stored Process Web App. It allows you to call a stored process via URL. You should read (http://support.sas.com/documentation/cdl/en/stpug/68399/HTML/default/viewer.htm#n0mbwll43n6sw3n1jhcfnx51i8ze.htm).
From there, use the Python requests library.
So, I want to use Google Url shortener Api, and I try to use
proc http
so, when I run this code
filename req "D:\input.txt";
filename resp "D:\output.txt";
proc http
url="https://www.googleapis.com/urlshortener/v1/url"
method="POST"
in=req
ct="application/JSON"
out=resp
;run;
(where D:\input.txt looks like {"longUrl": "http://www.myurl.com"} ) everything works greate on my home SAS Base 9.3. But, at work, on EG 4.3, I get:
NOTE: The SAS System stopped processing this step because of errors.
and no possible to debug. After googling, I found, that I have to set java system option like this
-jreoptions (-Djavax.net.ssl.trustStore=full-path-to-the-trust-store -Djavax.net.ssl.trustStorePassword=trustStorePassword)
But, where I can get "the certificate of the service to be trusted"- and password to it?
Edit: As I noticed in comments below, my work SAS installed into server, so I didn't have direct access to configuration. Also, It isn't good idea to change servers config. So, I try to google more, and found beautiful solution using cUrl, without X command (cause it block in my EG). Equivalent syntax is:
filename test pipe 'curl -X POST -d #D:\input.txt https://www.googleapis.com/urlshortener/v1/url --header "Content-Type:application/json"';
data _null_;
infile test missover lrecl= 32000;
input ;
file resp;
put _infile_;
run;
Hope it help someone
Where to get the certificate
Open the URL that you want the certificate from via Chrome. Click on the lock file in the URL bar, click on "details" tab and then click on "Save as file" in the bottom right. You will need to know what trust store you are going to use at this stage. See the following step.
The password and trust store is defined by you. It is in most cases nothing more than an encrypted zip file. There are a lot of tools out there that allow you to create a trust store, encrypt it and then import the certificates into it. The choice will depend on what OS you are using. There are some java based tools that OS independent, for example Portecle. It allows to define various trust stores on different OS and you can administer them remotely.
Regards,
Vasilij
Since upgrading to SAS 9.3, i'm only able to send emails within rsubmit, which isnt a problem... however i'm unable to attach local files, please can someone assit?
RSUBMIT;
FILENAME outmail EMAIL
SUBJECT="Daily report attached"
TO= ("xxxxx#xx.com")
ATTACH= "C:\Users\one\Desktop\Cars.xls";
DATA _NULL_;
FILE outmail;
PUT "Hello All,";
PUT ;
PUT "Please find attached the Cars report.";
PUT ;
PUT "Regards";
PUT ;
RUN;
I receive the following error message in the log:
ERROR: Error opening attachment file C:\Users\one\Desktop\Cars.xls.
ERROR: Physical file does not exist, /home/one/C:\Users\one\Desktop\Cars.xls.
Any help is much apriciated.
Thank you
Your RSUBMIT is being submitted on a server, so inside the RSUBMIT the paths are local to the server. Unless it can see your desktop (ie, via a mapped drive) it won't be able to access files on the local machine. You would have to upload them to the server first.