简体   繁体   中英

Java- Invoke .net wcf web service Spring

I have created spring rest controller. In that i need use .net wcf service inside rest controller. Is it possible to consume .net wcf web service in java application? If it's possible, could you please explain me how to consume wcf service in java

Note: .net wcf service hosted in remote server

As wcf web service is just another web service so we can consume web service easily using RestTemplate of Spring. If your web service is based on GET method of HTTP than you can call that in your spring rest controller as in the following code:

RestTemplate restTemplate = new RestTemplate();
Quote quote = restTemplate.getForObject(" http://gturnquist-quoters.cfapps.io/api/random ", Quote.class);

Here Quote is pojo class you can create to store the response of the wcf web service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM