如何使用Spring WS通过传递预生成的SOAP请求而不是XML有效负载来查询基于SOAP的端点?

时间:2013-09-03 13:03:54

标签: spring webservice-client spring-ws

需要使用Sprint WS查询基于SOAP的端点 - 但这里不是传递XML有效负载,而是传递生成的SOAP请求本身。我现在正在使用org.springframework.ws.client.core.WebServiceTemplate吗?

1 个答案:

答案 0 :(得分:0)

您可以执行以下操作:

ClientMessageCallBack _callBack = 
                new ClientMessageCallBack("yournamespaceuri/operationx");

final String _message = 
        "<ns1:operationx xmlns:ns1="yournamespaceuri"></ns1:operationx>";

StreamSource _source = new StreamSource(new StringReader(_message));
// the result will be output in the console
StreamResult _result = new StreamResult(System.out);

// suppose you have a reference to webServiceTemplate
webServiceTemplate.sendSourceAndReceiveToResult(_source,_callBack, _result);