Results 1 to 7 of 7

Thread: No adapter for endpoint

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Posts
    138

    Default No adapter for endpoint

    I've read a few other threads related to this, but it doesn't seem that I've discovered my fault. I've created a Java class with @Endpoint and @PayloadRoot annotations, configured the Marshalling beans as per the airline example, however, I continue to get this error. Below are examples of my code (trimmed for brevity, doesn't include the WSDL generator). Hopefully someone can see something I overlooked. For reference, I'm using Netbeans 6.0 (which has some nice support for JAXB Binding generation, btw), Java 1.5, Spring 2.0, and Spring WS 1.0.2, and JAXB 2.1.

    Full Error
    Code:
    No adapter for endpoint [public javax.xml.bind.JAXBElement<com.mg21.ws.bindings.catalog.Product> com.mg21.shotgun.ws.endpoint.ProductEndpoint.productRequest(int)]: Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?
    catalog-ws-servlet.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
        <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
            <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/schemas/catalog.xsd"/>
                        <property name="validateRequest" value="true"/>
                        <property name="validateResponse" value="true"/>
                    </bean>
                </list>
            </property>
            <property name="order" value="1"/>
        </bean>
    
        <bean id="marshallingEndpoint" class="com.mg21.ws.endpoint.ProductEndpoint">
            <description>
                This endpoint handles echo requests.
            </description>
            <property name="productService" ref="productService"/>
        </bean>
    
        <bean id="productService" class="com.mg21.ws.service.ProductService">
            <description>
                This bean is our "business" service.
            </description>
        </bean>
    
        <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
            <description>
                The JAXB 2 Marshaller is used by the endpoints.
            </description>
            <property name="contextPath" value="com.mg21.ws.bindings.catalog"/>
        </bean>
        
        <bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
            <description>
                This adapter allows for methods that need and returns marshalled objects. The MarshallingEndpoint
                uses JAXB 2 objects.
            </description>
            <constructor-arg ref="marshaller"/>
        </bean>
    </beans>
    ProductEndpoint.java
    Code:
    @Endpoint
    public class ProductEndpoint {
    
        public static final String NAMESPACE_URI = "http://www.12gaugemedia.com/ws/services/catalog";
    
        public static final String PRODUCT_REQUEST_LOCAL_NAME = "productRequest";
    
        public static final String PRODUCT_RESPONSE_LOCAL_NAME = "productResponse";
    
        private ProductService productService;
        
        private ObjectFactory objectFactory = new ObjectFactory();
        
        @PayloadRoot(localPart = PRODUCT_REQUEST_LOCAL_NAME, namespace = NAMESPACE_URI)
        public JAXBElement<Product> productRequest(int id){      
          return objectFactory.createProductResponse(productService.productRequest(id));
        }
        
        public void setProductService(ProductService productService) {
          this.productService = productService;
        }
    }
    ProductRequest.java
    Code:
    public class ProductService {
    
      public Product productRequest (int i){
          Product product = new Product();
          product.setName("Product 1");
          product.setDescr("Lorem Ipsum");
          product.setBlurb("Dolor Amit");
          return product;
      }
    }
    catalog.xsd
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified"
            targetNamespace="http://www.12gaugemedia.com/ws/services/catalog"
            xmlns:tns="http://www.12gaugemedia.com/ws/services/catalog">
      
      <element name="productRequest">
        <simpleType>
          <restriction base = "int">
            <pattern value="([\d])+"/>
          </restriction>
        </simpleType>
      </element>
      
      <element name="productResponse" type="tns:Product" />
      
      <complexType name="Product">
        <all>
          <element name="name" />
          <element name="descr" />
          <element name="blurb" />
        </all>
      </complexType>
      
    </schema>
    Thanks!

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Try changing

    Code:
    public JAXBElement<Product> productRequest(int id)
    into
    Code:
    public JAXBElement<Product> productRequest(JAXBElement<Integer> id)
    and see if that works. JAXB doesn't support raw types, only when wrapped it these funny-looking JAXBElements.
    Last edited by Arjen Poutsma; Nov 19th, 2007 at 07:11 PM.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3
    Join Date
    Jul 2006
    Posts
    138

    Default

    Awesome... thanks for the pointer. I didn't notice that in the documentation. After switching that over, it worked like a charm. Wow, that was a whole day of frustration for something so trivial.

    Thanks again!

  4. #4
    Join Date
    Jul 2006
    Posts
    138

    Default

    I tried this same code with an XPath Endpoint and received a similar error:

    Code:
    No adapter for endpoint [public javax.xml.transform.Source com.mg21.ws.endpoint.ProductEndpoint.productRequest(javax.xml.bind.JAXBElement<java.lang.Integer>)]: Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?
    Code:
        @PayloadRoot(localPart = PRODUCT_REQUEST_LOCAL_NAME, namespace = NAMESPACE_URI)
        public Source productRequest(@XPathParam("/")JAXBElement<Integer> id){
          
          JAXBElement<Product> response = objectFactory.createProductResponse(productService.productRequest(id.getValue().intValue()));
                  
          return new MarshallingSource(marshaller, response);
        }
    I also replaced the GenericMarshallingMethodEndpointAdapter with a XPathParamAnnotationMethodEndpointAdapter as per the airline example.

    Code:
        <bean class="org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter">
            <property name="namespaces">
                <props>
                    <prop key="tns">http://www.12gaugemedia.com/ws/services/catalog</prop>
                </props>
            </property>
        </bean>
    When accessing a single simpleType element via XPath, should I be doing something different with my path? Could that even be related?

    I also tried using just "Integer" instead of JAXBElement<Integer> (because the airline example doesn't use JAXBElement types) to no avail:

    Code:
    public Source productRequest(@XPathParam("/")Integer id)
    Thanks again for your input, I truly appreciate your assistance!

  5. #5
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    XPath doesn't handle Integers, but it does do Doubles. See http://static.springframework.org/sp...r.html#d0e2094, the end of the section.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  6. #6
    Join Date
    Jul 2006
    Posts
    138

    Default

    Interesting. Thanks for the clarification. I'll try that out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •