标头Content-Type的Soap调用在Java Spring Boot中不起作用

时间:2018-07-13 10:10:56

标签: java spring-boot soap

通过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");

0 个答案:

没有答案