cancel
Showing results for 
Search instead for 
Did you mean: 

User is not authorized to use destination (package: ..., name: ...)

Former Member
0 Kudos

Hi All,

Perhaps someone has already tried to call a Web Service from HANA via .xshttpdest.

Here is the destination file: name = sapmmcS74.xshttpdest

host = "10.66.176.252";

port = 50013;

description = "sapmmc on S74";

useSSL = false;

pathPrefix = "/SAPControl.cgi";

authType = none;

useProxy = false;

proxyHost = "";

proxyPort = 0;

timeout = 0;

and the corresponding server-side javascript is:

//<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:SAPControl">

//<soapenv:Header/>

//<soapenv:Body>

// <urn:GetSystemInstanceList>

//    <timeout>0</timeout>

// </urn:GetSystemInstanceList>

//</soapenv:Body>

//</soapenv:Envelope>

try{

var soapenv = "";

soapenv = soapenv.concat("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:SAPControl\">");

soapenv = soapenv.concat("<soapenv:Header/>");

soapenv = soapenv.concat("<soapenv:Body>");

soapenv = soapenv.concat("<urn:GetSystemInstanceList>");

soapenv = soapenv.concat("<timeout>0</timeout>");

soapenv = soapenv.concat("</urn:GetSystemInstanceList>");

soapenv = soapenv.concat("</soapenv:Body>");

soapenv = soapenv.concat("</soapenv:Envelope>");

var dest = $.net.http.readDestination("services", "sapmmcS74");

var client = new $.net.http.Client();

var req = new $.web.WebRequest($.net.http.POST, soapenv);

client.request(req, dest);

var response = client.getResponse();

if(response.body){

  $.response.setBody(response.body.asString());

}

else {

  $.response.setBody( "error" );

}

$.response.status = response.status;

$.response.contentType = "text/xml; charset=utf-8";

}

catch(x){

  $.response.status = 500;

  $.response.setBody( x.message );

}

Both are in the same package/folder "services".

When I test the .xsjs I receive always the error: User is not authorized to use destination (package: services, name: sapmmcS74).

I assigned all possible authorities in HANA to my user: sap.hana.xs.admin.roles::HTTPDestAdministrator as well as package privileges etc. but the error is not resolved.

Any ideas?

Thanks,

Hristina

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

The same issue was solved when I put .xshttpdest file and .xsjs file in the same package (technically in the same folder)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Yes this is as-designed. As security measure these must be in the same package.

0 Kudos

Hi Thomas,

I am getting same issue even though i kept both .xshttpdest and .xsjs file under same folder.

Package hierarchy is as shown below.

Found the following errors:

===========================

Error: User is not authorized to use destination (package: testApp, name: Images) (line 3 position 0 in /workshop/sessiona/00/LatestXS/Bhupender/httpdestination/searchImages.xsjs)

line 3 is :- var dest = $.net.http.readDestination("testApp", "Images");

Thanks

Bhupender

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The package hierarchy that you show in your screen shot is the not the same as the one in your code or the error message.  In your code your package is testApp, but the package hierarchy in your screen shot is LatestXS.Bhupender.httpdestination. I would assume your source code is incorrect here shouldn't be using testApp as the package path to the Images.xshttpdest.

0 Kudos

Hi Thomas,

Yes you are right, thanks a lot.

Thanks

Bhupender

0 Kudos

Hi Thomas,

I was going through your video regarding outbound connectivity, it was really helpful.

(XSJS Outbound Connectivity SPS6 - YouTube)

I am facing one issue with the last part.

when i execute my .xsjs file

Found the following errors:

===========================

Error: HttpClient.getResponse: Can't get the response from the server. The following error occured: internal error occurred "Connection to www.loc.gov broke down while reading response." (line 11 position 0 in /workshop/sessiona/00/LatestXS/Bhupender/httpdestination/searchImages.xsjs)

line 11 := var response = client.getResponse();

Thanks

Bhupender

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Does this error happen consistently?  I've never seen it before but broken down while reading response makes it sound like you had a connection to the remote server and then lost it. Seems like something that would transitory.  Have you tried other destinations?  Are your proxy settings correct?

0 Kudos

Hi Thomas,

I am not able to connect to this remote server even once.

And yes, I am able to connect to host = "download.finance.yahoo.com" which is explained in HANA developer guide.

And sir, As i am using AWS HANA instance. So i set useProxy = false;


let me know if i am going wrong somewhere.


Thanks

Bhupender

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>So i set useProxy = false;


Your an SAP Employee, are you running AWS via the CAL? In which case there is an option to run it within the SAP network via a virtual private network. In this case you do need the proxy.

0 Kudos

Hi Thomas,

In case i set the proxy then error comes to  line  "client.request(req, dest);"

Found the following errors:

===========================

Error: HttpClient.request: request failed. The following error occured: unable to establish connection to proxy:8080 - internal error code: resolving DNS host name failed.

This  scenario is faced by one of our customers, who are not SAP Employee and their AWS instance is not running through the CAL.

Thanks

Bhupender

Answers (1)

Answers (1)

former_member317580
Discoverer
0 Kudos

Did you find a resolution to this problem?  I'm having the same issue here on a Hana 70 instance.

Former Member
0 Kudos

Same issue.

I read this comment maybe it could help you.

I moved the .xshttpdest in the same package where it is used and know it works.

former_member317580
Discoverer
0 Kudos

I was able to get it working as long as the referencing XSJSLib, xsjs and the xshttpdest files were all in the same package.