Skip to Content
0

SAPUI5 consuming Java web service

Oct 24, 2017 at 06:06 AM

148

avatar image

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-application/

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member
Nov 10, 2017 at 11:49 AM
0

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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

0
Former Member

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

0
avatar image
Former Member
Nov 07, 2017 at 11:44 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Tri Minh Le Nov 07, 2017 at 10:23 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded