Skip to Content

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

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>
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Mar 08, 2017 at 05:50 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 08, 2017 at 03:22 PM

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

    is it right?

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 08, 2017 at 04:16 PM

    are u sure?

    what the error now?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Rubens Pereira

      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.

  • avatar image
    Former Member
    Mar 08, 2017 at 04:27 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded