Hi,

  This is my first time using Castor (ver: 0.9.3.9) and SOAP.  I have some legacy Java 
classes which I'm trying to marshal to XML using Castor mapping files that I have 
created for the java classes.  The mapping file seem to work correclty when I running 
a test client that is not going thru SOAP services, the marshalling of the object is 
working correctly.  But when I tried to send request and marshal the java object that 
is returned back (thru SOAP), it seems that the marshalling is not using the mapping 
file  that I have set and load.  Below is the function I used to marshal the object 
and send the message back to the client.

public void buildResponse (
      String       inMsgName   ,
      Object       inContent   ,
      SOAPContext  outResponse ,
      Envelope     inoutEnv    )
         throws MessagingException, IOException
   {
      // Create the response.
      System.out.println("In buildResponse() ");

      Document theDoc = new DocumentImpl();
      Element theResponse =  theDoc.createElement ( inMsgName );

      String mapFile = "file:C:\\mappdir\\mapping.xml";
      
      try
      {
         Mapping map = new Mapping();
         map.loadMapping(mapFile);
         Marshaller marshaller = new Marshaller(theResponse);
         marshaller.setMapping(map);
         marshaller.marshal(inContent);
      }

      catch ( Throwable e )
      {
         sLog.error ( "error building response", e );

         buildErrorResponse (
            "ERROR_BUILDING_RESPONSE" ,  // inError
            e.getMessage()            ,  // inDescription
            outResponse               ,  // outResponse
            inoutEnv                  ); // inoutEnv

         return;
      }

      // Set this response as the content of the envelope.

      Vector theBodyEntries = inoutEnv.getBody().getBodyEntries();
      theBodyEntries.clear();
      theBodyEntries.add ( theResponse );

      StringWriter aWriter = new StringWriter();
      inoutEnv.marshall ( aWriter, null );

      // Send the envelope back to the client.
      //
      outResponse.setRootPart ( aWriter.toString(), "text/xml" );
   }


Please Help.
Thank You In Advance,
Ide

Reply via email to