java - Spring Web service throws com.sun.xml.internal.messaging.saaj.soap.ver1_1.BodyElement1_1Impl cannot be cast to org.jdom.Element -


i totally new spring , started self studying begining want develop spring-ws based web service. have created schemas.xsd, spring-ws-servlet.xml , web.xml files in web-inf folder. implemented endpoint annotated @endpoint. in scehmas.xsd have below element

<xsd:element name="simplerequest">         <xsd:complextype>             <xsd:sequence>                 <xsd:element name="rename" type="xsd:string" />                                    </xsd:sequence>         </xsd:complextype>     </xsd:element> 

and in web.xml specify spring-ws message dispatcher servlet below.

<servlet>         <servlet-name>spring-ws</servlet-name>         <servlet-class>org.springframework.ws.transport.http.messagedispatcherservlet</servlet-class>         <init-param>             <param-name>contextconfiglocation</param-name>             <param-value>/web-inf/spring-ws-servlet.xml</param-value>         </init-param>         <init-param>             <param-name>transformwsdllocations</param-name>             <param-value>true</param-value>         </init-param>     </servlet>      <servlet-mapping>         <servlet-name>spring-ws</servlet-name>         <url-pattern>/*</url-pattern>     </servlet-mapping> 

in spring-ws-servlet.xml define endpoint

    <context:component-scan base-package="com.test" />  <sws:annotation-driven />  <sws:dynamic-wsdl id="form" porttypename="guiform"     locationuri="/forms/">     <sws:xsd location="/web-inf/schemas.xsd" /> </sws:dynamic-wsdl>  <bean id="formsendpoint" class="com.test.formsendpoint"  />  <bean     class="org.springframework.ws.server.endpoint.mapping.payloadrootannotationmethodendpointmapping">     <property name="defaultendpoint" ref="formsendpoint" /> </bean> 

in formsendpoint class have below method,

@payloadroot(namespace = namespace_uri, localpart = "simplerequest")     @responsepayload     public element handleformsrequest(@requestpayload element simplerequest) throws  jdomexception, parserconfigurationexception             {          system.out.println("================ hit on endpoint ========================");         string formid = formidexpression.valueof(simplerequest);        } 

at line formidexpression.valueof(simplerequest); throws

java.lang.classcastexception: com.sun.xml.internal.messaging.saaj.soap.ver1_1.bodyelement1_1impl cannot cast org.jdom.element     @ org.jaxen.jdom.documentnavigator.getdocumentnode(documentnavigator.java:396)     @ org.jaxen.expr.defaultabsolutelocationpath.evaluate(defaultabsolutelocationpath.java:102)     @ org.jaxen.expr.defaultxpathexpr.aslist(defaultxpathexpr.java:102)     @ org.jaxen.basexpath.selectnodesforcontext(basexpath.java:674)     @ org.jaxen.basexpath.selectsinglenodeforcontext(basexpath.java:698)     @ org.jaxen.basexpath.stringvalueof(basexpath.java:279)     @ org.jdom.xpath.jaxenxpath.valueof(jaxenxpath.java:182)     @ com.neurotec.mmafis.formsendpoint.handleformsrequest(formsendpoint.java:53)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ org.springframework.ws.server.endpoint.methodendpoint.invoke(methodendpoint.java:134)     @ org.springframework.ws.server.endpoint.adapter.defaultmethodendpointadapter.invokeinternal(defaultmethodendpointadapter.java:240)     @ org.springframework.ws.server.endpoint.adapter.abstractmethodendpointadapter.invoke(abstractmethodendpointadapter.java:53)     @ org.springframework.ws.server.messagedispatcher.dispatch(messagedispatcher.java:233)     @ org.springframework.ws.server.messagedispatcher.receive(messagedispatcher.java:173)     @ org.springframework.ws.transport.support.webservicemessagereceiverobjectsupport.handleconnection(webservicemessagereceiverobjectsupport.java:88)     @ org.springframework.ws.transport.http.webservicemessagereceiverhandleradapter.handle(webservicemessagereceiverhandleradapter.java:59)     @ org.springframework.ws.transport.http.messagedispatcherservlet.doservice(messagedispatcherservlet.java:292)     @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:936)     @ org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:838)     @ javax.servlet.http.httpservlet.service(httpservlet.java:646)     @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:812)     @ javax.servlet.http.httpservlet.service(httpservlet.java:727)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208)     @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:220)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:122)     @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:501)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:170)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:98)     @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:950)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:116)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:408)     @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1040)     @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:607)     @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:313)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)     @ java.lang.thread.run(thread.java:744) 

i have tested request using soapui plugin in eclipse. ideas on why occurs highly appreciated.

you must first generate classes corresponding "simplerequest". can use jaxb this.

then,

public element handleformsrequest(@requestpayload element simplerequest)  

should be

public element handleformsrequest(@requestpayload **clazz** simplerequest) 

where clazz generated class


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -