Stephen,

        I did what you suggested using the location attribute and it worked 
like a charm.  Thank you very much.  But now I have another issue.... The 
response coming back from the server can be like the one I previously sketched 
out, or it could be a fault, like the one sketched below:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";>
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<faultcode xmlns="http://psfttemp.org";>200</faultcode>
<faultstring>Component Interface API.</faultstring>
<runcode>0</runcode>
<detail>
<keyinformation>
<CASE_ID>4639495</CASE_ID>
</keyinformation>
<messages>
<type>Error</type>
<messagesetnumber>91</messagesetnumber>
<messagenumber>50</messagenumber>
<messagetext>No rows exist for the specified keys.  {RC_CASE_SW_CI} 
(91,50)</messagetext>
<explaintext>No rows already exist in the database with the specified 
keys.</explaintext>
</messages>
<messages>
<type>Error</type>
<messagesetnumber>91</messagesetnumber>
<messagenumber>59</messagenumber>
<messagetext>Failed to get the Component Interface.</messagetext>
</messages>
</detail>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Ideally I would like to check for a fault first, then unmarshall into the 
object.  I set up a mapping file to map to a fault object.  But I havent been 
able to get the whole chain of events to occur properely.  I tried putting the 
definitions for both the fault and the  GET__CompIntfc__RC_CASE_SW_CIResponse 
in the same mapping file.  I then tried to unmarshal the fault first and if it 
remained uninitialized the marshal the other response.  My mapping file looks 
like the following

<?xml version="1.0" encoding="UTF-8"?>
<mapping>
    <class name="net.usi.oasis.crm.CrmException" auto-complete="false">
         <map-to xml="Envelope"/>
         <field name="PeoplSoftErrorMsgText" type="string" required="false"
            direct="false" transient="false">
            <bind-xml name="messagetext" node="element" reference="false" 
location="Body/messages"/>
        </field>
         <field name="faultCode" type="int" required="false"
            direct="false" transient="false">
            <bind-xml name="faultcode" node="element" reference="false" 
location="Body"/>
        </field>
         <field name="faultString" type="string" required="false"
            direct="false" transient="false" get-method="getFaultString" 
set-method="setFaultString">
            <bind-xml name="faultstring" node="element" reference="false" 
location="Body"/>
        </field>
         <field name="explainText" type="string" required="false"
            direct="false" transient="false">
            <bind-xml name="explaintext" node="element" reference="false" 
location="Body/"/>
        </field>
        </class>
    <class name="net.usi.oasis.crm.Case.USiPeopleSoftCase" 
auto-complete="false">
        <description>Mapping for class 
net.usi.oasis.crm.Case.USiPeopleSoftCase</description>
        <map-to xml="Envelope"/>
        <field name="caseID" type="integer" required="true"
            direct="false" transient="false">
            <bind-xml name="CASE_ID" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="customerRoleTypeID" type="integer" required="true"
            direct="false" transient="false">
            <bind-xml name="ROLE_TYPE_ID_CUST" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="source" type="string" required="true"
            direct="false" transient="false" get-method="getSourceText" 
set-method="setSource">
            <bind-xml name="RC_SOURCE" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="contactRoleTypeID" type="integer" required="true"
            direct="false" transient="false">
            <bind-xml name="ROLE_TYPE_ID_CNTCT" node="element" 
reference="false" location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="status" type="string" required="false"
            direct="false" transient="false" get-method="getStatusText" 
set-method="setStatus">
            <bind-xml name="RC_STATUS" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="severity" type="integer" required="true"
            direct="false" transient="false">
            <bind-xml name="RC_SEVERITY" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="priority" type="integer" required="false"
            direct="false" transient="false">
            <bind-xml name="RC_PRIORITY" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="customerID" type="string" required="true"
            direct="false" transient="false">
            <bind-xml name="BO_ID_CUST" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="customerSETID" type="string" required="true"
            direct="false" transient="false">
            <bind-xml name="SETID_CUSTOMER" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="summary" type="string" required="true"
            direct="false" transient="false">
            <bind-xml name="RC_SUMMARY" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="errorCode" type="string" required="false"
            direct="false" transient="false">
            <bind-xml name="ERROR_CODE" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="productID" type="string" required="false"
            direct="false" transient="false">
            <bind-xml name="RC_PRODUCT_ID" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="contactID" type="string" required="true"
            direct="false" transient="false">
            <bind-xml name="BO_ID_CONTACT" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="businessUnit" type="string" required="true"
            direct="false" transient="false">
            <bind-xml name="BUSINESS_UNIT" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="errorMessage" type="string" required="false"
            direct="false" transient="false">
            <bind-xml name="ERROR_MESSAGE" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
        <field name="assignedTo" type="string" required="false"
            direct="false" transient="false" get-method="getAssignee" 
