Announcement Announcement Module
Collapse
No announcement yet.
No Adapter for endpoint problem. Need some insights Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No Adapter for endpoint problem. Need some insights

    Hi,

    I am trying to code a webservice using the annotations instead of xml. I had a similarversion using xml.
    Now I want to convert this to annotations. But Iam experiencing some difficulties.

    Iam getting the following error message.

    Code:
    xception in thread "main" org.springframework.ws.soap.client.SoapFaultClientException: No adapter for endpoint [public nl.wowww.top2000.model.Artist nl.wowww.top2000.service.ws.ArtistEndPoint.getArtist(java.lang.Object)]: Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?
    	at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:37)
    	at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:738)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:564)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:502)
    	at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:351)
    	at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:345)
    	at nl.ibgroep.client.spring.EchoClient.echo(EchoClient.java:28)
    	at nl.ibgroep.client.spring.EchoClient.main(EchoClient.java:36)
    I have been trying to solve this problem, but I cannot find out what I am doing wrong.
    Below are config and code examples I use:

    servlet-ws-servlet.xml
    Code:
        <bean id="marshaller" class="org.springframework.oxm.castor.CastorMarshaller">
          <property name="mappingLocation">
            <value>classpath:mapping.xml</value>
          </property>
        </bean>
    
        <bean class="org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping"/>
     
        <!--  ARTIST  -->
        <bean id="artistEndpoint" class="nl.wowww.top2000.service.ws.ArtistEndPoint">
            <property name="musicService"><ref bean="musicService"/></property>
        </bean>
    
        <bean id="artist" class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition">
            <property name="builder">
                <bean
                    class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
                    <property name="schema" value="/WEB-INF/artist.xsd"/>
                    <property name="portTypeName" value="artist"/>
                    <property name="locationUri" value="http://localhost:8080/Top2000Webservices-1.0/top2000/services"/>
                </bean>
            </property>
        </bean>
    ArtistEndpoint
    Code:
    @Endpoint
    public class ArtistEndPoint {
        
        private MusicService musicService;
    
        /**
         * @param musicService the musicService to set
         */
        public final void setMusicService(MusicService musicService) {
            this.musicService = musicService;
        }
    
        @Action("http://www.wowww.nl/top2000/artist/schemas/ArtistRequest")
        public Artist getArtist(Object requestObject) {
            ArtistRequest request = (ArtistRequest)requestObject;
            return musicService.getArtist(request.getId()); 
        }
    
    }
    artist.xsd
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified"
            targetNamespace="http://www.wowww.nl/top2000/artist/schemas"
            xmlns:tns="http://www.wowww.nl/top2000/artist/schemas">
    
        <element name="ArtistResponse">
          <complexType>
            <sequence>
              <element name="firstName" type="string"/>
              <element name="lastName" type="string"/>
              <element name="artistsName" type="string"/>
              <element name="age" type="string"/>
            </sequence>
          </complexType>
        </element>
    
        <element name="ArtistRequest">
          <complexType>
            <sequence>
              <element name="id" type="long"/>
            </sequence>
          </complexType>
        </element>
        
    </schema>
    my test client
    Code:
    import java.io.IOException;
    import java.net.URI;
    import java.net.URISyntaxException;
    
    import nl.wowww.top2000.model.Artist;
    import nl.wowww.top2000.model.ws.ArtistRequest;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
    import org.springframework.ws.soap.addressing.client.ActionCallback;
    import org.springframework.ws.soap.addressing.version.Addressing10;
    
    public class EchoClient extends WebServiceGatewaySupport {
    
        public void echo() throws IOException, URISyntaxException {
            ArtistRequest req = new ArtistRequest();
            req.setId(1);
            Artist artist = (Artist)getWebServiceTemplate().marshalSendAndReceive(req,new ActionCallback(new URI("http://www.wowww.nl/top2000/artist/schemas/ArtistRequest"),new Addressing10(),new URI("http://www.wowww.nl/top2000/artist/schemas/ArtistResponse")));
            System.out.println(artist.getArtistsName());
        }
        
        public static void main(String[] args) throws IOException, URISyntaxException {
            ApplicationContext applicationContext =
                    new ClassPathXmlApplicationContext("applicationContext.xml", EchoClient.class);
            EchoClient echoClient = (EchoClient) applicationContext.getBean("echoClient");
            echoClient.echo();
        }
    
    }
    testclient applicationcontext.xml
    Code:
        <bean id="marshaller" class="org.springframework.oxm.castor.CastorMarshaller">
          <property name="mappingLocation">
            <value>classpath:mapping.xml</value>
          </property>
        </bean>
    
        <bean id="echoClient" class="nl.ibgroep.client.spring.EchoClient">
            <property name="defaultUri" value="http://localhost:8080/Top2000Webservices-1.0/top2000/services"/>
            <property name="marshaller" ref="marshaller" />
            <property name="unmarshaller" ref="marshaller" />
        </bean>
    I hope someone can point out what is not right in this code.

    Kind regards,

    Marc
    wowww.nl

  • #2
    Problem solved adding Adapter bean

    I solved the problem. I had forgotten to add the Adapter for the castor marshalling/unmarshalling

    Code:
        <bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
          <property name="marshaller" ref="marshaller"/>
          <property name="unmarshaller" ref="marshaller"/>
        </bean>
    Above code for anyone interested in the solution.

    Kind regards,
    Marc
    wowww.nl

    Comment

    Working...
    X