Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 回调外部的Spring WS客户端更新变量_Java_Spring_Soap_Callback_Spring Ws - Fatal编程技术网

Java 回调外部的Spring WS客户端更新变量

Java 回调外部的Spring WS客户端更新变量,java,spring,soap,callback,spring-ws,Java,Spring,Soap,Callback,Spring Ws,我正在从WebServiceMessageCallback提取HTTP响应,但是当我尝试更新回调外部的变量时,我得到:不能在另一个方法中定义的内部类中引用非最终变量rawResponse String rawResponse=null; try { this.webserviceTemplate.sendSourceAndReceiveToResult(source, new WebServiceMessageCallback() { @

我正在从WebServiceMessageCallback提取HTTP响应,但是当我尝试更新回调外部的变量时,我得到:不能在另一个方法中定义的内部类中引用非最终变量rawResponse

String rawResponse=null;
try { 
    this.webserviceTemplate.sendSourceAndReceiveToResult(source,
        new WebServiceMessageCallback() {
                @Override
                public void doWithMessage(WebServiceMessage message)
                        throws IOException, TransformerException {
                    TransportContext context = TransportContextHolder.getTransportContext();
                    CommonsHttpConnection  connection = (CommonsHttpConnection  )context.getConnection();
                    context.getConnection();
                    rawResponse = connection.getPostMethod().getResponseBodyAsString();*/

您真的应该使用final变量来完成。AtomicReference是为您准备的:

final AtimicReference<String> rawResponse = new AtimicReference<String>();
try { 
    this.webserviceTemplate.sendSourceAndReceiveToResult(source,
        new WebServiceMessageCallback() {
                @Override
                public void doWithMessage(WebServiceMessage message)
                        throws IOException, TransformerException {
...
                    rawResponse.set(connection.getPostMethod().getResponseBodyAsString());