Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: 1.2
-
Component/s: XML code generator
-
Labels:None
-
Number of attachments :
Description
Hi,
This in continuation to my previous question.
The reason to use mapping file is : Without mapping file , marshalling works but not unmarshalling. While unmarshalling, it searches for the corresponding class for root of the xml. If mapping file is not provided it raises an exception.
The exception raised is on the server side is:
Caused by: org.xml.sax.SAXException: The class for the root element 'EmployeeRequest' could not be found.
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.
java:1527)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.
java:1430)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.
java:246)
at org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.
java:183)
at org.exolab.castor.xml.util.DOMEventProducer.start(DOMEventProducer.ja
va:111)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:617)
I am using spring webservices. Initially i have generated classes and class descriptors for the xsd. Next i have marshalled the object and send it to server by using webservicetemplate.
EmployeeResponse response = (EmployeeResponse) webServiceTemplate
.marshalSendAndReceive(employeeRequest);
Whereas in config.xml file the configurations are: (Client side configurations)
<bean id="webServiceTemplate"
class="org.springframework.ws.client.core.WebServiceTemplate">
<property name="messageFactory" ref="messageFactory" />
<property name="defaultUri"
value="http://localhost:8080/empService/" />
<property name="messageSender" ref="urlMessageSender" />
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
</bean>
<bean id="marshaller" class="org.springframework.oxm.castor.CastorMarshaller"/>
Whereas in service -config.xml file the configurations are: (Service side configurations)
<bean id="saveEmpEndpoint"
class="com.hr.ws.SaveEmpEndpoint">
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
<property name="saveEmpService" ref="saveEmpService" />
</bean>
<bean id="marshaller"
class="org.springframework.oxm.castor.CastorMarshaller">
</bean>
My SaveEmpEndpoint class extends AbstractMarshallingPayloadEndpoint
I am attaching xsd for your reference.
Thanks in advance.
Activity
| Field | Original Value | New Value |
|---|---|---|
| Component/s | XML code generator [ 11761 ] |
| Resolution | Won't Fix [ 2 ] | |
| Fix Version/s | 1.2 [ 13559 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Hi, looking at the exception in detail, it looks like the Java class for 'EmployeeRequest' is not on your classpath, and thus cannot be found at unmarshalling. Make sure that the classes as generated by the XML code generator (Java classes and descriptor classes) are packaged with your server side application. Then - and only then - will Castor be able to find the class(es) required during unmarshalling.
In other words, you will never need a mapping file in this scenario, where you started from an XML schema and generated classes for it.