WSO2——在jaggery应用程序中调用数据服务

WSO2 - call a data service within a jaggery app

本文关键字:调用 数据 服务 应用程序 jaggery WSO2      更新时间:2023-09-26

我们已经设置了数据服务,我们想在jaggery应用程序中调用这个数据服务。

这是我们的Jaggery Code:

function invokeWS() {
var ws = require("ws");
var ds = ws.WSRequest();
var options = new Array();
options.useSOAP = 1.2;
options.action = "urn:VerifyUserSession";
var payload = '<p:VerifyUserSession xmlns:p="http://..."><!--Exactly 1 occurrence--> <xs:SESSIONID xmlns:xs="http://...">fb9ecf05-751b-4eff-b454-11a9bee44be1</xs:SESSIONID> </p:VerifyUserSession>';
log.info(payload);
var result;
try {
    ds.open(options, 'http://localhost:9765/services/accountManagementDS', false);
    ds.send(payload);
    result = ds;
}
catch (e){
    return 'error';
}
return result.responseText;

}

下面是来自"TryIt"服务的数据服务:

<body>
   <p:VerifyUserSession xmlns:p="http://...">
      <!--Exactly 1 occurrence-->
      <xs:SESSIONID xmlns:xs="http://...">?</xs:SESSIONID>
   </p:VerifyUserSession>
</body>

我做错了什么吗?在使用ds.open()

时会抛出错误

您必须将WSRequest初始化为,

var ds = new ws.WSRequest();