set-method="setAssignee">
            <bind-xml name="ASSIGNED_TO" node="element" reference="false" 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse"/>
        </field>
    </class>
</mapping>


I'm not sure if I explained what Im trying to do well or not, hopefully I 
did.... 
My Idea was to do something like the following...

                                Mapping      mapping = new Mapping();
                
                            // 1. Load the mapping information from the file
                            mapping.loadMapping( 
"C:/development/java/USiMaven/ps_case/src/main/java/net/usi/oasis/crm/USiPeopleSoftMap.xml"
 );
        
                            // 2. Unmarshal the data
                            Unmarshaller unmar = new Unmarshaller(mapping);
                            unmar.setIgnoreExtraElements(true);
                            unmar.setIgnoreExtraAttributes(true);
                            CrmException  _crme = new CrmException();
                            StringReader myExceptionReader = new 
StringReader(document.asXML());                
                            _crme = 
(CrmException)unmar.unmarshal(myExceptionReader);
                            if (_crme.getFaultCode() != 0)
                            {
                                
System.out.println(_crme.getFaultCode()+_crme.getFaultString());
                                throw _crme;
                            }
                            StringReader myReader = new 
StringReader(document.asXML());         
                            retCase = (IntCase)unmar.unmarshal(myReader);


Your help is greatly appreciated....

-- Jay



