In this thread we would like to show, how you overcome such a problem. The instructions applies also to all server side profile attributes and is based on passing a XML snipped to the server. This becomes handy if he Java API is not included the attribute you want to set. If it is in the API please use the API.
Fist you jave to read your profile XML snippet. I attach a sample method, which does this:
Code: Select all
InputStream is = this.getClass().getClassLoader().getResourceAsStream(file_path);
StringBuffer sb = new StringBuffer();
try (InputStreamReader fr = new InputStreamReader(is, StandardCharsets.UTF_8.name()); BufferedReader br = new BufferedReader(fr);) {
String read = br.readLine();
while (read != null) {
sb.append(read);
read = br.readLine();
}
} catch (Exception ex) {
Logger.log(MessageTexts._error, ex.getMessage());
}
String snippet = sb.toString();
CallerContextProperty p2 = new CallerContextProperty("ProfileXMLSnippet", snippet);
Important is to read with UTF-8 encoding, because the server side expects this. The keyword is "ProfileXMLSnippet" in the caller context property. After you read the XML file, just add it to the client:
Code: Select all
this.ctx = new CallerContext(new CallerContextProperty[] {...});
this.xLocateClient = (XLocateRemoteInterface) ClientFactory.createClient(...);
this.xLocateClient.setCallerContext(ctx);
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Profile>
<Common coordinateFormat="PTV_SMARTUNITS" majorVersion="1" minorVersion="0"/>
<Routing majorVersion="2" minorVersion="0">
<Vehicle>
<Speed speedForAirLineDistance="60">
<SpeedRangeByNetworkClass minimumSpeed="80" maximumSpeed="130"/>
<SpeedRangeByNetworkClass minimumSpeed="70" maximumSpeed="100"/>
<SpeedRangeByNetworkClass minimumSpeed="60" maximumSpeed="80"/>
<SpeedRangeByNetworkClass minimumSpeed="50" maximumSpeed="70"/>
<SpeedRangeByNetworkClass minimumSpeed="25" maximumSpeed="50"/>
<SpeedRangeByNetworkClass minimumSpeed="18" maximumSpeed="40"/>
<SpeedRangeByNetworkClass minimumSpeed="9" maximumSpeed="16"/>
<SpeedRangeByNetworkClass minimumSpeed="4" maximumSpeed="6"/>
</Speed>
</Vehicle>
</Routing>
</Profile>