on 12-10-2012 11:37 AM
Hi,
I know some part of this topic was already discussed in the forum but I am facing a critical problem now. I found some tutorials regarding consuming SAP gateway service using HTML , but when I tried to use those for gw demo server (found in scn) , it shows nothing.
I debug the HTML code but didn't find anything. I am using datajs files for the same purpose.
I am badly stuck at this point.Suggestions are welcomed...
here is my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link type="text/css" rel="Stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/redmond/jquery-ui.css" />
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="datajs-1.0.0.min.js"></script>
<script type="text/javascript" src="jquery.tmpl.js"></script>
<script language="JavaScript" type="text/javascript">
//ODATA Root Service URI
var CUSTOMERS_ODATA_SVC = "http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders?$format=json";
//Page Load Actions
function OnPageLoad()
{
GetCustomers();
}
function GetCustomers()
{
$("#loadingCustomers").show();
alert("ok");
OData.defaultHttpClient.enableJsonpCallback = true;
OData.read( CUSTOMERS_ODATA_SVC, function (data)
{
var html = "";
for (var i = 0; i < data.results.length;i++) {
html += "<div>"+"Customer ID: "+data.results[i].OrderId+"<br/></div>"; html += "<div>"+"Company Name: "+data.results[i].CustomerId+"<br/></div>"; html +=
"<div>"+"Contact Name:"+data.results[i].SalesOrg +"<br/><br/></div>";
}
document.getElementById("target-element-id").innerHTML = html;
},
function (err) {
//Error Callback:
alert("Error occurred " + err.message);
}
);
}
</script>
</head>
<body onload="OnPageLoad()">
<div id="target-element-id" ></div>
</body>
</html>
Please suggest if anything wrong in this..
The error happened because of this line:
OData.defaultHttpClient.enableJsonpCallback = true;
You have to assign "false". Otherwise, your browser will send this link:
And you will get the error message in Firebug:
HTTP/500/E/Internal Server Error
Call of service /sap/opu/odata/sap/SALESORDERS/SOHeaders terminated because of an error. The following error text was processed in system HW1 : An exception occurred The error occurred on the application server iwdfvm3986. The termination type was: RABAX_STATE.If the termination type is RABAX_STATE, you will find more information on the cause of termination in system HW1 in transaction ST22. If the termination type is ABORT_MESSAGE_STATE, you will find more information on the cause of termination on the application server iwdfvm3986 in transaction SM21. If the termination type is ERROR_MESSAGE_STATE, you can search for further information in the trace file for the work process in transaction ST11 on the application server iwdfvm3986. You may also need to analyze the trace files of other work processes. If you do not yet have a user ID, contact your system administrator.
To make your application work, do some changes in the code:
var CUSTOMERS_ODATA_SVC = "http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders";
OData.read( { requestUri: CUSTOMERS_ODATA_SVC,
user: "GW@ESW",
password: "ESW4GW"}, function (data) {....}
More info regarding datajs: http://datajs.codeplex.com/wikipage?title=datajs%20OData%20API&referringTitle=Documentation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where are you passing the user credentials (user: GW@ESW) to access the OData service?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tobias,
Actually i am passing credentials like this :
http://GW@ESW:ESW4GW@gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders?$format=json
When I use this URL in firefox REST client, I got the result. But when I use in HTML5, I didn't get any result except blank page.
Thanks
Simadri
With a tool like Firebug (for Firefox) you can see if the browser is able to access the URL or if the web server is blocking the access.
When you log on to the Gateway system using your browser and than call your HTML5 page, does it work? As you are still authenticated thanks to your previous access, the server should respond with the JSON data.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.