I'm using MapPoint Web Service in a Java J2EE architecture. How do I set the default distance unit to miles in the RouteService CalculateSimpleRoute call?
This is a discussion on Setting default distance unit within the Bing Maps and MapPoint Web Service forums, part of the Map Forums category; I'm using MapPoint Web Service in a Java J2EE architecture. How do I set the default distance unit to miles ...
I'm using MapPoint Web Service in a Java J2EE architecture. How do I set the default distance unit to miles in the RouteService CalculateSimpleRoute call?
Here's an example of how to set the header elements in Java:
The following is a code snippet of how you would set the Distance Unit property of
the UserInfoFindHeader and UserInfoRouteHeader. These edits were done to the FindRouteDialog.java
file which is in the 'Java Driving Directions' demo located at
http://demo.mappoint.net/.
try {
String findUrl = staging ? findStagingUrl : findProductionUrl;
findService = new FindServiceLocator().getFindServiceSoap(new
URL(findUrl));
((FindServiceSoapStub) findService).setUsername(userName);
((FindServiceSoapStub) findService).setPassword(password);
//Create a SOAP Header Element and child elements to support setting
the Distance unit for the FindService
SOAPHeaderElement myUserInfoFindHeader = new
SOAPHeaderElement("","UserInfoFindHeader");
MessageElement myDistanceUnit = new MessageElement("","DefaultDistanceUnit");
myDistanceUnit .addTextNode("DistanceUnit.Mile");
myUserInfoFindHeader.addChild(myDistanceUnit);
//Set the header using the SOAP Header Element and children created
above
((FindServiceSoapStub) findService).setHeader(myUserInfoFindHeader);
String routeUrl = staging ? routeStagingUrl : routeProductionUrl;
routeService = new RouteServiceLocator().getRouteServiceSoap(new
URL(routeUrl));
((RouteServiceSoapStub) routeService).setUsername(userName);
((RouteServiceSoapStub) routeService).setPassword(password);
//Create a SOAP Header Element and child elements to support setting
the Distance unit for the Route Service
SOAPHeaderElement myUserInfoRouteHeader = new
SOAPHeaderElement("","UserInfoRouteHeader");
MessageElement myDistanceUnit = new MessageElement("","DefaultDistanceUnit");
myDistanceUnit .addTextNode("DistanceUnit.Mile");
myUserInfoRouteHeader.addChild(myDistanceUnit);
//Set the header using the SOAP Header Element and children created
above
((RouteServiceSoapStub) routeService).setHeader(myUserInfoRouteHeader);
}
catch (Exception e) {
ExceptionDialog.displayException(this, e);
}
Steven Pushee
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2003 Microsoft Corporation. All rights
reserved.
There are currently 1 users browsing this thread. (0 members and 1 guests)