Good morning,
I'm using eclipe and tomcat to develop and test a sapui5 mobile application that speaks with a SAP OData service. After the development fase the application will be installed on the SAP server.
I'm trying to use the User interface services (sap.ui2) to access user information.
My problem is that it seems that this API is not prepared to be called/used from an application that is not deploy on a SAP Server. All the calls I see being made are relative calls and because of that the resources are not found.
Heres a full sample:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script src="<my-sap-server>/sap/public/bc/ui2/services/sap/ui2/srvc/error.js"></script>
<script src="<my-sap-server>/sap/public/bc/ui2/services/sap/ui2/srvc/utils.js"></script>
<script src="<my-sap-server>/sap/public/bc/ui2/shell-api/sap/ui2/shell/startup.js"></script>
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal">
</script>
<script>
var user = sap.ui2.shell.getUser();
user.load({
// depthAtRoot: 1,
// nodeId: " ",
// depthAtNode: 1
},
function() {
//set user data in the json model
alert(user.getFullName());
},
function(sErrorMessage) {
/* failure handler: e.g. display load error */
alert(sErrorMessage);
}
);
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
And the error:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/sap/bc/ui2/start_up?depth=0
2014-10-07 10:30:10 Error 404 in response for URL /sap/bc/ui2/start_up?depth=0 - sap.ui2.srvc
As shown, the API assumes the ui2 is deployed on my local server and not on the remote SAP server from where I loaded the libraries.
I've search the sap.ui2 API and didn't found a way to change this behaviour.
Without this I have 2 alternatives:
1 - Start using the SAP Server for testing - this is not ideal for me because development and testing would take longer
2 - Manually invoke the URL http:///sap/bc/ui2/start_up?depth=0 to a standard SAPUI5 JSONModel - Not desirable because if the SAP teams decides to change something my application can become broken.
Any thoughts on this matter?
Thanks in advance.