Hi,
I'm trying to implement a simple WS, have followed instructions form the book and also from the springsource.
While invoking the WS as webServiceTemplate.marshalSendAndReceive following error is seen:
[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'CustomerDetailsRequest'.]
Snippet from the stacktrace:
I have seen few more posts with similar error, have tried all the suggested solutions, but none have worked, hence thought to seek help from the forum.Code:org.springframework.oxm.jaxb.JaxbMarshallingFailureException: JAXB marshalling exception: null; nested exception is javax.xml.bind.MarshalException - with linked exception: [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'CustomerDetailsRequest'.] at org.springframework.oxm.jaxb.JaxbUtils.convertJaxbException(JaxbUtils.java:72) at org.springframework.oxm.jaxb.AbstractJaxbMarshaller.convertJaxbException(AbstractJaxbMarshaller.java:143) at org.springframework.oxm.jaxb.Jaxb2Marshaller.marshal(Jaxb2Marshaller.java:383) at org.springframework.ws.support.MarshallingUtils.marshal(MarshallingUtils.java:81) at org.springframework.ws.client.core.WebServiceTemplate$2.doWithMessage(WebServiceTemplate.java:360) at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:535) 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:341) at com.h3g.midus.services.web.poc.client.CustomerDetails.getDetails(CustomerDetails.java:15) at com.h3g.midus.domain.ServiceRequest.complete(ServiceRequest.java:328) at com.h3g.midus.domain.ServiceRequest$$FastClassByCGLIB$$6eeead3d.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
I think somehow the the parser cant get hold of XSD in declared location, hence throws the exception.
The relevant code detail snippets are:
From xyz-ws-servlet.xml
1. Endpoint Mapping
2. Endpoint beanCode:<bean id="endpointMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping"> <property name="interceptors"> <list> <ref bean="loggingInterceptor"/> </list> </property> <property name="endpointMap"> <map> <entry key="{http://xyz.abc.com/poc/schemas}CustomerDetailsRequest" value-ref="customerDetailsEndpoint"/> </map> </property> </bean>
3. JaxbMarshaller bean definitionCode:<bean id="customerDetailsEndpoint" class="com.abc.xyz.services.web.poc.CustomerDetailsMarshallingEndpoint"> <property name="marshaller" ref="marshaller"/> <property name="unmarshaller" ref="marshaller"/> <property name="customerDetailsBrowser" ref="customerDetailsBrowser"></property> </bean>
4. And finally the XSDCode:<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="classesToBeBound"> <list> <value>com.abc.xyz.services.web.poc.CustomerDetailsRequest</value> <value>com.abc.xyz.services.web.poc.CustomerDetailsResponse</value> </list> </property> <property name="schemas" value="classpath:xsd/CustomerDetails.xsd"/></bean>
I have already tried all of the solutions posted on this subject, but none have worked.Code:<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xyz.abc.com/poc/schemas" xmlns="http://xyz.abc.com/poc/schemas" attributeFormDefault="qualified" elementFormDefault="qualified"> <xs:element name="CustomerDetailsRequest"> ... Few more nodes .... </xs:element> <xs:element name="CustomerDetailsResponse"> ... Few more nodes .... </xs:element> </xs:schema>
Would be a great help if anyone can suggest what may be wrong!
Thanks,


Reply With Quote
