Announcement Announcement Module
Collapse
No announcement yet.
PayloadRootAnnotationMethodEndpointMapping usage Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PayloadRootAnnotationMethodEndpointMapping usage

    Hi Arjen,
    One more question I have written an endpoint mapping class that have 2 methods orderSend() and orderDelete() and i want to use a single endpoint class for the 2 of them instead of 2 different endpoint classes.
    E.g
    @PayloadRoot(localPart =OrderSendRequest, namespace = http://myExample.com/types/OrderEndpointIntf)
    public Source orderSend(@XPathParam("//tns:id")String id,
    @XPathParam("//tns:message")Message message)
    {
    }
    @PayloadRoot(localPart =OrderDelRequest, namespace = http://myExample.com/types/OrderEndpointIntf)
    public Source orderDel(@XPathParam("//tns:id")String id)
    {
    }

    Now i need to know how to use the PayloadRootAnnotationMethodEndpointMapping for the send and delete requests

  • #2
    That looks good. You only need to create a Spring app context that contains the @Endpoint bean itself, and the PayloadRootAnnotationMethodEndpointMapping. The mapping will detect the annotated bean automatically. Look in the airline sample to see how it is done.

    Comment


    • #3
      Well thats exaclty what i dont know how to write.And the airline example doesnt explain how to write the AnnotationMapping.
      Is it done this way:

      <bean id="payloadMapping" class="org.springframework.ws.soap.endpoint.Payloa dRootAnnotationMethodEndpointMapping">
      <property name="mappings">
      <props>
      <prop key="{http://myExample.com/types/OrderEndpointIntf}OrderSendRequest">OrderEndpoint</prop>
      <prop key="{http://myExample.com/types/OrderEndpointIntf}OrderDelRequest">OrderEndpoint</prop>
      </props>
      </property>
      </bean>

      <bean id="OrderEndpoint" class="com.service.OrderEndpoint">
      <property name="orderService" ref="OrderService"/>
      </bean>

      If it is this way then how will it know which method it had to call in the end point for each of the OrderSend and OrderRecall Request.

      Also in the airline example why do i need an appContext.xml
      and appContext-ws.xml.Cant i declare everythin in the spring-ws-servlet.xml.

      Comment


      • #4
        If you watch carefully, you will see that the PayloadRootAnnotationMethodEndpointMapping doesn't have a mappings property in the airline sample:

        Code:
        <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
                <description>
                    Detects @PayloadRoot annotations on @Endpoint bean methods. The MarshallingAirlineEndpoint
                    has such annotations. It uses two interceptors: one that logs the message payload, and the other validates
                    it accoring to the 'airline.xsd' schema file.
                </description>
                <property name="interceptors">
                    <list>
                        <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
                        <bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
                            <property name="schema" value="/WEB-INF/xsd/airline.xsd"/>
                            <property name="validateRequest" value="true"/>
                            <property name="validateResponse" value="true"/>
                        </bean>
                    </list>
                </property>
                <property name="order" value="1"/>
            </bean>
        It only has interceptors. Like I said before, the PayloadRootAnnotationMethodEndpointMapping automatically picks up all @PayloadRoot methods on @Endpoint beans. No need to define a mapping.

        Alternatively, if you don't use annotations, you can use the PayloadRootQNameEndpointMapping, also done in the airline sample. Note that it is highly untypical to have multiple mappings, I only did it in the sample because I wanted to show that it is possible. Here is the PayloadRootQNameEndpointMapping sample from the airline app:

        Code:
            <bean id="secureMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
                <description>
                    This endpoint mapping is used for endpoints that are secured via WS-Security. It uses a
                    securityInterceptor, defined in applicationContext-security.xml, to validate incoming messages.
                </description>
                <property name="mappings">
                    <props>
                        <prop key="{http://www.springframework.org/spring-ws/samples/airline/schemas}GetFrequentFlyerMileageRequest">
                            getFrequentFlyerMileageEndpoint
                        </prop>
                    </props>
                </property>
                <property name="interceptors">
                    <list>
                        <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor"/>
                        <ref bean="wsSecurityInterceptor"/>
                    </list>
                </property>
                <property name="order" value="2"/>
            </bean>
        You will see that this mapping doesn't use annotations, but rather has an explicit "mapping" property, which maps qualified names to endpoint beans.

        So it's just two different things to do the same thing. Not recommended, but possible.

        Comment


        • #5
          How to apply different interceptors for endpoints using PayloadRootAnnotationMethodE?

          Thanks for very clear explanation in this thread. I have one question though. I have two endpoints using annotations. I want to apply different interceptors to each of them. Not sure if there is a way to do this using PayloadRootAnnotationMethodEndpointMapping.

          I can use the PayloadRootQNameEndpointMapping but I have 25 methods in my wsdl and this is making my xml file a bit ugly... doesn't look like I can use regex for QName.

          Would really appreciate any suggestions in this regard.

          Thanks,
          Sreekant

          Comment


          • #6
            Posted exactly the same question regarding two PayloadRootAnnotationMethodEndpointMapping definitions today.
            Any news on this?

            Comment


            • #7
              Different interceptors using PayloadRootAnnotationMethodEndpointMapping

              Anyone have an answer to this yet? If I want to apply different interceptors to different end points, how is that possible using PayloadRootAnnotationMethodEndpointMapping? I don't think it can make any distinction.

              NB: http://stackoverflow.com/questions/1...ndpointmapping

              Comment


              • #8
                I found a solution, look here:
                http://blog.datazuul.com/roller/entr...ne_interceptor

                Comment

                Working...
                X