Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 41
Registered: ‎07-28-2010
My Device: Not Specified

Using KML Documents with BlackBerry Maps - HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

Hello everybody Smiley Happy

 

I'm developing my first BlackBerry application that uses BlackBerry Maps and use BlackBerry Java SDK Location-Based Services Version: 5.0 - Development Guide as a reference document.

 

Thanks to the guide, I am able to load BlackBerry Maps with Location Document in my application and it works fine. However when I try to invoke BlackBerry Maps by using a KML document hosted in my web server, I receive and error while trying to load KML file from web server:

 

HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

 

Could anyone give me suggestions for this situation?

Any help would be greatly appreciated!!!

 

This is the content of KML file I'm trying to load:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
   <Placemark>
      <name>Ottawa</name>
      <description>Ottawa office</description>
      <Point>
         <coordinates>-90.86948943473118,48.25450093195546,0</coordinates>
      </Point>
   </Placemark>
</kml>

and the code to invoke the map:

 

_viewMapKML = new MenuItem("View Map with KML", 2000,10)

{                      

  public void run()                      

  {                                

  MapsArguments ma = new MapsArguments(MapsArguments.ARG_KML, "http://www.myserver/sample.kml");                                                    Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, ma);                      

}

};

 

I'm using BlackBerry JDE 6.0 with BlackBerry Curve 8330 simulator.

 

Best regards,

 

Tuyen Nguyen

 

 

 

 

 

 

 

 

Developer
Posts: 499
Registered: ‎06-24-2008
My Device: Not Specified

Re: Using KML Documents with BlackBerry Maps - HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

[ Edited ]

406 errors occur when the type of data being served by a server is not in the set of acceptable data to the client.

 

This suggests the something in the Accept headers of your HTTP request indicates the data being served is not acceptable.

 

Accept headers include the following:

 

  • Accept: The MIME types accepted by the client. For example, a browser may only accept back types of data (HTML files, GIF files etc.) it knows how to process.
  • Accept-Charset: The character sets accepted by the client.
  • Accept-Encoding: The data encoding accepted by the client e.g. the file formats it understands.
  • Accept-Language: The natural languages (English, German etc.) accepted by the client.
  • Accept-Ranges: Whether the client accepts ranges of bytes from the resource i.e. a portion of the resource.

Something about your data doesn't match the values accepted by BlackBerry Maps.

 

I'd suggest using Wireshark or similar to see what "Accept" headers BlackBerry Maps issues and then ensure that your data is ok. You could just be missing a mime type setting in your server or maybe the encoding doesn't match.

 

A crazy thought but you might try changing the file extension to "xml".

Contributor
Posts: 41
Registered: ‎07-28-2010
My Device: Not Specified

Re: Using KML Documents with BlackBerry Maps - HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

Thank you BR14 for your detailed respond, I'd try your suggestions and report the result.

 

Hope you all the best.

 

Tuyen Nguyen

Contributor
Posts: 41
Registered: ‎07-28-2010
My Device: Not Specified

Re: Using KML Documents with BlackBerry Maps - HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

I've tried to change the file extension to xml but still not succeed.

 

This is the link to the BlackBerry Developer Documentation that I am following:

http://docs.blackberry.com/en/developers/deliverables/11944/CS_invoking_BB_Maps_using_a_KML_document...

 

Does anyone have any ideas?

Developer
Posts: 499
Registered: ‎06-24-2008
My Device: Not Specified

Re: Using KML Documents with BlackBerry Maps - HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

Have you checked this article?

 

http://docs.blackberry.com/en/developers/deliverables/11944/Open_BB_Maps_from_the_BB_Browser_898721_...

 

"You can use the BlackBerry® Browser to open BlackBerry® Maps and load a KML document, a compressed KML document, or a location document. The web server MIME types must be correctly configured.

  • KML documents have a MIME type of "application/vnd.google-earth.kml+xml".
  • Compressed KML documents have a MIME type of "application/vnd.google-earth.kmz".
  • Location documents have a MIME type of "text/vnd.rim.location.xloc"."

 

Looks as though you may need to configure your server mime-types config.

Contributor
Posts: 41
Registered: ‎07-28-2010
My Device: Not Specified

Re: Using KML Documents with BlackBerry Maps - HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

Hello br14,

 

I do not intend to use Browser to user BlackBerry Maps, but many thanks for your suggestions.

 

Best regards,

 

Tuyen Nguyen

Developer
Posts: 499
Registered: ‎06-24-2008
My Device: Not Specified

Re: Using KML Documents with BlackBerry Maps - HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

"I do not intend to use Browser to user BlackBerry Maps, but many thanks for your suggestions."

 

I realise you're not using the browser.

 

However, clearly Maps is using a HTTP client of some kind and stipulating an acceptable content type or you wouldn't be seeing the 406 error.

 

You web server needs to set the content type of the KML file to the appropriate mime type. If you're using Apache for example you might edit the mime.types config file.

 

 

 

New Contributor
Posts: 4
Registered: ‎11-02-2010
My Device: Bold 9700
My Carrier: Orange UK

Re: Using KML Documents with BlackBerry Maps - HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

I came across this with the exact same problem and managed to get it working as follows:

 

Open your text editor (let's assume "Notepad" in Windows) and paste the following text in to your new document:

 

 

##

# Blackberry Maps

AddType application/vnd.google-earth.kml+xml

##

 

 

Click "Save as" and in the "Save as type" drop down box select "All Files". Name the file ".htaccess" (without the brackets of course) and save it somewhere locally, e.g. your desktop.

 

Connect to your webspace and locate the folder where you want to store/host you KML maps - copy and paste this new .htaccess file into the same folder - this can be in the root or inside a folder, but crucially, it MUST be in the same folder where the KML files are located.

 

Finally, in Blackberry maps, try adding the full path to the KML file again.

 

Hopefully, it should work this time, as it did for me!

 

Hope this helps!

New Contributor
Posts: 4
Registered: ‎11-02-2010
My Device: Bold 9700
My Carrier: Orange UK

Re: Using KML Documents with BlackBerry Maps - HTTP 406 Error: Not Acceptable The file you are trying to load is not supported.

Forgot to mention - you don't need the first two or last two hashtags (##). I just had to add them to allow me to post the body!

Good luck!