-----Original Message-----
From: Stephen Bash [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 25, 2006 11:21 AM
To: [email protected]
Subject: Re: [castor-user] FW: problem unmarshaling data

Jay-

That sounds like you've got your work cut out for you.  A few caveats before we 
go much further.  I'm not sure how the various namespaces are going to interact 
(do you have namespace processing turned on?  do you have validation turned 
on?).  And I'm not sure how dynamic some of those element names are...  Will 
GET__CompIntfc__RC_CASE_SW_CIResponse ever change?

If we can get past those issues, here's what I would do:  In the mapping file, 
I would declare USiPeopleSoftCase to map-to Envelope (or the namespace 
qualified version, I'm not sure which would work).  Then, in the bind-xml 
elements, I would add the attribute 
location="Body/GET__CompIntfc__RC_CASE_SW_CIResponse".  That way Castor will 
create a USiPeopleSoftCase object when it sees the Envelope root element, and 
it will look within the nested elements for the fields.

The SOAP format is a little uglier than anything I've dealt with myself, but I 
have played games similar to this before.  Good luck, and let us know how it 
goes.

Stephen


Stuart, Jay Cameron wrote:
> Unfortunately I cannot use axis to handle the soap interaction because the 
> geniuses at PeopleSoft set the method to have approximately 300 parameters.  
> It seems Java has a limit on method parameters of about 250 (what were they 
> thinking :) ) This being the case I had to code the Soap interactions 
> manually.  That being said I wanted to create an object based on the 
> GET__CompIntfc__RC_CASE_SW_CIResponse node but it(castor) wanted me to use 
> the root element.  From what Stephen was saying, I guess I can map my class 
> to the root element and then somhow go the two levels down 
> (body->GET__CompIntfc__RC_CASE_SW_CIResponse)  to get the elements I need?  
> The work around I used so far was to use dom4j and extract the node I needed 
> then pipe that into castor.  If I can eliminate that extra step, that would 
> be ideal.
> 
> -- Jay
> 
> -----Original Message-----
> From: Werner Guttmann [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 25, 2006 9:12 AM
> To: [email protected]
> Subject: RE: [castor-user] FW: problem unmarshaling data
> 
> Stephen et alias,
> 
> I am still puzzled as to why Stuart has a requirement to unmarshal the 
> complete SOAP message envelop. Afair, Castor can be quite tightly integrated 
> with Axis in the way that Castor will be used as (De)Serializer from within 
> Axis. In this context, Axis will be taking care of handling with the SOAP 
> artefacts, whereas Castor's responsibility will be to deal with 
> (de)serializing (akak (un)marshalling)) the SOAP payload.
> 
> Just my 0.02 cents
> Werner
> 
> 
>>-----Original Message-----
>>From: Stephen Bash [mailto:[EMAIL PROTECTED]
>>Sent: Mittwoch, 25. Jänner 2006 15:05
>>To: [email protected]
>>Subject: Re: [castor-user] FW: problem unmarshaling data
>>
>>Jay-
>>
>>Without running your example and doing some debugging, I'm not certain 
>>what the problem is, but I'll take a guess...  I don't think Castor 
>>can ignore the root element.  Looking at your example, if you were 
>>able to create some sort of mapping for the root element (Envelope I 
>>guess), and then use location attributes to specify where the fields 
>>you are interested reside, you can probably get Castor to unmarshal 
>>this example.  Since the two fields you are interested in reside in 
>>the USiPeopleSoftCase class (while it wouldn't make a lot of sense to 
>>someone reading the mapping file) you could make things work by 
>>mapping that class to Envelope.
>>
>>Hope the gets you somewhere at least close to the right track...
>>
>>Stephen
>>
>>
>>Stuart, Jay Cameron wrote:
>>
>>>I am having an issue trying to unmarshal some SOAP data from an XML 
>>>file.  So far I have created a mapping file and I have set the 
>>>setIgnoreExtraElements to true.  I am getting the following error:
>>>"The class for the root element 'Envelope' could not be found."
>>> 
>>>Here is the xml:
>>> 
>>><?xml version="1.0"?>
>>><SOAP-ENV:Envelope
>>>xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; 
>>>xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
>>><SOAP-ENV:Header/>
>>><SOAP-ENV:Body>
>>><GET__CompIntfc__RC_CASE_SW_CIResponse xmlns="http://psfttemp.org";> 
>>><MARKET_0>GBL</MARKET_0> <EXTENSION/>
>>
>><RC_BU_DESCR>Enterprise Resource
>>
>>>Planning</RC_BU_DESCR> <BO_ID>100063040</BO_ID> 
>>><ROLE_TYPE_ID>8</ROLE_TYPE_ID> 
>>></GET__CompIntfc__RC_CASE_SW_CIResponse>
>>></SOAP-ENV:Body>
>>></SOAP-ENV:Envelope>
>>> 
>>> 
>>>My mapping file looks like:
>>> 
>>><?xml version="1.0" encoding="UTF-8"?> <mapping>
>>>    <class name="net.usi.oasis.crm.Case.USiPeopleSoftCase" 
>>>auto-complete="true">
>>>        <description>Default mapping for class 
>>>net.usi.oasis.crm.Case.USiPeopleSoftCase</description>
>>>        <map-to xml="USiPeopleSoftCase"/>
>>>        <field name="caseID" type="integer" required="true"
>>>            direct="false" transient="false">
>>>            <bind-xml name="BO_ID" node="element" 
>>
>>reference="false"/>
>>
>>>        </field>
>>>        <field name="customerRoleTypeID" type="integer" 
>>
>>required="true"
>>
>>>            direct="false" transient="false">
>>>            <bind-xml name="ROLE_TYPE_ID" node="element" 
>>
>>reference="false"/>
>>
>>>        </field>
>>>    </class>
>>></mapping>
>>> 
>>>and my code is as follows:
>>> 
>>>              mapping.loadMapping(
>>>
>>
>>"C:/development/java/USiMaven/ps_case/src/main/java/net/usi/oa
>>sis/crm/USiPeopleSoftMap.xml" 
>>
>>>);
>>> 
>>>              Unmarshaller unmar = new Unmarshaller(mapping);
>>>              unmar.setIgnoreExtraElements(true);
>>>              unmar.setValidation(false);
>>>              retCase = (IntCase)unmar.unmarshal(new 
>>>InputSource(element.asXML())); I am not sure why I am getting this 
>>>error.  Any help would be greatly appreciated....
>>> 
>>>Jay Stuart
>>>
>>>
>>
>>-------------------------------------------------
>>If you wish to unsubscribe from this list, please send an empty 
>>message to the following address:
>>
>>[EMAIL PROTECTED]
>>-------------------------------------------------
>>
>>
>>
> 
> 
> -------------------------------------------------
> If you wish to unsubscribe from this list, please send an empty message to 
> the following address:
> 
> [EMAIL PROTECTED]
> -------------------------------------------------
> 
> 
> -------------------------------------------------
> If you wish to unsubscribe from this list, please send an empty 
> message to the following address:
> 
> [EMAIL PROTECTED]
> -------------------------------------------------
> 
> 

-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the 
following address:

[EMAIL PROTECTED]
-------------------------------------------------


-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to