Hi,

I have created a short example REST server using JiBX and Restlet here:

https://github.com/butlermh/TVExample

However I encountered some problems in my integration test 

https://github.com/butlermh/TVExample/blob/master/TVProgrammeREST/src/test/java/com/tvexample/programme/integrationTests/ClientProgrammeProxy.java

when using POST or PUT on the client side. I hoped to be able to call my 
interface by using ClientResource.wrap:

ClientResource cr = new ClientResource(resourceURI);
resource = cr.wrap(ProgrammeResource.class);
resource.create(programme);

However this creates a request like this

POST /tv/programmes/4 HTTP/1.1
Transfer-Encoding: chunked
Date: Sun, 26 Jun 2011 12:33:20 GMT
Content-Type: application/octet-stream; charset=UTF-8
Accept: */*
Host: localhost:8181
User-Agent: Restlet-Framework/2.1m3

0045
<programme><id>4</id><title>Strictly Come Dancing</title></programme>
0000

So I get a response like this

HTTP/1.1 415 Unsupported Media Type
Content-Type: text/html; charset=UTF-8
Date: Sun, 26 Jun 2011 12:33:20 GMT
Accept-Ranges: bytes
Server: Restlet-Framework/2.1m3
Content-Length: 554

If I create the request manually directly from JiBX 

IBindingFactory bfact =  
  BindingDirectory.getFactory(Programme.class);
IMarshallingContext mctx = 
  bfact.createMarshallingContext();
StringWriter sw = new StringWriter();
mctx.marshalDocument(p, "UTF-8", null, sw);
StringRepresentation rep = new 
  StringRepresentation(sw.toString(), MediaType.APPLICATION_XML);
Client cl = new Client(Protocol.HTTP);
Request request = new Request(method, url, rep);
Response response = cl.handle(request);

to create a request like this

PUT /tv/programmes/2 HTTP/1.1
Date: Sun, 26 Jun 2011 12:37:32 GMT
Content-Length: 96
Content-Type: application/xml; charset=UTF-8
Accept: */*
Host: localhost:8181
User-Agent: Restlet-Framework/2.1m3

<?xml version="1.0" encoding="UTF-8"?><programme><id>2</id><title>Doctor 
Who</title></programme>

then it works. Any ideas why this is happening?

Best wishes,

Mark

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2777341

Reply via email to