Spring WS sendSourceAndReceiveToResult 方法通过 POST

Spring WS sendSourceAndReceiveToResult method via POST

如何将 Using Spring Web Services on the Client 中的 sendSourceAndReceiveToResult() 与自定义序列化程序一起使用?

问题不正确。任何 SOAP 请求都是 POST 通过 HTTP 传输。

如果我们查看 WebServiceTemplate#sendSourceAndReceiveToResult 源代码,我们会看到:

 Boolean retVal = doSendAndReceive(uri, transformer, requestPayload, requestCallback,
                new SourceExtractor<Boolean>() {

                    public Boolean extractData(Source source) throws IOException, TransformerException {
                        if (source != null) {
                            transformer.transform(source, responseResult);
                        }
                        return Boolean.TRUE;
                    }
                });

注意doSendAndReceive内部方法调用。任何高级 WebServiceTemplate# API 都这样做。在后台,org.springframework.ws.transport.http.HttpUrlConnectionMessageSender 用作默认 SOAP 传输,其中 connection.setRequestMethod(HttpTransportConstants.METHOD_POST); 用于构建 HttpUrlConnection

就这些了。