Проблема с использованием клиента resteasy для вызова служб отдыха, которые принимают json в теле - PullRequest
0 голосов
/ 04 июля 2019

Я написал resteasy веб-службы rest, после развертывания они работают должным образом при тестировании с почтальоном.Теперь мне нужно написать клиент внутри приложения javafx, используя restasy client-proxy.Все работает для сервисов, которые используют только параметры пути, у меня проблемы с передачей сложных объектов (json) в тело.

Код моего сервера:

@Path("/manutenzioni/ticket")
public class GestioneTicketRestService {

        @PUT
        @Path("/interventi/{annoRichiesta}/{numeroRichiesta}")
        @Produces(MediaType.APPLICATION_JSON)
        @Consumes(MediaType.APPLICATION_JSON)
        public InterventoTicket apriInterventoTicket(@PathParam("annoRichiesta") Integer annoRichiesta, 
                @PathParam("numeroRichiesta") Integer numeroRichiesta, InterventoTicket interventoTicket) throws Exception {
            GestioneTicketEjbRemote ejb = (GestioneTicketEjbRemote) EjbFactory.getBeans(EjbImpl.GESTIONE_TICKET_EJB);
            return ejb.apriInterventoTicket(annoRichiesta, numeroRichiesta, interventoTicket);
        }

Код моего клиента:

 public ProxyGestioneTicket getProxyGestioneTicket() {
        ResteasyClient client = new ResteasyClientBuilder().build();
        ResteasyWebTarget target = client.target(getTarget());
        target.register(new BasicAuthentication(username, password));
        ProxyGestioneTicket proxy = target.proxy(ProxyGestioneTicket.class);
        return proxy;
    }

Интерфейс прокси:

   public interface ProxyGestioneTicket {
    @PUT
    @Path("/manutenzioni/ticket/interventi/{annoRichiesta}/{numeroRichiesta}")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    public InterventoTicket apriInterventoTicket(@PathParam("annoRichiesta") Integer annoRichiesta, 
                    @PathParam("numeroRichiesta") Integer numeroRichiesta, 
                    InterventoTicket interventoTicket) throws Exception;
    ...

Вызов:

InterventoTicket interventoTicket = new InterventoTicket();
interventoTicket.setDataInizio("20190101");
//set....             
ProxyGestioneTicket proxy = getProxyGestioneTicket();          
proxy.apriInterventoTicket(2019, 7008, interventoTicket);

на стороне сервера Я получаю нулевое значение для переменной "interventoTicket".

Что я делаюнеправильно?Спасибо

...