Java Questions
Java Questions

Reputation: 7953

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.

How can I do it with Spring ?

Upvotes: 1

Views: 4407

Answers (1)

Konstantin Yovkov
Konstantin Yovkov

Reputation: 62864

You can use RestTemplate, which supports mashalling, unmarshalling, variable resolution, etc.

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:

Upvotes: 4

Related Questions