Skip to Content
0

No data on http://services.odata.org/Northwind/Northwind.svc

Mar 08, 2017 at 02:57 PM

212

avatar image

I am triyng cosume a Odata service (http://services.odata.org/Northwind/Northwind.svc)

But it not return any Data

Bellow is my code

#C.controller.js

sap.ui.define([
		'jquery.sap.global',
		'sap/ui/core/Fragment',
		'sap/ui/core/mvc/Controller',
		'sap/ui/model/Filter',
		'sap/ui/model/json/JSONModel'
	], function(jQuery, Fragment, Controller, Filter, JSONModel) {
	"use strict";


	var CController = Controller.extend("sap.m.sample.InputStates.C", {
		inputId: '',


		onInit: function () {
			var sServiceUrl = "8080/http/services.odata.org/V2/OData/OData.svc";
                        var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl,true);
			this.getView().setModel(oModel);
		},


		handleValueHelp : function (oController) {
			this.inputId = oController.oSource.sId;
			// create value help dialog
			if (!this._valueHelpDialog) {
				this._valueHelpDialog = sap.ui.xmlfragment(
					"sap.m.sample.InputStates.Dialog",
					this
				);
				this.getView().addDependent(this._valueHelpDialog);
			}


			// open value help dialog
			this._valueHelpDialog.open();
		},


		_handleValueHelpSearch : function (evt) {
			var sValue = evt.getParameter("value");
			var oFilter = new Filter(
				"Name",
				sap.ui.model.FilterOperator.Contains, sValue
			);
			evt.getSource().getBinding("items").filter([oFilter]);
		},


		_handleValueHelpClose : function (evt) {
			var oSelectedItem = evt.getParameter("selectedItem");
			if (oSelectedItem) {
				var productInput = this.getView().byId(this.inputId);
				productInput.setValue(oSelectedItem.getTitle());
			}
			evt.getSource().getBinding("items").filter([]);
		}
	});




	return CController;


});

#Dialog.fragment.xml

<core:FragmentDefinition
	xmlns="sap.m"
	xmlns:core="sap.ui.core">
	<SelectDialog
		title="Products"
		class="sapUiPopupWithPadding"
		items="{/Categories}"
		search="_handleValueHelpSearch"
		confirm="_handleValueHelpClose"
		cancel="_handleValueHelpClose">
		<StandardListItem
			title="{CategoryName}"
			 />
	</SelectDialog>
</core:FragmentDefinition>
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Veeraraghavan Narasimhan
Mar 08, 2017 at 05:50 PM
1

Hello Rubens,

The issue with URL http://services.odata.org/Northwind/Northwind.svc is shown below

This service is a OData V3 service and currently UI5 does not support V3 and support V2 and support for V4 will be soon available. So you should use the linkhttp://services.odata.org/V2/Northwind/Northwind.svc/ as V2 is supported.

Thanks and Regards,

Veera


v3-service.png (107.8 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded

I tried it, but is not working.

I am trying use this example https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.InputStates/code/V.view.xml

But I need to consume a remote OData service(http://services.odata.org/V2/Northwind/Northwind.svc/), and not a local JSON.

I tried with the code above, but it not return any Data.

Can you help me?

0

Can you tell what is the error you are getting. As long as the model is bound it should work. Can you attach some screenshot?

0
Jun Wu Mar 08, 2017 at 03:22 PM
1

var sServiceUrl ="8080/http/services.odata.org/V2/OData/OData.svc";

is it right?

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

It's my proxy

0
Jun Wu Mar 08, 2017 at 04:16 PM
1

are u sure?

what the error now?

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

So, I am trying use this example https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.InputStates/code/V.view.xml

But I need to consume a remote OData service(http://services.odata.org/Northwind/Northwind.svc), and not a local JSON.

I tried with the code above, but it not return any Data.

Can you help me?

0

Hi Rubens,

perhaps it's a CORS problem (Cross-Origin Resource Sharing)? You'd need either to access the remote service via a proxy or configure your browser to allow CORS requests.

Cheers,

C.

0
Christian Brunner Mar 08, 2017 at 04:27 PM
1

Hi Jun,

the URL is wrong. Try

http://services.odata.org/V2/Northwind/Northwind.svc/

or

http://services.odata.org/V3/Northwind/Northwind.svc/

Note the difference: V2 or V3

Cheers,

Christian.

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

So, I am trying use this example https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.InputStates/code/V.view.xml

But I need to consume a remote OData service(http://services.odata.org/Northwind/Northwind.svc), and not a local JSON.

I tried with the code above, but it not return any Data.

Can you help me?

0