If you have accessed this page through the xServer's management console, you can immediately view and execute the Jsp code samples, just click the links below. Refer to the troubleshooting section if the samples do not work. This page is best viewed with Mozilla Firefox.
In order to install the C# samples which are not displayed here by default, refer to the C# installation section.
These samples are designed to be executed with the default data of Luxemburg. If you changed the data path in xroute.properties these samples may not work properly.
Please choose an xRoute sample use case
<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8" language="java" import="java.io.*" import="java.util.*" import="com.ptvag.jabba.service.baseservices.*" import="com.ptvag.xserver.common.*" import="com.ptvag.xserver.xroute.*" import="com.ptvgroup.xserver.framework.*" %> <% { // // This page is a sample for PTV xRoute Server and is intended to // show client developers how to request information from the server. // See the code comments for documentation. // // Please note that the default url is http://localhost:<port>/<service>. // // The xServer's port String port = System.getProperty("port.http", "50030"); String path = this.getServletContext().getRealPath("/").replace('\\', '/'); // Build up the xServer's service url String url = request.getRequestURL().toString().split(":")[0] + "://localhost:" + port + "/" + path.substring(path.lastIndexOf("webapps") + 8) + "ws/XRoute"; // // When using this sample in a different context, i.e. not within the xServer, // please uncomment and modify the following line and comment the line following that line. // //String serviceUrl = "http://localhost:50030/xroute/ws/XRoute"; String serviceUrl = url; // // The request parameters are defined here // // The stop-off points int x1 = 612894; //006� 17' 21'' int y1 = 4960676; //049� 36' 24'' int x2 = 605381; //006� 32' 17'' int y2 = 4960841; //049� 36' 30'' // The profile to be used String profile = "carfast"; // The coordinate-format to be used String coordFormat = CoordFormat.PTV_GEODECIMAL.getValue(); // // Building the request // // Stop-off points Point start = new Point(); start.setPoint(new PlainPoint()); start.getPoint().setX(x1); start.getPoint().setY(y1); Point dest = new Point(); dest.setPoint(new PlainPoint()); dest.getPoint().setX(x2); dest.getPoint().setY(y2); // WaypointDesc elements WaypointDesc[] waypoints = new WaypointDesc[2]; waypoints[0] = new WaypointDesc(); waypoints[0].setCoords(new Point[] { start }); waypoints[0].setLinkType(LinkType.NEXT_SEGMENT); waypoints[0].setNodeID(null); waypoints[0].setSegmentID(null); waypoints[0].setFuzzyRadius(0); waypoints[0].setHeading(null); waypoints[0].setStreet(null); waypoints[1] = new WaypointDesc(); waypoints[1].setCoords(new Point[] { dest }); waypoints[1].setLinkType(LinkType.NEXT_SEGMENT); waypoints[1].setNodeID(null); waypoints[1].setSegmentID(null); waypoints[1].setFuzzyRadius(0); waypoints[1].setHeading(null); waypoints[1].setStreet(null); // CallerContext element to set co-ordinate format and profile name CallerContext callerContext = new CallerContext(); callerContext.setLog1("xRoute sample RouteInfo"); callerContext.setLog2(""); callerContext.setLog3(""); CallerContextProperty p1 = new CallerContextProperty("CoordFormat", coordFormat); CallerContextProperty p2 = new CallerContextProperty("ResponseGeometry", GeometryEncoding.PLAIN.getValue()); CallerContextProperty p3 = new CallerContextProperty("Profile", profile); CallerContextProperty[] callerContextProperties = {p1, p2, p3}; callerContext.setProperties(callerContextProperties); // // Creating the service instance // // Use JWSDP or CXF? => Check what's available... RemoteType remoteType = null; try { Class.forName("com.ptvag.xserver.xroute.XRouteCXFClient"); // => CXF available remoteType = RemoteType.DOCSTYLE_CXF; } catch(Exception e) { // => JWSDP remoteType = RemoteType.DOCSTYLE_JWSDP; } XRouteRemoteInterface client = (XRouteRemoteInterface)ClientFactory.createClient(XRouteRemoteInterface.class, remoteType, "", "", serviceUrl); client.setCallerContext(callerContext); // Set user and password client.setUsername("sample"); client.setPassword("sample"); // // Sending the request // String message = ""; boolean success = true; com.ptvag.xserver.xroute.RouteInfo routeInfo = null; try { routeInfo = client.calculateRouteInfo(waypoints, null, null); } catch (Exception e) { success = false; message = e.toString(); } if (success == true && routeInfo == null) { success = false; message = "Error parsing the response."; } %> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>PTV xRoute - RouteInfo Sample</title> <link rel="shortcut icon" href="../images/favicon.ico"/> <link type="text/css" rel="stylesheet" href="../css/xserver.css"> <link type="text/css" rel="stylesheet" href="../css/h234counters.css"> <link type="text/css" rel="stylesheet" href="../css/toc.css"> </head> <body> <% // If the request has been executed successfully, the route info // is displayed, otherwise the error message is displayed. %> <% if (success == true) { %> <h2>The request has been executed successfully.</h2> <p>The route has been calculated with the following result: distance <%=routeInfo.getDistance()%> m, travel time <%=routeInfo.getTime()%> s.</p> <% } else { %> <h2>An error occurred while executing the request.</h2> <p><b>Message: </b><%=message%></p> <% } %> <% } %> </body> </html>
<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8" language="java" import="java.io.*" import="java.util.*" import="com.ptvag.jabba.service.baseservices.*" import="com.ptvag.xserver.common.*" import="com.ptvag.xserver.xroute.*" import="com.ptvgroup.xserver.framework.*" %> <% { // // This page is a sample for PTV xRoute Server and is intended to // show client developers how to request information from the server. // See the code comments for documentation. // // Please note that the default url is http://localhost:<port>/<service>. // // The xServer's port String port = System.getProperty("port.http", "50030"); String path = this.getServletContext().getRealPath("/").replace('\\', '/'); // Build up the xServer's service url String url = request.getRequestURL().toString().split(":")[0] + "://localhost:" + port + "/" + path.substring(path.lastIndexOf("webapps") + 8) + "ws/XRoute"; // // When using this sample in a different context, i.e. not within the xServer, // please uncomment and modify the following line and comment the line following that line. // //String serviceUrl = "http://localhost:50030/xroute/ws/XRoute"; String serviceUrl = url; // // The request parameters are defined here // // The stop-off points int x1 = 612894; //006? 17' 21'' int y1 = 4960676; //049? 36' 24'' int x2 = 605381; //006? 32' 17'' int y2 = 4960841; //049? 36' 30'' // The profile to be used String profile = "carfast"; // The coordinate-format to be used String coordFormat = CoordFormat.PTV_GEODECIMAL.getValue(); // // Building the request // // Stop-off points Point start = new Point(); start.setPoint(new PlainPoint()); start.getPoint().setX(x1); start.getPoint().setY(y1); Point dest = new Point(); dest.setPoint(new PlainPoint()); dest.getPoint().setX(x2); dest.getPoint().setY(y2); // WaypointDesc elements WaypointDesc[] waypoints = new WaypointDesc[2]; waypoints[0] = new WaypointDesc(); waypoints[0].setCoords(new Point[] { start }); waypoints[0].setLinkType(LinkType.NEXT_SEGMENT); waypoints[0].setNodeID(null); waypoints[0].setSegmentID(null); waypoints[0].setFuzzyRadius(0); waypoints[0].setHeading(null); waypoints[0].setStreet(null); waypoints[1] = new WaypointDesc(); waypoints[1].setCoords(new Point[] { dest }); waypoints[1].setLinkType(LinkType.NEXT_SEGMENT); waypoints[1].setNodeID(null); waypoints[1].setSegmentID(null); waypoints[1].setFuzzyRadius(0); waypoints[1].setHeading(null); waypoints[1].setStreet(null); // CallerContext element to set co-ordinate format and profile name CallerContext callerContext = new CallerContext(); callerContext.setLog1("xRoute sample ExtendedRoute"); callerContext.setLog2(""); callerContext.setLog3(""); CallerContextProperty p1 = new CallerContextProperty("CoordFormat", coordFormat); CallerContextProperty p2 = new CallerContextProperty("ResponseGeometry", GeometryEncoding.PLAIN.getValue()); CallerContextProperty p3 = new CallerContextProperty("Profile", profile); CallerContextProperty[] callerContextProperties = {p1, p2, p3}; callerContext.setProperties(callerContextProperties); ResultListOptions resultListOptions = new ResultListOptions (); resultListOptions.setSegments (true); resultListOptions.setTexts (true); CountryInfoOptions countryInfoOptions = new CountryInfoOptions(); // // Creating the service instance // // Use JWSDP or CXF? => Check what's available... RemoteType remoteType = null; try { Class.forName("com.ptvag.xserver.xroute.XRouteCXFClient"); // => CXF available remoteType = RemoteType.DOCSTYLE_CXF; } catch(Exception e) { // => JWSDP remoteType = RemoteType.DOCSTYLE_JWSDP; } XRouteRemoteInterface client = (XRouteRemoteInterface)ClientFactory.createClient(XRouteRemoteInterface.class, remoteType, "", "", serviceUrl); client.setCallerContext(callerContext); // Set user and password client.setUsername("sample"); client.setPassword("sample"); // // Sending the request // String message = ""; boolean success = true; com.ptvag.xserver.xroute.ExtendedRoute extendedRoute = null; try { extendedRoute = client.calculateExtendedRoute(waypoints, null, null, resultListOptions, countryInfoOptions); } catch (Exception e) { success = false; message = e.toString(); } if (success == true && extendedRoute == null) { success = false; message = "Error parsing the response."; } %> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>PTV xRoute - ExtendedRoute Sample</title> <link rel="shortcut icon" href="../images/favicon.ico"/> <link type="text/css" rel="stylesheet" href="../css/xserver.css"> <link type="text/css" rel="stylesheet" href="../css/h234counters.css"> <link type="text/css" rel="stylesheet" href="../css/toc.css"> </head> <body> <% // If the request has been executed successfully, the route info // is displayed, otherwise the error message is displayed. %> <% if (success == true) { %> <h2>The request has been executed successfully.</h2> <p>The route has been calculated with the following result: distance <%=extendedRoute.getRoute().getInfo().getDistance()%> m, travel time <%=extendedRoute.getRoute().getInfo().getTime()%> s.</p> <h3>Distance [m], Street Name [-], Street Nr. [-]</h3> <% RouteListSegment[] segments = extendedRoute.getRoute().getSegments(); String [] texts = extendedRoute.getRoute().getTexts (); int noIdx = -1; int nameIdx = -1; String number = new String (); String name = new String (); for ( int zIndex = 0; zIndex <= (segments.length - 1); zIndex ++ ) { noIdx = segments[zIndex].getStreetNoIdx (); nameIdx = segments[zIndex].getStreetNameIdx(); number = " - "; name = " - "; if (noIdx != -1) {number = texts[noIdx];} if (nameIdx != -1) {name = texts[nameIdx];}; %><p><%=segments[zIndex].getAccDist()%>, <%=name%>, <%=number%></p><% } %> <% } else { %> <h2>An error occurred while executing the request.</h2> <p><b>Message: </b><%=message%></p> <% } %> <% } %> </body> </html>
This sample shows how to calculate distance, travel time and a street list for an extended route consisting of two stop-off points.
The road is blocked for heavy trucks.
Two Results are listed:
1) a truck making a detour
2) a truck driving the direct way
<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8" language="java" import="java.io.*" import="java.util.*" import="com.ptvag.jabba.service.baseservices.*" import="com.ptvag.xserver.common.*" import="com.ptvag.xserver.xroute.*" import="com.ptvgroup.xserver.framework.*" %> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>PTV xRoute - ExtendedRoute Total Weight Sample</title> <link rel="shortcut icon" href="../images/favicon.ico"/> <link type="text/css" rel="stylesheet" href="../css/xserver.css"> <link type="text/css" rel="stylesheet" href="../css/h234counters.css"> <link type="text/css" rel="stylesheet" href="../css/toc.css"> </head> <body> <% { // // This page is a sample for PTV xRoute Server and is intended to // show client developers how to request information from the server. // See the code comments for documentation. // // Please note that the default url is http://localhost:<port>/<service>. // // The xServer's port String port = System.getProperty("port.http", "50030"); String path = this.getServletContext().getRealPath("/").replace('\\', '/'); String scheme = request.getRequestURL().toString().split(":")[0]; // Build up the xServer's service url String url = scheme + "://localhost:" + port + "/" + path.substring(path.lastIndexOf("webapps") + 8) + "ws/XRoute"; // // When using this sample in a different context, i.e. not within the xServer, // please uncomment and modify the following line and comment the line following that line. // //String serviceUrl = "http://localhost:50030/xroute/ws/XRoute"; String serviceUrl = url; // // The request parameters are defined here // // The stop-off points //Büderscheid Kaunereferwee: int x1 = 593639; //005° 56' 11'' int y1 = 4993194; //049° 55' 55'' //Büderscheid Am Breetfeld int x2 = 593972; //005° 56' 23'' int y2 = 4993500; //049° 56' 06'' // The profile to be used String profile = "truckfast"; // Profile snippet containing vehicle settings and additional data rules String profileSnippetTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<Profile xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"" + scheme + "://localhost:50030/xroute/schema/XRouteProfile.xsd\">\n" + " <Routing majorVersion=\"2\" minorVersion=\"0\">\n" + " <Vehicle>\n" + " <Physical>\n" + " <Weight totalPermittedWeight=\"MAX_WEIGHT_VALUE\"/>\n" + " </Physical>\n" + " </Vehicle>\n" + " <Course>\n" + " <AdditionalDataRules enabled=\"true\" layerName=\"TruckAttributes\">\n" + " <VehicleSpecific enabled=\"true\">\n" + " <Malus residential=\"2501\"/>\n" + " </VehicleSpecific>\n" + " </AdditionalDataRules>\n" + " </Course>\n" + " </Routing>\n" + "</Profile>\n"; // The coordinate-format to be used String coordFormat = CoordFormat.PTV_GEODECIMAL.getValue(); // // Building the request // // Stop-off points Point start = new Point(); start.setPoint(new PlainPoint()); start.getPoint().setX(x1); start.getPoint().setY(y1); Point dest = new Point(); dest.setPoint(new PlainPoint()); dest.getPoint().setX(x2); dest.getPoint().setY(y2); // WaypointDesc elements WaypointDesc[] waypoints = new WaypointDesc[2]; waypoints[0] = new WaypointDesc(); waypoints[0].setCoords(new Point[] { start }); waypoints[0].setLinkType(LinkType.NEXT_SEGMENT); waypoints[0].setNodeID(null); waypoints[0].setSegmentID(null); waypoints[0].setFuzzyRadius(0); waypoints[0].setHeading(null); waypoints[0].setStreet(null); waypoints[1] = new WaypointDesc(); waypoints[1].setCoords(new Point[] { dest }); waypoints[1].setLinkType(LinkType.NEXT_SEGMENT); waypoints[1].setNodeID(null); waypoints[1].setSegmentID(null); waypoints[1].setFuzzyRadius(0); waypoints[1].setHeading(null); waypoints[1].setStreet(null); // CallerContext element to set co-ordinate format and profile name CallerContext callerContext = new CallerContext(); callerContext.setLog1("xRoute sample ExtendedRoute truck total weight"); callerContext.setLog2(""); callerContext.setLog3(""); CallerContextProperty p1 = new CallerContextProperty("CoordFormat", coordFormat); CallerContextProperty p2 = new CallerContextProperty("ResponseGeometry", GeometryEncoding.PLAIN.getValue()); CallerContextProperty p3 = new CallerContextProperty("Profile", profile); CallerContextProperty p4 = new CallerContextProperty("ProfileXMLSnippet", null); // snippet contents is set in loop CallerContextProperty[] callerContextProperties = {p1, p2, p3, p4}; callerContext.setProperties(callerContextProperties); ResultListOptions resultListOptions = new ResultListOptions (); resultListOptions.setSegments(true); resultListOptions.setSegmentAttributes(true); resultListOptions.setTexts(true); // Creating the service instance // Use JWSDP or CXF? => Check what's available... RemoteType remoteType = null; try { Class.forName("com.ptvag.xserver.xroute.XRouteCXFClient"); // => CXF available remoteType = RemoteType.DOCSTYLE_CXF; } catch(Exception e) { // => JWSDP remoteType = RemoteType.DOCSTYLE_JWSDP; } XRouteRemoteInterface client = (XRouteRemoteInterface)ClientFactory.createClient(XRouteRemoteInterface.class, remoteType, "", "", serviceUrl); if (client != null) { client.setCallerContext(callerContext); // Set user and password client.setUsername("sample"); client.setPassword("sample"); String[] weights = new String[] {new String("30000"), new String ("2000")}; com.ptvag.xserver.xroute.ExtendedRoute extendedRoute = null; for (String weight : weights) { String message = ""; boolean success = true; String snippet = profileSnippetTemplate.replaceAll("MAX_WEIGHT_VALUE", weight); callerContextProperties[3].setValue(snippet); // Sending the request try { extendedRoute = client.calculateExtendedRoute(waypoints, null, null, resultListOptions, null); } catch (Exception e) { success = false; message = e.toString(); } if (success == true && extendedRoute == null) { success = false; message = "Error parsing the response."; } // If the request has been executed successfully, the route info // is displayed, otherwise the error message is displayed. if (success == true) { %> <h1>TOTAL_WEIGHT == <%=weight%> kg</h1> <h2>The request has been executed successfully.</h2> <p>The route has been calculated with the following result: distance <%=extendedRoute.getRoute().getInfo().getDistance()%> m, travel time <%=extendedRoute.getRoute().getInfo().getTime()%> s.</p> <p>Applied ProfileXMLSnippet:<pre><%=org.apache.commons.lang3.StringEscapeUtils.escapeXml(callerContextProperties[3].getValue())%></pre></p> <table> <thead><tr><td>Distance [m]</td><td>Street Name [-]</td><td>Street Nr. [-]</td><td>Road editor attributes [-]</td></tr></thead> <% RouteListSegment[] segments = extendedRoute.getRoute().getSegments(); String [] texts = extendedRoute.getRoute().getTexts (); int noIdx = -1; int nameIdx = -1; String number = new String (); String name = new String (); String re = new String (); for ( int zIndex = 0; zIndex <= (segments.length - 1); zIndex ++ ) { noIdx = segments[zIndex].getStreetNoIdx (); nameIdx = segments[zIndex].getStreetNameIdx(); number = " - "; name = " - "; re = " - "; if (noIdx != -1) {number = texts[noIdx];} if (nameIdx != -1) {name = texts[nameIdx];}; if (segments[zIndex].getSegmentAttr() != null && segments[zIndex].getSegmentAttr().getAdditionalRE() != null) {re = segments[zIndex].getSegmentAttr().getAdditionalRE();} %><tr><td><%=segments[zIndex].getAccDist()%></td><td><%=name%></td><td><%=number%></td><td><%=re%></td></tr><% } //for zIndex... %></table><% } else { %> <h2>An error occurred while executing the request.</h2> <p><b>Message: </b><%=message%></p> <% } } //for zWeights... } // if } %> </body> </html>
This sample shows how to calculate distance, travel time and a street list for an extended route consisting of two stop-off points.
The road is blocked for high trucks.
Two Results are listed:
1) a truck making a detour
2) a truck driving the direct way
<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8" language="java" import="java.io.*" import="java.util.*" import="com.ptvag.jabba.service.baseservices.*" import="com.ptvag.xserver.common.*" import="com.ptvag.xserver.xroute.*" import="com.ptvgroup.xserver.framework.*" %> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>PTV xRoute - ExtendedRoute Height Sample</title> <link rel="shortcut icon" href="../images/favicon.ico"/> <link type="text/css" rel="stylesheet" href="../css/xserver.css"> <link type="text/css" rel="stylesheet" href="../css/h234counters.css"> <link type="text/css" rel="stylesheet" href="../css/toc.css"> </head> <body> <% { // // This page is a sample for PTV xRoute Server and is intended to // show client developers how to request information from the server. // See the code comments for documentation. // // Please note that the default url is http://localhost:<port>/<service>. // // The xServer's port String port = System.getProperty("port.http", "50030"); String path = this.getServletContext().getRealPath("/").replace('\\', '/'); String scheme = request.getRequestURL().toString().split(":")[0]; // Build up the xServer's service url String url = scheme + "://localhost:" + port + "/" + path.substring(path.lastIndexOf("webapps") + 8) + "ws/XRoute"; // // When using this sample in a different context, i.e. not within the xServer, // please uncomment and modify the following line and comment the line following that line. // //String serviceUrl = "http://localhost:50030/xroute/ws/XRoute"; String serviceUrl = url; // // The request parameters are defined here // // The stop-off points int x1 = 607916; int y1 = 4947833; int x2 = 608334; int y2 = 4947833; // The profile to be used String profile = "truckfast"; // Profile snippet containing vehicle settings and additional data rules String profileSnippetTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<Profile xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"" + scheme + "://localhost:50030/xroute/schema/XRouteProfile.xsd\">\n" + " <Routing majorVersion=\"2\" minorVersion=\"0\">\n" + " <Vehicle>\n" + " <Physical>\n" + " <Dimension height=\"MAX_HEIGHT_VALUE\"/>\n" + " </Physical>\n" + " </Vehicle>\n" + " <Course>\n" + " <AdditionalDataRules enabled=\"true\" layerName=\"TruckAttributes\">\n" + " <VehicleSpecific enabled=\"true\"/>\n" + " </AdditionalDataRules>\n" + " </Course>\n" + " </Routing>\n" + "</Profile>\n"; // The coordinate-format to be used String coordFormat = CoordFormat.PTV_GEODECIMAL.getValue(); // // Building the request // // Stop-off points Point start = new Point(); start.setPoint(new PlainPoint()); start.getPoint().setX(x1); start.getPoint().setY(y1); Point dest = new Point(); dest.setPoint(new PlainPoint()); dest.getPoint().setX(x2); dest.getPoint().setY(y2); // WaypointDesc elements WaypointDesc[] waypoints = new WaypointDesc[2]; waypoints[0] = new WaypointDesc(); waypoints[0].setCoords(new Point[] { start }); waypoints[0].setLinkType(LinkType.NEXT_SEGMENT); waypoints[0].setNodeID(null); waypoints[0].setSegmentID(null); waypoints[0].setFuzzyRadius(0); waypoints[0].setHeading(null); waypoints[0].setStreet(null); waypoints[1] = new WaypointDesc(); waypoints[1].setCoords(new Point[] { dest }); waypoints[1].setLinkType(LinkType.NEXT_SEGMENT); waypoints[1].setNodeID(null); waypoints[1].setSegmentID(null); waypoints[1].setFuzzyRadius(0); waypoints[1].setHeading(null); waypoints[1].setStreet(null); // CallerContext element to set co-ordinate format and profile name CallerContext callerContext = new CallerContext(); callerContext.setLog1("xRoute sample ExtendedRoute truck height"); callerContext.setLog2(""); callerContext.setLog3(""); CallerContextProperty p1 = new CallerContextProperty("CoordFormat", coordFormat); CallerContextProperty p2 = new CallerContextProperty("ResponseGeometry", GeometryEncoding.PLAIN.getValue()); CallerContextProperty p3 = new CallerContextProperty("Profile", profile); CallerContextProperty p4 = new CallerContextProperty("ProfileXMLSnippet", null); // snippet contents is set in loop CallerContextProperty[] callerContextProperties = {p1, p2, p3, p4}; callerContext.setProperties(callerContextProperties); ResultListOptions resultListOptions = new ResultListOptions (); resultListOptions.setSegments(true); resultListOptions.setSegmentAttributes(true); resultListOptions.setTexts(true); // Creating the service instance // Use JWSDP or CXF? => Check what's available... RemoteType remoteType = null; try { Class.forName("com.ptvag.xserver.xroute.XRouteCXFClient"); // => CXF available remoteType = RemoteType.DOCSTYLE_CXF; } catch(Exception e) { // => JWSDP remoteType = RemoteType.DOCSTYLE_JWSDP; } XRouteRemoteInterface client = (XRouteRemoteInterface)ClientFactory.createClient(XRouteRemoteInterface.class, remoteType, "", "", serviceUrl); if (client != null) { client.setCallerContext(callerContext); // Set user and password client.setUsername("sample"); client.setPassword("sample"); com.ptvag.xserver.xroute.ExtendedRoute extendedRoute = null; String[] heights = new String[] {new String("500"), new String("200")}; for (String height : heights) { String message = ""; boolean success = true; String snippet = profileSnippetTemplate.replaceAll("MAX_HEIGHT_VALUE", height); callerContextProperties[3].setValue(snippet); // Sending the request try { extendedRoute = client.calculateExtendedRoute(waypoints, null, null, resultListOptions, null); } catch (Exception e) { success = false; message = e.toString(); } if (success == true && extendedRoute == null) { success = false; message = "Error parsing the response."; } %><td valign="top"><% // If the request has been executed successfully, the route info // is displayed, otherwise the error message is displayed. if (success == true) { %> <h1>HEIGHT == <%=height%> cm</h1> <h2>The request has been executed successfully.</h2> <p>The route has been calculated with the following result: distance <%=extendedRoute.getRoute().getInfo().getDistance()%> m, travel time <%=extendedRoute.getRoute().getInfo().getTime()%> s.</p> <p>Applied ProfileXMLSnippet:<pre><%=org.apache.commons.lang3.StringEscapeUtils.escapeXml(callerContextProperties[3].getValue())%></pre></p> <table> <thead><tr><td>Distance [m]</td><td>Street Name [-]</td><td>Street Nr. [-]</td><td>Road editor attributes [-]</td></tr></thead> <% RouteListSegment[] segments = extendedRoute.getRoute().getSegments(); String [] texts = extendedRoute.getRoute().getTexts (); int noIdx = -1; int nameIdx = -1; String number = new String (); String name = new String (); String re = new String (); for ( int zIndex = 0; zIndex <= (segments.length - 1); zIndex ++ ) { noIdx = segments[zIndex].getStreetNoIdx (); nameIdx = segments[zIndex].getStreetNameIdx(); number = " - "; name = " - "; re = " - "; if (noIdx != -1) {number = texts[noIdx];} if (nameIdx != -1) {name = texts[nameIdx];}; if (segments[zIndex].getSegmentAttr() != null && segments[zIndex].getSegmentAttr().getAdditionalRE() != null) {re = segments[zIndex].getSegmentAttr().getAdditionalRE();} %><tr><td><%=segments[zIndex].getAccDist()%></td><td><%=name%></td><td><%=number%></td><td><%=re%></td></tr><% } //for zIndex... %></table><% } else { %> <h2>An error occurred while executing the request.</h2> <p><b>Message: </b><%=message%></p> <% } } //for zHeights... } // if } %> </body> </html>
If the Jsp samples cannot be executed, please view the source code and check the serviceUrl variable.
The C# samples can be found in the xServer's samples folder. Please unpack them into the root folder of your local IIS installation, usually C:\Inetpub\wwwroot. Then call the IIS management console from the Control Panel and register the sample folder as IIS application.
Additionally make sure, that Microsoft.Net Framework 2.0 redistributables are installed and ASP.NET is registered within Internet Information Services (IIS). For registration use the ASP.NET IIS Registration tool with the command line
aspnet_regiis.exe -i
After having executed these steps, please reload this page. The C# samples are automatically displayed and can be executed.