2012-08-28 76 views
2

我正在與jaxb一起工作,嘗試使用WebServiceGatewaySupport編寫自定義解組過程。Spring jaxb WebServiceGatewaySupport實現java.lang.IllegalArgumentException

我的課程在下面。問題是與響應,當我打電話以下方法

getWebServiceTemplate().sendSourceAndReceiveToResult 

它崩潰與消息「java.lang.IllegalArgumentException異常:‘URI’不能爲空」。它似乎即使我正在使用StringResult,它試圖解析XML並找到一個XML/SOAP響應錯誤。

public class WUResultGateway extends WebServiceGatewaySupport{ 

    private WebServiceTemplate webServiceTemplate; 

    private SourceExtractor ratingResponseExtractor = new WUResponseExtractor(); 

    public WUResultGateway(WebServiceTemplate webServiceTemplate){ 
      this.webServiceTemplate = webServiceTemplate; 
    } 
    private Source marshall(SendRDCResults results) throws IOException{ 

     StringResult resp = new StringResult(); 
     Marshaller marshaller = webServiceTemplate.getMarshaller(); 
     marshaller.marshal(results, resp); 

     return new ResourceSource(new ByteArrayResource(resp.toString().getBytes())); 
    } 

    public Object wuResponse(SendRDCResults results) throws IOException{ 
     //StringSource source = new StringSource(); 
     Result result = new StreamResult(); 
     StringResult strResult = new StringResult(); 
     boolean flag = getWebServiceTemplate().sendSourceAndReceiveToResult(marshall(results), strResult); 
     return result; 
    } 

} 

不作任何改變,從服務器的響應,我想在絃樂或簡單的XML格式的值沒有錯誤。誰能幫忙?

回答

1

setDefaultUri(webServiceTemplate.getDefaultUri());

終於看起來如下

public Object wuResponse(SendRDCResults results) throws IOException{ 
      //StringSource source = new StringSource(); 
      Result result = new StreamResult(); 
      StringResult strResult = new StringResult(); 
      setDefaultUri(webServiceTemplate.getDefaultUri()); 
      boolean flag = getWebServiceTemplate().sendSourceAndReceiveToResult(marshall(results), strResult); 
      return result; 
     }