-
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!
-
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.
-
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!
-
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!
-
XPath doesn't handle Integers, but it does do Doubles. See http://static.springframework.org/sp...r.html#d0e2094, the end of the section.
-
Interesting. Thanks for the clarification. I'll try that out.
-
Hi all,
I know i am digging the old thread but I am really want this to work.
I am trying to use xmlBeansMarshaller with PayloadRootQNameEndpointMapping
By going through the documents and airline example I did the following
My spring-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"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd">
<description>
This web application context contains Spring-WS beans. The beans defined in this context are automatically
detected by Spring-WS, similar to the way Controllers are picked up in Spring Web MVC.
</description>
<bean id="xmlBeansMarshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller" />
<bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
<property name="marshaller" ref="xmlBeansMarshaller"/>
<property name="unmarshaller" ref="xmlBeansMarshaller"/>
</bean>
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="mappings">
<props>
<prop key="{http://cia.crossview.com/customer/customersegments}CustomerProfileRequest">customerEndpoint</prop>
</props>
</property>
<property name="interceptors">
<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
</property>
</bean>
<bean id="customerEndpoint" class="com.crossview.cia.ws.customer.segment.ws.CustomerProfileEndpoint">
<description>
This endpoint handles Customer Profile requests.
</description>
<property name="customerService" ref="customerService"/>
</bean>
<bean id="customer" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<description>
This bean definition represents a WSDL definition that is generated at runtime. It can be retrieved by
going to /ciaservices/customer.wsdl (i.e. the bean name corresponds to the filename).
</description>
<property name="schema" ref="schema"/>
<property name="portTypeName" value="Customer"/>
<property name="locationUri" value="http://localhost:8080/ciaservices/customer"/>
<property name="targetNamespace" value="http://cia.crossview.com/customer/customersegments"/>
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<description>
This bean definition contains the XSD schema.
</description>
<property name="xsd" value="/WEB-INF/customer.xsd"/>
</bean>
<bean id="customerService" class="com.crossview.cia.ws.customer.services.CustomerProfileServiceImpl">
<description>
This bean is our "business" service.
</description>
</bean>
</beans>
And I am able to generate the wsdl file. But when I am trying to hit it using SOAPSonar I am getting :
No adapter for endpoint [com.crossview.cia.ws.customer.segment.ws.CustomerP rofileEndpoint@1b2ede8]: Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring>
I am not clear how to implement my Endpoint? which class to extend?, which method to override? and how to handle the request and response?
I have created the xmlbeans jar for my xsd.
my endpoint
Code:
public class CustomerProfileEndpoint extends AbstractDomPayloadEndpoint
{
public void setCustomerService(CustomerProfileService customerService) {
this.customerService = customerService;
}
protected Element invokeInternal(Element requestElement, Document document) throws Exception {
// TODO not clear how to handle request and response
// i am sending 2 parameters in the request
userId, userAge
and want to send Name-value pair say userId-- userName
}
}
Please guide me how can I implement this using xmlBeansMarshaller