How to specify endpoint address in JavaScript?

This forum deals with any kind of web based client technology, whether it is the well known java script based Ajax servlet or the upcoming approaches such as Leaflet, OpenLayers and so on.
Post Reply
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

How to specify endpoint address in JavaScript?

Post by Bernd Welter »

Hi there,
maybe a simple question but: how to set the target URL of our JavaScript clients properly?
Usecase: as a Developer I want to develop a client application against a test environment and then within the deployment I want to change the endpoint address. But how to assign this properly?

Bernd

PS: here are some incomplete examples - the missing link is probably just a single statement. But which one?
  • The following code is taken from our documentation and tells me how to set the credentials.

    Code: Select all

    var xroute = new XRouteClient("https://xserver2-europe-eu-test.cloud.ptvgroup.com/services/rs/XRoute/");
    xroute.setCredentials('xtok', '<your xserver-internet token>');
  • In the integration samples the code looks like this - it is based on "the client class already knows the endpoint address":

    Code: Select all

    var A = {
        "$type": "OffRoadWaypoint",
        "location": {
            "offRoadCoordinate": {
                "x": 6.1256572,
                "y": 49.5983745
            }
        }
    };
    
    var B = {
        "$type": "OnRoadWaypoint",
        "location": {
            "coordinate": {
                "x": 6.1256572,
                "y": 49.4816576
            }
        }
    };
    
    xroute.calculateRoute({
        "waypoints": [A, B]
    }, routingCompleted);
    
    function routingCompleted(route, exception) {
        print(route.distance + 'm in ' + route.travelTime + 's');
    }
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
Joost
Posts: 310
Joined: Fri Apr 25, 2014 1:46 pm

Re: How to specify endpoint address in JavaScript?

Post by Joost »

IIRC:

Code: Select all

var xroute = new XRouteClient("https://xserver2-europe-eu-test.cloud.ptvgroup.com/services/rs/XRoute/")
Joost Claessen
Senior Technical Consultant
PTV Benelux
Post Reply