Invalid wsdl generated by spring-ws when the request element doesn't end with 'Request'

前端 未结 5 1851
执念已碎
执念已碎 2021-02-13 14:08

I must prepare a webservice to accept anan already defined wsdl structure. I followed the tutorial found here, with source code for the test project downloadable here.

F

5条回答
  •  灰色年华
    2021-02-13 14:10

    I had the same error. My setup was as follows:

    Generation of classes from an existing XSD file using the maven jaxb2-maven-plugin

    
    
        org.codehaus.mojo
        jaxb2-maven-plugin
        2.5.0
        
            
                xjc
                
                    xjc
                
            
        
        
            
            com.company
            true
            true
            
                ${project.basedir}/src/main/resources/file.xsd
            
        
    
    

    The handler method:

    @PayloadRoot(namespace = "URI", localPart = "LOCAL_PART")
    @ResponsePayload
    public JAXBElement retrieveNextStatesRequest(@RequestPayload Request request) {
        // Logic
        return new Response();
    }
    

    The jaxb2-maven-plugin however has no possibility to add a XmlRoot annotation. However it provides an ObjectFactory to generate instances wrapped in JAXBElement instances.

    So when changes the method accordingly the SOAP requests now work as expected:

    @PayloadRoot(namespace = "URI", localPart = "LOCAL_PART")
    @ResponsePayload
    public Response retrieveNextStatesRequest(@RequestPayload Request request) {
        // Logic
        return new ObjectFactory.createResponse(new Response());
    }
    

提交回复
热议问题