我正在使用Spring在jaxb中工作,尝试使用WebServiceGatewaySupport编写自定义的解组过程。
我的课程如下。当我调用以下方法时,问题在于响应
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;
}
}
如果不对服务器的响应进行任何更改,我希望以s String或简单的xml格式获取值而不会出现错误。有人可以帮忙吗?
答案 0 :(得分: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;
}