如何使用 proc http 和 http_tokenauth 在后台调用 SAS STP [英] How to call a SAS STP in background using proc http and http_tokenauth

查看:105
本文介绍了如何使用 proc http 和 http_tokenauth 在后台调用 SAS STP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用选项背景通过 proc http 从 SAS 调用存储进程 (STP),以确保我的主进程不会等待 STP 完成.我确实使用以下代码:

I'm trying to call a stored process (STP) from SAS via proc http using the option background, to ensure that my main process does not wait for the STP to be finished. I do use the following code:

filename resp "<path to response file>";
%let url = https://<ServerName>:<port>/SASStoredProcess/do;
%let question_mark = ?;

proc http
url="%str(&url.)&question_mark.%nrstr(_action=background&_program=<path to STP>&num1=11&num2=22)"
out=resp
http_tokenauth;
HEADERS "Content-Type"="application/x-www-form-urlencoded" "Accept"="application/json";
quit;

不幸的是,在我的响应文件中,我总是收到 SAS 登录页面.

Unfortunately, in my response file I do always receive the SAS logon page.

将用户名/密码作为我的 URL 的一部分发送确实有效,但出于安全原因不希望这样做.因此我需要使用 http_tokenauth,它适用于非背景 STP.此外,当我将 URL 粘贴到浏览器时,它确实有效.

Sending username/pw as part of my URL does work, but it is not wanted for security reasons. Hence I need to use http_tokenauth, which works for non background STPs. Also, when I just paste my URL to the browser, it does work.

如何确保使用 proc http 和 http_tokenauth 也能正常工作?

How can I ensure it does also work using proc http and http_tokenauth?

附加信息:

设置:

我确实有一个 STP,它由流程引擎通过 REST 调用,并期望立即得到包含 ID 的答案.(主 STP)这个主 STP 然后需要调用一个包含一个进程的子 STP,这将大约需要一小时才能完成.因此,我不希望主 STP 等待子 STP 完成.因此子STP应该在后台调用.

I do have a STP which is called by a process engine via REST and expects an immediate answer containing an ID.(Main STP) This main STP then needs to call a sub STP containing a process, which will approx. take one hour to be finished. Hence I do not want the Main STP to wait for the sub STP to be finished. Therefore the sub STP should be called in background.

推荐答案

令牌认证仅在使用do1"时有效;而不是做".参考文档:https://documentation.sas.com/?docsetId=stpug&docsetTarget=n0ax7wadghvldwn1bbarfuly6adl.htm&docsetVersion=9.4&locale=en

Token authentication only works when using "do1" instead of "do". Referring to documentation: https://documentation.sas.com/?docsetId=stpug&docsetTarget=n0ax7wadghvldwn1bbarfuly6adl.htm&docsetVersion=9.4&locale=en

此外,我使用查询来传递我的参数,这使其更加清晰.

Furthermore I'm using query to pass my parameters, which makes it more clear.

所以现在确实有效:

%let url = https://<ServerName>:<port>/SASStoredProcess/do1;

proc http 
  url="%str(&url.)"
  query=("_action"             = "background"
         "_program"            = "<path to STP>"
         "num1"                = "1"
         "num2"                = "2"
         )
  ct="application/x-www-form-urlencoded"
  http_tokenauth
  out=resp;
quit;

这篇关于如何使用 proc http 和 http_tokenauth 在后台调用 SAS STP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