通过Spring引导调用soap服务并在其中设置标头Content-Type,但它显示错误contenttype.toLowerCase is not a function
我的Soap连接器呼叫是:
公共类SOAPConnector扩展了WebServiceGatewaySupport {
public Object callWebService(String url, Object request, Map<String, String> headers) {
WebServiceTemplate webServiceTemplate = getWebServiceTemplate();
return webServiceTemplate.marshalSendAndReceive(url, request, new WebServiceMessageCallback() {
public void doWithMessage(WebServiceMessage message) throws IOException {
TransportContext context = TransportContextHolder.getTransportContext();
HttpUrlConnection connection = (HttpUrlConnection) context.getConnection();
for (Map.Entry<String, String> header : headers.entrySet()) {
connection.addRequestHeader(header.getKey(), header.getValue());
}
}
});
}
}
从配置文件和标头映射中调用和callWebService函数,如下所示:
Map<String, String> headers = new HashMap<>();
headers.put("accept", "application/xml");
headers.put("Content-Type", "text/xml;charset=UTF-8");