Search code examples
javaweb-servicesunicodealfresco

Java, Alfresco Web Service API and Unicode NamedValues


I'm using Java for accessing Alfresco content server via it's web service API for importing some content into it. Content should have some NamedValue properties set to UTF-8(cyrillic) string. I keep getting the Sax parser exception:

org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x1b) was found in the element content of the document.

The code looks something like this:

NamedValue[] namedValueProperties = new NamedValue[2];

namedValueProperties[0] = Utils.createNamedValue(Constants.PROP_NAME, name );
namedValueProperties[1] = Utils.createNamedValue("{my.custom.model}myProperty", cyrillicString);

CMLCreate create = new CMLCreate("1", parentReference, null, null, null, documentType, namedValueProperties);
CML cml = new CML();
cml.setCreate(new CMLCreate[]{create});
UpdateResult[] results = null;

try {
   results = WebServiceFactory.getRepositoryService().update(cml);
} catch (...)
    Here comes the "org.xml.sax.SAXParseException"
} 

Does anyone know how to solve this problem?


Solution

  • The problem was that alfresco-web-service-client.jar library I used was from 2.9B distribution (I am hitting 2.9B community content server), and dependency libs bcprov-jdk15-136.jar and xmlsec-1.4.0.jar were not adequate (remained old from 2.1 verison). I should have used bcprov-jdk15-137.jar and xmlsec-1.4.1.jar which are deployed along with 2.9B distribution.