Skip to Content

Using SCP Predictive Service in Java app

I need to call Predictive Services inside Java servlet. When I make GET request for retrieving registered datasets using the link /api/analytics/dataset (where is https://aac4paservices . hanatrial.ondemand.com/com.sap.aa.c4pa.services) using class CloaseableHttpClient, I get the following HTML page that says that Javascript is not supported.

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
    <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='oucrsrzceptfcaokfcvabtltx_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="PEF1dGhukVoNVRPT08L2RXN0Pg==" />
        <input type="hidden" name="RelayState" value="oucrsrzceptfcaokfcvabtltx" />
        <noscript>
            <input type="submit" value="Continue" />
        </noscript>
    </form>
</body>
</html> 

What are the other ways for using SCP Predictive services inside Java servlet? The only guides that I found on the Internet were about making calls to Predictive Service resources using Javascript (e.g., in SAPUI5 apps).

I would like to note that I'm using SCP trial account. I thought that changing authentication configuration of aac4paservices app to only support basic authentication with username and password, I could log in using basic authentication. However, after I changed authentication configuration and restarted aac4paservices app, I kept getting 401 error. That's when I accidentally found this blog post. Here is what is says in the comment section:

"It seems only SAML authentication is supported in the HCP free developer trial (and not basic auth) and SAML authentication is difficult to configure in Postman"

Is that correct? If yes, has the reason for getting "Javascript not supported" error been that I was redirected to SAML login which required Javascript? If there is no way to use basic authentication in trial account, is there any other way to call Predictive services inside Java app?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 23, 2017 at 09:32 AM

    Hi Jake,


    First of all, thanks for providing your feedback.


    The SAP Cloud Platform predictive services supports other forms of authentication than SAML even on trial. For example OAuth is available, but you need to know how to get your key.


    I wrote a series of tutorials a while back on this topic. You can check the configuration from the following tutorial (step 5): https://www.sap.com/developer/tutorials/hcpps-ps-configure.html


    Can I ask you then using Postman to validate that this is actually properly working (without the Postman Interceptor).


    If Postman (or any other REST Client works fine), then can you share your Java code as there is many ways to address this?


    Thanks

    Abdel

    Add comment
    10|10000 characters needed characters exceeded