No adapter for endpoint; Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?

*爱你&永不变心* 提交于 2019-12-03 01:57:25
lu_ko

I had a similar error message. My problem was in request and response class that I generated from XSD. It missed @XMLRootElement annotation. This caused that description of operation (in WSDL) and description of implemented method (in Endpoint) did not match. Adding JAXBElement to my endpoint method solved my problem.

import javax.xml.bind.JAXBElement;

@PayloadRoot(namespace = "http://foo.bar/books", localPart = "GetBook")
@ResponsePayload
public JAXBElement<MyReponse> getBook(@RequestPayload JAXBElement<MyRequest> myRequest) {
    ...

See this blog for more details: spring-ws: No adapter for endpoint

I'm not sure how your complete Endpoint looks, but the class should be annotated with @Endpoint or it should implement MessageHandler or PayloadEndpoint.

On other thing you can play with is the method signature. Spring-WS' endpoint mapping is pretty intelligent: it tries to map input and output classes from your method signature with the WSDL file. Are you sure a String is the @ResponsePayLoad, not a StoreImageResponse?

For example, here's the method signature of one of my endpoint

@PayloadRoot(
    localPart = "GetHiredCandidatesRequest", 
    namespace = DEFAULT_NAMESPACE
)
@ResponsePayload
public GetHiredCandidatesResponse getCandidates (
    @RequestPayload GetHiredCandidatesRequest getCandidate,
    MessageContext messageContext) {
    ...
}

Which is defined in my WSDL like this:

<wsdl:operation name="GetHiredCandidates">
    <wsdl:input message="tns:GetHiredCandidatesRequest" name="GetHiredCandidatesRequest"></wsdl:input>
    <wsdl:output message="tns:GetHiredCandidatesResponse" name="GetHiredCandidatesResponse"></wsdl:output>
</wsdl:operation>

Do you see how it's mapped? Perhaps you're missing something like that in your signature.

anshulkatta

First, as per the guidelines, there should be an Endpoint class

@Endpoint
public class EmpEndpoint {

    @Autowired
    private EmpService empService;

    //This is like @RequestMapping of Spring MVC    
    @PayloadRoot(localPart = "EmpServiceRequest", namespace = "http://www.example.org/")
    @ResponsePayload
    public EmpServiceResponse getemployeeDetails(@RequestPayload EmpServiceRequest request) {
        EmpServiceResponse response = new ObjectFactory().createEmpServiceResponse();
        List<Employee> l = empService.getemployeeDetails(request.getName());
        response.setName(l.get(0).getName());
        response.setEmail(l.get(0).getEmail());
        return response;
    }
}

And one Service and its implementation class which will have PayloadRoot and other Annotations (Request and Response)

And place this in your spring-servlet.xml

  <!-- To detect @Endpoint -->
<sws:annotation-driven/>

<!-- To detect @Service, @Component etc -->
<context:component-scan base-package="your package for eg com.employee" />

Same problem but in my case was because I forgot to place the annotations @ResponsePayload and @RequestPayload in the handler function. Just check it! It's probably all it's needed.

I was using WSDL file and did as below, then it worked.

@PayloadRoot(namespace = "http://www.myservice/v1.0/query", localPart = "queryRequest")
@ResponsePayload
public JAXBElement<QueryResponse> query(@RequestPayload JAXBElement<QueryRequest> queryRequest) {
    System.out.println("Welcome to " + queryRequest.getRequestName());
    return new QueryResponse();
}

I had the same error, but only running my Spring Web Service integration tests.

The problem was that I setup the Jaxb2Marshaller with a different configuration if compared with Jaxb2Marshaller inside the test. I was not using the same Bean for the application and test.

My Jaxb2Marshaller with the application running is:

private Jaxb2Marshaller marshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setContextPath("com.company.application");
    marshaller.setMtomEnabled(true);
    return marshaller;
}

But on my tests, I was using:

@Before
public void init() throws Exception {
    marshaller.setPackagesToScan(ClassUtils.getPackageName(Order.class));
    marshaller.afterPropertiesSet();
}

To make the test work, I just defined the two missing properties:

@Before
public void init() throws Exception {
    marshaller.setPackagesToScan(ClassUtils.getPackageName(Order.class));
    marshaller.afterPropertiesSet();
    marshaller.setContextPath("com.company.application");
    marshaller.setMtomEnabled(true);
}

This method works when called from SOAPUI:

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getOrderDetail")
public @ResponsePayload JAXBElement<OrderDetailResponse> getOrderDetail(@RequestPayload JAXBElement<String> customerId, @RequestPayload JAXBElement<String> promoCode)

In the method below, the values inside the customerStatusRequest are coming in null even though from SOAPUI I am populating them.

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCustomerStatus")
public @ResponsePayload
JAXBElement<CustomerStatusResponse> getCustomerStatus(@RequestPayload JAXBElement<CustomerStatusRequest> customerStatusRequest)

(CustomerStatusRequest implements Serializable)

It appears String parameter values are making it through the call. But not a custom class. I annotated the CustomerStatusRequest class in this manner:

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CustomerStatusRequest", propOrder = {
    "customerId",
    "gender",
    "dob",
    "lastName",
    "sourceSystemId"
},namespace="http://www.mycompany.com/webservices")

and also each field in the CustomerStatusRequest this way:

@XmlElement(name = "customerId", required = true, nillable = true)

The method is called but the values for customerId, etc... are still coming in as null. Are additional annotations needed for a custom class?

--Thanks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!