【发布时间】:2020-06-22 07:07:36
【问题描述】:
我在企业级使用以下 SOAP 请求
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
....
</soapenv:Header>
<soapenv:Body>
<UserRQ xmlns="http://www.user.org/USER/INFO" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
...
为了使用邮递员(或其他)访问 API,我正在使用 WebServiceClient 并且当前将整个请求(包括标头和正文)传递给它
ApplicationClient.java:
public class ApplicationClient extends WebServiceGatewaySupport {
//Envelope is the whole request
public ResponseEntity<String> getResults(Envelope envelope) {
WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("org.test.wsdl");
webServiceTemplate.setMarshaller(marshaller);
webServiceTemplate.setUnmarshaller(marshaller);
ResponseEntity<String> response = (ResponseEntity<String>) webServiceTemplate.marshalSendAndReceive("<URL>", envelope);
log.info(response.getStatusCode());
return response;
}
}
响应正确(得到 200 响应码)。无论如何通过Web服务客户端分别传递标头和正文?或者我们如何编组标题?
【问题讨论】:
标签: java web-services soap soap-client webservice-client