简体   繁体   English

如何从Spring 3.x调用Web服务或URL

[英]How to call a webservice or url from spring 3.x

I really don't know how to proceed with this in Spring. 我真的不知道在春季如何进行此操作。

I have an URL https://test.payu.in/merchant/postservice.php?form=2 which I have to call with some parameters and consume the result. 我有一个URL https://test.payu.in/merchant/postservice.php?form=2 ,我必须使用一些参数调用它并使用结果。

How can I do it with Spring ? 如何使用Spring来做?

You can use RestTemplate , which supports mashalling, unmarshalling, variable resolution, etc. 您可以使用RestTemplate ,它支持mashalling,解组编,可变分辨率等。

For example, you have to do something similar to this: 例如,您必须执行以下操作:

Map<String, String> vars = new HashMap<String, String>();
vars.put("hotel", "42");
vars.put("booking", "21");
String result = 
    restTemplate.getForObject("http://example.com/hotels/{hotel}/bookings/{booking}", String.class, vars);

More info: 更多信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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