springjaxbwebservicetemplate

Spring jaxb WebServiceGatewaySupport implementation java.lang.IllegalArgumentException


I'm working in jaxb with Spring, trying to write a custom unmarshalling process using WebServiceGatewaySupport.

My class is below. The problem is with response, when I call the following method

getWebServiceTemplate().sendSourceAndReceiveToResult

It crashes with message "java.lang.IllegalArgumentException: 'uri' must not be empty". It seems like even though I am using StringResult, it is trying to parse xml and finding a xml/soap response error.

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;
    }

}

Without making any change to the response from the server, I want to get values in s String or simple xml format without errors. Can anyone help?


Solution

  • setDefaultUri(webServiceTemplate.getDefaultUri());

    finally looks as follows

        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;
            }