on 09-04-2015 1:12 PM
Hi colleagues,
I am encountering an error while querying the backend system from an Android application via HCP Mobile Services.
De Detailed scenario
The error: detailed
<html>
<head>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
</head>
<body style="background-color:#FFFFFF" onload="var url=window.location.hash;if(url&&0!==url.length){var anchorCookie='oucrswcyzlzsqgnrqjjsuklxd_anchor="'+encodeURIComponent(url)+'"';document.cookie=anchorCookie}document.forms[0].submit()">
<p>
<script language="javascript">document.write("Please wait ...");</script>
</p>
<noscript>
<p>Note: Your browser does not support JavaScript or it is turned off. Press the button to proceed.</p>
</noscript>
<form method="post" action="https://accounts.sap.com/saml2/idp/sso/accounts.sap.com">
<input type="hidden" name="SAMLRequest" value="PEF1dGhuUmVxdWVzdCB4bWxucz0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOnByb3RvY29sIiB4bWxuczpuczI9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24iIHhtbG5zOm5zMz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnIyIgeG1sbnM6bnM0PSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGVuYyMiIEFzc2VydGlvbkNvbnN1bWVyU2VydmljZVVSTD0iaHR0cHM6Ly9yb290YzUyMjc4MzB0cmlhbC5oYW5hdHJpYWwub25kZW1hbmQuY29tL1NlcnZpY2VzLnN2Yy9Db21wYW55TG9jYXRpb25zPyRmb3JtYXQ9anNvbiIgRGVzdGluYXRpb249Imh0dHBzOi8vYWNjb3VudHMuc2FwLmNvbS9zYW1sMi9pZHAvc3NvL2FjY291bnRzLnNhcC5jb20iIEZvcmNlQXV0aG49ImZhbHNlIiBJRD0iU2E1OTY2MGQ3LTkyMjUtNDhiYi05OWFlLWEwODNjOTNhNTI1ZC1ucjJmSXJ0U05JaEZkemVCZUZTNjVaZHAwY3pBcVJIR3BXdHgxZmRWWXZRIiBJc3N1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2ttcjRGM3ptZHZxZzBpbEZrTGt3L09qQ3Y3RndmYzFnLzFlQ1J5Y2Q0cUdxZGMyc2J6S3FWTXFFSjR1czY0ZFhrZ3FmMXg1TXZCdFFqcFRtekJETUxjc3lET1MyT09CS1hiMHAvNm11QWdsVk82dlFFdUpRdFlSd2Jaa2lZeWZkWThRTTF3SEMxRG1kK09WdERMNTlMUVNtWUJFbThSKzErNUw1VG8rME5MTGtkWmkrNEZHOTBFSXhrcXhFUy9admZMcW9RQ3VCdkZRSW1qV05NbUtJVDJad2ozVUFCR3d6Qjl4blhIRXNVeGF4ZXNIZlFZM0Rid3pJa2UycXFDUWVzRlV3eEFvV21ZZ2NSUkozSm1ZRE5SY1hwcnhCYkZQazdreUV3bExzQy9UMFFaLzFzVCttT011Q3Y2L0VCamFpSWRjZlprSk8rZz09PC9kczpTaWduYXR1cmVWYWx1ZT48L2RzOlNpZ25hdHVyZT48L0F1dGhuUmVxdWVzdD4="/>
<input type="hidden" name="RelayState" value="oucrswcyzlzsqgnrqjjsuklxd"/>
<noscript>
<input type="submit" value="Continue"/>
</noscript>
</form>
</body>
</html>
What I have tried
I really don't know where to look anymore. Has anyone ever encountered this error?
Thanks,
Christopher.
Hi Christopher,
What is the type of backend url configured for your app in HCPms admin portal? If it is an Odata service you could use an HTTP request to get the response then parse it and show the data easily. You could even use sapui5.
If the backend url is a non Odata service you have to find the way on how to make a request and get the response then parsing it to show the data in the app.
You could have a look at this blog on how to use Logon plugin and use Odata requests: If using SMP SDK SP09+:
Note: If you are using a non Odata service as backend url you will not get all the benefits of HCPms since the SDK is developed for Odata based data sources.
Regards, Midhun
SAP Technology RIG
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Midhun,
Yes, I am using an OData service. I am using SAP UI5 as well in fact. I think this is not so much related to the Logon plugin though, because my application can successfully register with the HCPms application. Each registration appears in the HCPms cockpit and I use the corresponding registration ID in the Ajax query. The error occurs when the HCPms application sends the Ajax query over to the backend system. The backend system requires a SAP ID authentication before it sends back any data and the Javascript needed for that to go through can't be executed. I can't figure out why.
Hi Christopher,
I hope that you are sending the credentials and application connection ID with all the requests you are making. Could you provide the code you used.
There is a sample code on how to make an Odata request to a backend through SMP here: (specifically you have to look at the read() inside the file register3.html).
Regards, Midhun
SAP Technology RIG
Hi,
Yes, I do send the correct credentials and the application connection ID (or any one registered connection ID) in each request I make.
I had a look at that read() method. My way of sending the Ajax call was slightly different, but I was returned the same error when I tried the sample's way of doing it.
Here is my code :
function ajaxCall1(locId) {
jQuery.ajax(
{
url: applicationContext.applicationEndpointURL + "/CompanyLocations?$format=json",
type: 'GET',
headers: oHeaders,
contentType: 'application/json',
async: false,
success: function(data, textStatus, jqXHR) {
oResult.companyLocations = data.d.results;
ajaxCall2(locId);
},
error: function(responseData, textStatus, errorThrown){
alert("Error retrieving odata 1: " + responseData);
alert(textStatus);
alert(errorThrown);
}
}
);
}
At debug time :
Hi Christopher,
This means that the response format is HTML. You have to find a way how to parse HTML. This is not related to Kapsel or SMP.
Are you sure that you are using Odata as end point url? Because Odata supports only two data formats: XML and JSON. It will not give you HTML response. Ref. http://www.odata.org/documentation/odata-version-2-0/json-format/
If you using a non Odata service as end point URL, you will not get all the benefits of HCPms.
Regards, Midhun
SAP Technology RIG
Hi Midhun,
I realise the answer is HTML. The answer is only HTML because the logon cannot be done. It is not supposed to be HTML. It is supposed to be JSON. Cf the backend link to which the mobile services redirect https://rootc5227830trial.hanatrial.ondemand.com/Services.svc/CompanyLocations?$format=json . This is the data that is supposed to be returned. It cannot be accessed because the logon failed, and therefore the HTML page on which the logon failed is returned.
Midhun,
I have finally got it working! I am still not 100% sure what the reason was (perhaps a combination of different settings in the app that were wrong) but I think part of the issue was due to the wrong trust settings in HCP - it works with the following settings : default configuration type, and Enabled Principal propagation / Force authentication (not Default).
Thanks for your links, they were a great help.
Best regards,
Christopher
EDIT : I now know what did the trick. In the application configuration on HCP, by setting each of the Authentication configuration to "User name and password", I avoided the Javascript login mechanism and could therefore authenticate using the headers of the HTTP request.
Discussion successfully moved from SAP HANA Cloud Platform Developer Center to SMP Developer Center
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I am having an issue in consuming the backend odata in my hybrid android app. I have created an application in HCPms and the backend url -odata which I have created in the hcp xs applicaiton in my trial instance - https://s8hanaxs.hanatrial.ondemand.com/p1940680127trial/warroom/Esplanade/Esplanade/odata/Esplanade...
I enabled the basic authentication and saved my user credentials in the HCPms backend tab, when the metadata request is called from the component.js of app it is failing with an error - {message: "Failed to execute 'send' on 'XMLHttpRequest': Fail…anatrial.ondemand.com/com.kapsel.push/$metadata'.", request: undefined, response: undefined}
But the same application if i change my hcp odata service to ES1 - http://sapes1.sapdevcenter.com:8080/sap/opu/odata/sap/ZGWSAMPLE_SRV/
with no other changes, this metadata call from the component.js is getting success 200ok.
I am not sure what is wrong, or is there any other way of handling hcp xs application odata service in hcpms.
Regards,
Kishore Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
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.