Spring MVC - Calling a rest service from inside another rest service

前端 未结 2 480
失恋的感觉
失恋的感觉 2021-02-06 14:48

I\'m currently having a really weird issue with calling one REST service from inside another one and I could really use a hand in working out what I\'m doing wrong.

2条回答
  •  甜味超标
    2021-02-06 15:43

    Use RestTemplate.exchange mentioned below :

    ResponseEntity response = RestTemplate.exchange(EndPointURL, HttpMethod.GET/POST/PUT/DELETE, HttpEntity/headers, URI-Variables)
    

    The input paramater's are described below :

    • EndpointURL -- SOAP End point URL ,that the REST service has to consume.

    • HTTPMethod -- Method Type such as GET ,PUT ,POST ,DELETE etc.

    • HTTPEntity -- Soap requires for mandatory sender headers.Make sure that you set your header(s) name and value as key-Value pair in HTTP headers.

    • URI-Variables -- (Object... urivariables) such as String.class ,Integer.class

      You should also put the connectTimeout , isSSLDisabled, responseCached in the constructor while generating request to restTemplate.

提交回复
热议问题