Hi all,
i try to migrate a running hibernate backend to a dropwizard server and stuck with the client call.
The resource method:
@Path(value = "/ox_country")
public class OxCountryResource {
. . .
@POST
@Timed
@Path("/paged-ro")
@UnitOfWork
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public OxResultObject getAllCountriesPagedAsResulObject(OxCountryLookup _lookup, @QueryParam("start") long _start,
@QueryParam("size") long _size) {
if (_lookup == null) {
System.out.println("lookup bean is null");
}
long start = _start;
long size = _size;
return oxCountryService.getPagedCountrys(_lookup, start, size);
}
my client call:
OxResultObject<?> ro = null;
OxCountryLookup lookup = new OxCountryLookup();
lookup.setCode2("E");
int start = 0;
int size = 10;
try {
WebTarget webTargetResource = webTarget.path("ox_country/paged-ro");
WebTarget webTargetResourceWithParam = webTargetResource.queryParam("start", start).queryParam("size", size);
Invocation.Builder invocationBuilder = webTargetResourceWithParam.request(MediaType.APPLICATION_JSON);
invocationBuilder.header("some-header", "true");
response = invocationBuilder.post(Entity.entity(lookup, MediaType.APPLICATION_JSON));
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
}
// How do get the remote IP ????
System.out.println(response.getStatus() + " " + response.getStatusInfo() + " " + response.getMetadata().getFirst("Date") + " "
+ "Content-Length: " + response.getMetadata().getFirst("Content-Length"));
} catch (Exception e) {
response.close();
e.printStackTrace();
} finally {
response.close();
}
The OxCountryLookup is a helper bean which holds search values which are evaluated in the hibernate service method.
The OxResultObject is a helper class which holds the result list with the paged objects and a total count of possible records.
My problem is now i get not the 'OxCountryLookup' object to the rest service. I get all times a http 400 which pointed to a false header?
Any help are welcome.
thanks
Stephan