View Single Post

  #2 (permalink)  
Old 06-04-2004
Anonymous Anonymous is offline
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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.
Reply With Quote