I got the solution over net.Need to specify expilict namespace to the tag as
shown below in bold.
<mapping>
<class name="com.xyz.transfer.dto.response.TransferResponseDTO">
<map-to xml="Envelope"
ns-uri="http://schemas.xmlsoap.org/soap/envelope/"/>
<field name="ss" type="java.lang.String">
<bind-xml name="Std" node="element" />
</field>
<field name="cd" type="com.xyz.common.ism.response.ClientData">
<bind-xml name="soapenv:ClientData"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" node="element"/>
</field>
</class>
<class name="com.xyz.common.ism.response.ClientData">
<field name="Name" type="java.lang.String">
<bind-xml name="Name" node="element"/>
</field>
<field name="Address" type="java.lang.String">
<bind-xml name="Address" node="element"/>
</field>
</class>
</mapping>
waez wrote:
>
> Hi,
>
> I am new to Castor, trying marshalling and unmarshalling test programs, am
> getting following exception on Unmarshall. I google but this time no luck
> so thought of logging it here.
>
> Below is the mapping, XML, and java code to unmarshall.
>
> Exception
> ------------------------------------------------------------------------------------------------------
> unable to find FieldDescriptor for 'ClientData' in ClassDescriptor of
> Envelope{file: [not available]; line: 4; column: 22}
> ------------------------------------------------------------------------------------------------------
>
> Here is the XML that I am trying to unmarshall
>
> response.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Std>XYZ</soapenv:Std>
> <soapenv:ClientData>
> <Name>Jean Smith</Name>
> <Address>2000, Alameda de las Pulgas, San Mateo, CA
> 94403</Address>
> </soapenv:ClientData>
> </soapenv:Envelope>
>
> Please note that if I remove the namespace prefix i.e. 'soapenv' from the
> tag <soapenv:ClientData> making it just <ClientData> in the above
> response.xml, it unmarshalls with no issues however requirement is to
> unmarshall with namespace prefix i.e.<soapenv:ClientData>.
> The <map-to ns-uri="http://schemas.xmlsoap.org/soap/envelope/"
> ns-prefix="soapenv" /> works well in marshalling but not working in
> unmarshalling, please see the mapping file below
>
> Mapping File
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
> "http://castor.org/mapping.dtd">
> <mapping>
> <class name="com.xyz.transfer.dto.response.TransferResponseDTO">
>
> <map-to xml="Envelope"
> ns-uri="http://schemas.xmlsoap.org/soap/envelope/"
> ns-prefix="soapenv"/>
> <field name="ss" type="java.lang.String">
> <bind-xml name="Std" node="element" />
> </field>
> <field name="cd"
> type="com.xyz.common.ism.response.ClientData">
> <bind-xml name="ClientData" node="element"/>
> </field>
> </class>
> <class name="com.xyz.common.ism.response.ClientData">
> <map-to ns-uri="http://schemas.xmlsoap.org/soap/envelope/"
> ns-prefix="soapenv" />
> <field name="Name" type="java.lang.String">
> <bind-xml name="Name" node="element"/>
> </field>
> <field name="Address" type="java.lang.String">
> <bind-xml name="Address" node="element"/>
> </field>
> </class>
> </mapping>
>
> Java Code
>
> public static void main(String args[]) {
>
> Mapping mapping = new Mapping();
> try {
> // 1. Load the mapping information from the file
>
>
> mapping.loadMapping("resources\\transfer_resp_mapping.xml" );
> // 2. Unmarshal the data
> Unmarshaller unmar = new Unmarshaller
> (mapping);
>
> TransferResponseDTO dto =
> (TransferResponseDTO)
> unmar.unmarshal(new InputSource(new
> FileReader("resources\\response.xml")));
>
> System.out.println(dto.getSs());
>
> } catch (Exception e) {
> System.out.println(e);
> return;
> }
> }
> }
>
> Any help would be much appriciated.
>
> Thanks in Advance.
>
> Regards,
> Waez.
>
--
View this message in context:
http://www.nabble.com/Unmarshalling-issue-with-namespace-prefix-tp25119826p25130421.html
Sent from the Castor - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email