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

前端 未结 8 1064
遥遥无期
遥遥无期 2021-02-05 07:45

I am struggling with an Spring-WS with JMS example. I set the Spring-WS and JMS wiring as per the Spring recommendations. But I kept getting following error. I dont know how to

相关标签:
8条回答
  • 2021-02-05 08:06

    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);
    }
    
    0 讨论(0)
  • 2021-02-05 08:15

    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.

    0 讨论(0)
提交回复
热议问题