cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 consuming Java web service

former_member516423
Participant
0 Kudos

Hello experts,

I'm following this blog to implement s4hana cloud sdk step 9 Implement and Deploy a Frontend Application.

https://blogs.sap.com/2017/09/09/step-9-with-sap-s4hana-cloud-sdk-implement-and-deploy-a-frontend-ap...

I've set destination to Java application

In my ui5 application controller, onInit event, i try to make a request to java app.

$.ajax({
				type: "GET",
				url: "/FirstApp/products",
				dataType: "json",
				async: true,
				success: function(oData) {
					console.log(oData);
				},
				error: function(error) {
					console.log(error);
				}
			});

It returns no data but this error

<!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">
    <h1>Unauthorized</h1>
        <HR size="1" noshade="noshade">
            <p>
                <b>type</b> Status report
            </p>
            <p>
                <b>message</b>
                <u>Unauthorized</u>
            </p>
            <p>
                <b>description</b>
                <u>This request requires HTTP authentication.</u>
            </p>
        </body>
    </html>

I later add header to ajax call

$.ajax({
				type: "GET",
				url: "/FirstApp/products",
				dataType: "json",
				async: true,
headers: {
		'Authorization': 'Basic ' + btoa('<username>:<password>')
				},

				success: function(oData) {
					console.log(oData);
				},
				error: function(error) {
					console.log(error);
				}
			});

But it still doesn't work.

What could cause this error?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You have to setup both. The manifest.yml and xs-app.json.

former_member516423
Participant
0 Kudos

Hi Frank,

I've deployed it to NEO environment, not Cloud Foundry. So I think these 2 files you mention are not created when creating maven project with this artifact scp-neo-javaee6.

Regards,

Tri

Former Member
0 Kudos

Our blog post is just about CloudFoundry. I can't help you at this point. Sorry!

Answers (2)

Answers (2)

Former Member

You have to set you desired destination in the app-router configuration. You did it in cloud platform cockpit. Those are completely different destinations.

former_member516423
Participant
0 Kudos

Hi Frank,

Thanks for your reply.

I don't get your "app-router configuration". You mean manifest.json or neo-app.json?

In my neo-app.json, I included destination:

{
	"welcomeFile": "/webapp/index.html",
	"routes": [{
		"path": "/resources",
		"target": {
			"type": "service",
			"name": "sapui5",
			"entryPath": "/resources"
		},
		"description": "SAPUI5 Resources"
	}, {
		"path": "/test-resources",
		"target": {
			"type": "service",
			"name": "sapui5",
			"entryPath": "/test-resources"
		},
		"description": "SAPUI5 Test Resources"
	}, {
		"path": "/FirstApp",
		"target": {
			"type": "destination",
			"name": "FirstApp"
		},
		"description": "First App Java application"
	}],
	"sendWelcomeFileRedirect": true
}

Please let me know if this is correct.

Thanks in advance.

Tri