Announcement Announcement Module
Collapse
No announcement yet.
Spring WS with using SAAJ - No adapter for endpoint error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring WS with using SAAJ - No adapter for endpoint error

    I am really struggling getting Spring-WS to return a response with attachments. I have managed to get an MTOM version to work but this has some pre-requisites on the client as i believe that the client has to be MTOM enabled as well (please correct me if this is not correct).

    What i am trying to do now is to use the standard SOAP with attachment implementation using SAAJ and Spring-WS.

    To do this i implemented an endpoint that just attaches an image from the local filesystem to the response.

    Code:
        @Endpoint
        public class TestEndPoint {
        
        private SaajSoapMessageFactory saajMessageFactory;
        
        @PayloadRoot(namespace="http://ws.mypackage.com", localPart="downloadMessageRequestSaaj")
        	@ResponsePayload
        	public JAXBElement<DownloadResponseSaajType> invoke(@RequestPayload DownloadMessageRequestSaaj req, MessageContext context ) throws Exception  {
        		
        		DownloadResponseSaajType response = new DownloadResponseSaajType();
        		DownloadResponseSaajType.PayLoad payload = new DownloadResponseSaajType.PayLoad();	
        		
        		DataHandler handler = new javax.activation.DataHandler(new FileDataSource("c:\\temp\\maven-feather.png"));
        
        	        SaajSoapMessage message = saajMessageFactory.createWebServiceMessage();
        	        message.addAttachment("picture", handler);
        
        	        context.setResponse(message);
        	        
        	        payload.setMessagePayLoad(handler);
        	        
        	        return objectFactory.createDownloadMessageResponseSaaj(response);  
        
        	}
        	
        	public void setSaajMessageFactory(SaajSoapMessageFactory saajMessageFactory){
                this.saajMessageFactory = saajMessageFactory;
            }
        
            public SaajSoapMessageFactory getSaajMessageFactory(){
                return saajMessageFactory;
            }
        }
    The Saaj properties are depency injected as shown below:

    Code:
    <context:annotation-config/>  	
      	<context:component-scan base-package="com.mypackage"/>
      	
        <sws:annotation-driven/>
        
        <bean id="soapMessageFactory" class="javax.xml.soap.MessageFactory" factory-method="newInstance" />
    	<bean id="saajMessageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
    		    <constructor-arg ref="soapMessageFactory" />
    	</bean>
    		
    	<bean id="myService" class="com.mypackage.TestEndPoint">
    	    <property name="saajMessageFactory" ref="saajMessageFactory" />
    	</bean>
    When i try to call the above service i get the following error:

    Code:
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
           <SOAP-ENV:Header/>
           <SOAP-ENV:Body>
              <SOAP-ENV:Fault>
                 <faultcode>SOAP-ENV:Server</faultcode>
                 <faultstring xml:lang="en">No adapter for endpoint [public javax.xml.bind.JAXBElement&lt;com.mypackage.ws.DownloadResponseSaajType> com.mypackage.TestEndPoint.invoke(com.mypackage.ws.DownloadMessageRequestSaaj,org.springframework.ws.context.MessageContext) throws java.lang.Exception]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring>
              </SOAP-ENV:Fault>
           </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>

  • #2
    I noticed today that i change the method signature to remove the MessageContext parameters as shown below then i dont get that error:

    Code:
    public JAXBElement<DownloadResponseSaajType> invoke(@RequestPayload DownloadMessageRequestSaaj req)
    The problem however is that i need to access the MessageContext to be able to add the attachment. Could be that maybe my configuration is wrong somewhere?

    Comment

    Working...
    X