cancel
Showing results for 
Search instead for 
Did you mean: 

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

rubens12
Participant
0 Kudos

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>

Accepted Solutions (1)

Accepted Solutions (1)

former_member228602
Contributor

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

rubens12
Participant
0 Kudos

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?

former_member228602
Contributor
0 Kudos

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?

Answers (3)

Answers (3)

Former Member

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.

rubens12
Participant
0 Kudos

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?

junwu
Active Contributor

are u sure?

what the error now?

rubens12
Participant
0 Kudos

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?

Former Member
0 Kudos

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.

junwu
Active Contributor

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

is it right?

rubens12
Participant
0 Kudos

It's my proxy