I am trying to use XmlBeans with Restlet and am having issues. I am creating an
XmlBeans document and posting the xml document as follows:

AugmentedTypesDocument document = 
AugmentedTypesDocument.Factory.newInstance(xmlo);               
TeoTermsType saturatedTypes = document.addNewAugmentedTypes();
                        
for (String subject : subjects) {
        TeoTerm teoTerm = saturatedTypes.addNewTeoTerm();
        teoTerm.setSubject(subject);
        teoTerm.setPredicate(predicate);
        teoTerm.setRdfObject(object);
}

Representation xml = createDomRepresentation(document);
Reference ref = dataSourceUri.clone().addSegment(types);
response = client.post(ref, xml);

//  creating the DOM
public static Representation createDomRepresentation(XmlObject xmlObject) throws
IOException,
        ParserConfigurationException, SAXException {

        XmlOptions xmlo = new XmlOptions();
//              xmlo.setSavePrettyPrint();

  
Logger.getLogger(DataCharacterizationClient.class).debug(String.format("Creating
DomRepresentation using\n %s", xmlObject.xmlText(xmlo)));
                DomRepresentation representation = new 
DomRepresentation(MediaType.TEXT_XML);

                // Generate a DOM document representing the data source uris.
                DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();       
                Document doc = (Document) builder.parse(new InputSource(new
StringReader(xmlObject.xmlText(xmlo))));
                representation.setDocument(doc);

                // Returns the XML representation of this document.
                return representation;
}

The problem is that when I try process it on the server side as a Resource the
entity.getText() returns NULL.

@Override
public void acceptRepresentation(Representation entity)
                throws ResourceException {              
try {
StringReader reader = new StringReader(entity.getText());
Logger.getLogger(AugmentedTypesResource.class).debug(entity.getText());
TeoTermsType termsType = TeoTermsType.Factory.parse(reader);                    
...

It looks like the XML is being sent (looked at using TCPMon), but the Resource
doesn't receive it correctly.

Thanks in advance,
Mike

PS - Great library!

Reply via email to