Clicky

Play - Synchronous server calls with Jersey

February 16, 2016

Synchronous server calls with Jersey

Edit your build.sbt:
<![CDATA[ libraryDependencies ++= Seq( (…) “com.sun.jersey” % “jersey-client” % “1.19”, “com.sun.jersey” % “jersey-core” % “1.19” (…) ) ]]>
Edit your Java client class:
<![CDATA[ Client client = Client.create(); client.addFilter(new com.sun.jersey.api.client.filter.HTTPBasicAuthFilter(login, password)); WebResource webResource = client.resource(baseURL) .queryParam(“param1”, “param_value”) .queryParam(“param2”, “param_value”) .queryParam(“param3”, “param_value”); String response = webResource.header(“Content-Type”, “application/xml”).get(String.class); ]]>

SyntaxHighlighter.highlight();