Unable to initialize OData. with Breeze, Needed to support remote OData services
Asked Answered
S

1

5

I am trying to use breeze to call a wcf service, bij config breeze to use OData. But still I got the error:

Unable to initialize OData, Needed to support remote OData services 

I also tried: breeze.config.initializeAdapterInstance("dataService", "OData");

Below I have the html page which i want to use.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../Scripts/jquery-2.0.2.js"></script>
    <script src="../Scripts/knockout-2.2.1.debug.js"></script>
    <script src="../Scripts/q.js"></script>
    <script src="../Scripts/breeze.debug.js"></script>

    <script>
       breeze.core.config.setProperties({
            // the OData provider
            remoteAccessImplementation: breeze.entityModel.remoteAccess_odata,
            // this is the Knockout provider but we also provide a Backbone provider
            //  and we have others on the way
            trackingImplementation: breeze.entityModel.entityTracking_ko
        });


        var myServiceName =             "http://597de06c06404b47b1f1f592c56f6753.cloudapp.net/GoedendoelDataService.svc/?      $format=json";
        var em = new breeze.entityModel.EntityManager( {serviceName: myServiceName });

        var query = breeze.entityModel.EntityQuery.from("Goedendoel")
            .where("title", "startsWith", "G")
            .orderBy("title");

        em.executeQuery(query).then(function(data) {
            // process the results here.
            ko.applyBindings(data);
         }).fail(function (e) {
            alert(e);
        });

    </script>
 </head>
 <body>
    <p data-bind="visible: !results">Fetching data ... </p>
     <ul data-bind="foreach: results, visible: results" style="display: none">
        <li>
            <span data-bind="text:title"></span>
        </li>
     </ul>
</body>
 </html>
Sapid answered 13/6, 2013 at 20:7 Comment(0)
W
7

For OData support with Breeze you will also need the datajs library from Microsoft. More information here as well: Breeze OData

Windowlight answered 13/6, 2013 at 20:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.