【发布时间】:2019-01-30 17:07:32
【问题描述】:
这是我第一次一起使用 SOAP 和 spring。但是问题很多。不确定它的有效问题不是我的要求。
所以我在 SOAP 点上使用 xml 作为输入。这项服务运作良好。 现在我正在尝试调用服务方法,类似于下面的代码。
HttpHeaders header = new HttpHeaders();
header.set(HttpHeaders.CONTENT_TYPE, "application/saop+xml");
Resource resource = new ClassPathResource("soap/valid-req.xml");
String xml = IOUtils.toString(resource.getInputStream(), "UTF-8");
HttpEntity entity = new HttpEntity<>(xml, header);
String response = restTemplate.postForObject("http://localhost:8080/ws/HttpImport", entity, String.class);
是否可以使用 spring Rest Template 调用 SOAP 服务,或者我们是否有其他替代方法。
有人可以帮忙吗?
提前致谢。
【问题讨论】:
-
你看过spring.io/guides/gs/producing-web-service 吗? ...我对 SOAP 一无所知,但这看起来很符合您的需要。