Hello Mike,
The problem is that when I try process it on the server side as a Resource the
entity.getText() returns NULL.
you can only only get or write the entity's content once. The reason is
that this representation is read from a socket which can only be read once.
However, you can store it in a String, then log the string, create your
StringReader, etc:
@Override
public void acceptRepresentation(Representation entity)
throws ResourceException {
try {
String entityText = entity.getText();
StringReader reader = new StringReader(entityText);
Logger.getLogger(AugmentedTypesResource.class).debug(entityText);
Could you tell us what happens?
best regards,
Thierry Boileau
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!