Announcement Announcement Module
Collapse
No announcement yet.
Problem with changing from XML endpoint mapping to annotation based endpoints Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with changing from XML endpoint mapping to annotation based endpoints

    Hello,

    I have a WebService configured via XML with enpoints derived from AbstractDomPayloadEndpoint. Now I would like to change it to annotation based configuration of endpoints, but the entpoint method never gets called.

    First, here are the important parts (bean definitions) of my current working setup:

    Code:
    <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />
    
    <bean id="messageReceiver" class="org.springframework.ws.soap.server.SoapMessageDispatcher">
      <property name="endpointMappings" ref="endpointMapping" />
    </bean>
    
    <bean id="endpointMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
      <property name="mappings">
        <props>
          <prop key="{http://www.foo.net/dataService/}createFooRequest">createFooRequestEndpoint</prop>
        </props>
      </property>
    </bean>
    
    <bean id="createFooRequestEndpoint" class="de.test.ws.CreateFooRequestEndpoint" />
    
    <bean id="soapHandler" class="org.springframework.ws.transport.http.WebServiceMessageReceiverHttpHandler">
      <property name="messageFactory" ref="messageFactory" />
      <property name="messageReceiver" ref="messageReceiver" />
    </bean>
    
    <bean id="wsdlHandler" class="org.springframework.ws.transport.http.WsdlDefinitionHttpHandler">
      <property name="definition" ref="wsdlDefinition" />
    </bean>
    (some missing beans are not shown just for clarity reasons)

    Now we can see that the full qualified name of a WebService request is:

    Code:
    {http://www.foo.net/dataService/}createFooRequest
    Now here is the class that acts as an endpoint:

    Code:
    public class CreateFooRequestEndpoint extends AbstractDomPayloadEndpoint {
    
      @Override
      protected Element invokeInternal( Element element, Document document ) throws Exception {
        System.out.println( "invokeInternal" );
        return null;
      }
    }
    This works without problems, as soon as I send a SOAP message with the "{http://www.foo.net/dataService/}createFooRequest", the "invokeInternal" method of the "CreateFooRequestEndpoint" class gets invoked.


    Now I would like to do it via annotations - and this is what I can't get working.

    I changed the endpointMapping Bean this way:

    Code:
    <bean id="endpointMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
      <property name="defaultEndpoint" ref="dataServiceEndpoint" />
    </bean>
    
    <bean id="dataServiceEndpoint" class="de.test.ws.DataServiceEndpoint" />
    My "dataServiceEndpoint" looks like this:

    Code:
    @Endpoint
    public class DataServiceEndpoint {
    	
      // Remember: the full qualified request name should be:
      // {http://www.foo.net/dataService/}createFooRequest
    
      @PayloadRoot( localPart = "createFooRequest", namespace = "http://www.foo.net/dataService/" )
      public Element createFoo( Element element, Document document ) {
        System.out.println( "DataServiceEndpoint.createMission" );
        return null;
      }
    }

    When I now call the webservice, no console output is generated, the "DataServiceEndpoint.createFoo" method never gets called. Instead, I get the following SOAP fault:

    Code:
    <SOAP-ENV:Fault>
      <faultcode>SOAP-ENV:Server</faultcode>
      <faultstring xml:lang="en">No adapter for endpoint [de.foo.ws.DataServiceEndpoint@feb48]: Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring>
    </SOAP-ENV:Fault>
    My endpoint (with the annotaion style) does not implement a MessageHandler or PayloadEndpoint, of course. I don't know, if the fault message is just not yet prepared to give annotation-failure hints.

    So, to make a long story short, I have the following two questions:

    1. Is the method signature of "DataServiceEndpoint.createFoo" correct? I always see examples which use marshalling, so the "createFoo" method should take a "FooRequest" object as the only parameter. Do I have to use marshalling, or if not, what must the formal parameters look like for the "createFooRequest" method?

    2. What else might be wrong, do I have to configure some other beans?


    Thanks a lot for your help!


    Best regards,
    Timo

  • #2
    I figured it out myself - of course, I need to use the "PayloadRootAnnotationMethodEndpointMapping" class so annotations can be detected.

    Comment

    Working...
    X