Hi Gene,
The problem is that JAX-RS specifies that JAXB types are supported for
the following media types: text/xml, application/xml and application/⋆
+xml.
You can use a client filter to modify the content-type to "application/
vnd.google-earth+xml" or to "application/xml".
An alternative is to register the following provider, but i do not
recommend this because it depends on the non-API class
XMLRootElementProvider (which perhaps indicates we should move this to
the API?):
@Provider
@Produces("application/vnd.google-earth")
@Consumes("application/vnd.google-earth")
public static final class KmlProvider extends
XMLRootElementProvider {
public KmlProvider(@Context Injectable<SAXParserFactory> spf,
@Context Providers ps) {
super(spf, ps, MediaType.valueOf("application/vnd.google-
earth"));
}
public boolean isReadable(Class<?> type, Type genericType,
Annotation annotations[],
MediaType mediaType) {
return type == KmlType.class;
}
public boolean isWriteable(Class<?> type, Type genericType,
Annotation annotations[],
MediaType mediaType) {
return type == KmlType.class;
}
}
Paul.
On Oct 9, 2009, at 1:45 AM, Turner, George wrote:
> Many times service providers output multiple content types for xml.
> It is usually plain/text, application/xml, etc, etc.
> KML is output as application/vnd.google-earth, but to a JAXB
> unmarshaller, it is really just application/xml.
> What I am looking for is a way to do this:
>
> ClientConfig config = new DefaultClientConfig();
> Client client = Client.create(config);
> WebResource webResource = client.resource(url);
> KmlType kml = webResource.
> accept("plain/text", "application/xml", "application/
> vnd.google-earth").get(KmlType.class);
>
> And not get the ANNOYING error message that a message body reader
> has not been registered for KmlType and application/vnd.google-earth.
>
> Any help is GREATLY appreciated.
>
> Thanks
>
> Gene
>
> George (Gene) Turner
> <image001.png>
> Senior Staff Software Engineer
> Information Systems & Global Services
> Work:(719) 277-5244 Cell:(719) 237-0490
> george.turner_at_lmco.com
>
>