### Question:
ServiceCollectionResource { @POST @Produces(MediaType.APPLICATION_XML) @Consumes(MediaType.APPLICATION_JSON) public Response richQueryForXML(JSONObject queryDocument, @Context UriInfo ui) throws WebApplicationException { MultivaluedMap<String, String> queryParams = ui.getQueryParameters(); Set<String> s = queryParams.keySet(); Map<String, Object> m = new HashMap<String, Object>(); for (Iterator<String> iterator = s.iterator(); iterator.hasNext();) { String key = (String) iterator.next(); m.put(key, queryParams.getFirst(key)); } QueryResult jArr = null; try { jArr = col.queryForXML(queryDocument, m); } catch (Exception e) { Log.logException("Error in doing query for services in XML format", e, logger); throw new WebApplicationException(e,Response.status(Status.INTERNAL_SERVER_ERROR).entity("<error>"+e.getCause().toString()+"</error>").build()); } if (jArr == null) { return Response.ok().status(Status.NO_CONTENT).build(); } else if (jArr.getCount() == BigInteger.ZERO) { return Response.ok(jArr).status(Status.NO_CONTENT).build(); } return Response.ok(jArr).build(); } ServiceCollectionResource(); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/urls") Response getServiceEndPoints(); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/types") Response getServiceTypes(); @GET @Produces(MediaType.APPLICATION_JSON) Response queryWithParamsForJSON(@Context UriInfo ui); @GET @Produces({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) Response queryWithParamsForXML(@Context UriInfo ui); @POST @Produces({MediaType.APPLICATION_JSON}) @Consumes(MediaType.APPLICATION_JSON) Response richQueryForJSON(JSONObject queryDocument, @Context UriInfo ui); @POST @Produces(MediaType.APPLICATION_XML) @Consumes(MediaType.APPLICATION_JSON) Response richQueryForXML(JSONObject queryDocument, @Context UriInfo ui); @Deprecated @GET @Path("/query.xml") @Produces({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) Response queryXml(@Context UriInfo ui); @Deprecated @GET @Path("/pagedquery") @Produces(MediaType.APPLICATION_JSON) Response pagedQuery(@Context UriInfo ui); @Deprecated @GET @Path("/pagedquery") @Produces(MediaType.APPLICATION_XML) Response pagedQueryGlue2(@Context UriInfo ui);  }### Answer:
@Test @FunctionalTest(id = "ServiceEndpointRecordsQueryForXMLTest", description = "Test queries defined in JSON format for the service endpoint records in XML format") public void testRichQueryForXML() throws JSONException { EMIRClient cr = new EMIRClient(BaseURI); JSONObject orQueryDocument = new JSONObject(); JSONObject p1 = new JSONObject(); p1.put(ServiceBasicAttributeNames.SERVICE_TYPE.getAttributeName(), "jms"); JSONObject p2 = new JSONObject(); p2.put(ServiceBasicAttributeNames.SERVICE_ENDPOINT_HEALTH_STATE .getAttributeName(), "ok"); JSONArray j = new JSONArray(); j.put(p1); j.put(p2); orQueryDocument.put("$or", j); assertEquals(100, cr.richQueryForXML(orQueryDocument).getService().size()); JSONObject jo = new JSONObject(); jo.put("$ne", "ok"); JSONObject ne = new JSONObject(); ne.put(ServiceBasicAttributeNames.SERVICE_ENDPOINT_HEALTH_STATE .getAttributeName(), jo); assertEquals(50, cr.richQueryForXML(ne).getService().size()); }