On Dec 16, 2010, at 5:48 AM, tmp wrote:
>
> Hello!
>
> I have two questions regarding the following code:
> http://pastebin.com/Gm0pgs6m
> This resource should get some arbitrary data from the internet (js,
> images,
> html, ...) and deliver it in a response to the client.
>
> 1) At the moment I get errors when I want to deliver images:
> A message body writer for Java class
> com.sun.jersey.api.client.WebResource,
> and Java type class com.sun.jersey.api.client.WebResource, and MIME
> media
> type image/png was not found
>
> What is missing? Here you can see the jersey dependency in the
> pom.xml:
> http://pastebin.com/aqiFdDx1
>
There is no pre-defined message body reader supplied with Jersey to
convert an instance of WebResource to a representation. Although it
should be easy for you to write one, if you intention is to support
forwarding functionality.
Alternatively you could do something like this:
final ClientResponse cr = wecResource.get(ClientResponse.class);
return Response.ok(new StreamingOutput() {
public void write(OutputStream output) throws IOException {
ReaderWriter.writeTo(cr.getEntityInputStream(), output);
}
})....
Paul.
> 2) Because I have to solve a cross-domain problem in a
> webapplication, this
> resource has deliver arbitrary content from the web. Inside the
> webapp an
> arbitrary webpage is embedded in an iframe. All requests from this
> iframe
> (css files, js files, images, ...) are mapped to the posted
> resource. Now
> this resource has to check the headers of the iframe-request, build
> a new
> request with the given data and deliver the resonse to the client.
> Is my
> attempt correct? How can I get the headers (and all other needed
> data?) to
> forward it in the new request from the server? Is there a better way
> to
> solve the problem? (for example forwarding the request and the
> response)
>
> Thanks in advance!
> --
> View this message in context: http://jersey.576304.n2.nabble.com/MessageBodyWriter-Mimetype-exception-a-general-question-tp5840878p5840878.html
> Sent from the Jersey mailing list archive at Nabble.com.