package se.riges.search.lm.resources;

import java.io.IOException;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

import se.riges.lm.rmi.exceptions.LMAccountException;
import se.riges.search.lm.ServiceUtils;

@Path("elevation")
public class Elevation {
	@GET
	@Produces("application/json")
	public Response get(@QueryParam("lmuser") String lmUser, @QueryParam("srid") int srid, @QueryParam("x") double x, @QueryParam("y") double y) throws LMAccountException, IOException {
		final String url = "https://services.lantmateriet.se/distribution/produkter/hojd/v1/rest/api";
		final String path = "/hojd/" + srid + "/" + x + "/" + y;
		
		final String username = ServiceUtils.getUsername(lmUser);
		final String password = ServiceUtils.getPassword(lmUser);
		final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
			    .nonPreemptive().credentials(username, password).build();
		
		final Client client = ClientBuilder.newClient();
		client.register(feature);
		
		final WebTarget target = client.target(url).path(path);
		return target.request().get();
	}
}

@@ -110,16 +110,46 @@
 s.Path;%0A
+import javax.ws.rs.PathParam;%0A
 import j
@@ -169,16 +169,16 @@
 oduces;%0A
-
 import j
@@ -536,16 +536,31 @@
 levation
+/%7Bsrid%7D/%7Bx%7D/%7By%7D
 %22)%0Apubli
@@ -624,24 +624,22 @@
 %09public 
-Response
+String
  get(@Qu
@@ -673,21 +673,20 @@
 mUser, @
-Query
+Path
 Param(%22s
@@ -702,21 +702,20 @@
  srid, @
-Query
+Path
 Param(%22x
@@ -728,21 +728,20 @@
 ble x, @
-Query
+Path
 Param(%22y
@@ -1372,14 +1372,27 @@
 ;%0A%09%09
-return
+Response response =
  tar
@@ -1412,13 +1412,79 @@
 .get();%0A
+%09%09String json = response.readEntity(String.class);%0A%09%09return json;%0A
 %09%7D%0A%7D%0A

Use same API as remote and fix entity marshaling