Search code examples
springwsdlspring-ws

Generate Spring Source Endpoints with WSDL


Can you generate a full contract and request/response objects into Spring Source Web Service format with @EndPoint annotations from a WSDL?


Solution

  • Those objects are not automatically generated. The WSDL would be the contract - there you'll find the targetNamespace and the localPart. E.g.

    <xsd:schema targetNamespace="this:is.the.target:namespace" xmlns="this:is.the.target:namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <xsd:element name="myLocalPart">
            <xsd:complexType>
    

    The localPart ist the root XML element of your SOAP request payload. Now, you define an endpoint:

    @Endpoint
    public class MyEndpoint {
        @PayloadRoot(namespace="this:is.the.target:namespace", localPart="myLocalPart")
        @ResponsePayload
        public void handleRequest(@RequestPayload final Element elem) {
            // do something here...
        }
    

    If you've set up Spring-Ws dispatcher correctly, this would be sufficient for at least accepting the request. If you want the request to be automatically unmarshalled, you'll have to set up a marshaller/unmarshaller and define the OXM mapping somehow.