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.
I have been trying to solve this problem, but I cannot find out what I am doing wrong.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)
Below are config and code examples I use:
servlet-ws-servlet.xml
ArtistEndpointCode:<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>
artist.xsdCode:@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()); } }
my test clientCode:<?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>
testclient applicationcontext.xmlCode: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(); } }
I hope someone can point out what is not right in this code.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>
Kind regards,
Marc
wowww.nl


Reply With Quote
