Using an axis client to call fedora modifyDatastreamByValue method
Below is code that modifies a fedora data stream using an axis client.
I had an error message like:
SAXException: Found character data inside an array element while deserializing I did some looking around and found out that the line:
call.setOperationStyle(org.apache.axis.constants.Style.WRAPPED);
had to be inserted (see http://www.opensubscriber.com/message/axis-user@ws.apache.org/1855611.html and thanks Anne)
I had an error message like:
SAXException: Found character data inside an array element while deserializing I did some looking around and found out that the line:
call.setOperationStyle(org.apache.axis.constants.Style.WRAPPED);
had to be inserted (see http://www.opensubscriber.com/message/axis-user@ws.apache.org/1855611.html and thanks Anne)
public void insertSequenceData(String NewXMl, String PID, String LogMessage) throws Exception {
byte[] normalarr = NewXMl.getBytes("UTF-8");
String[] altIds = new String[1];
altIds[0] = "";
// Use an axis client to call the Fedora webserver
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName(APIM_NS, "modifyDatastreamByValue") );
call.setTargetEndpointAddress( new URL(URL_API_M));
call.setUsername(fedoraUser);
call.setPassword(fedoraPswd);
// if the WRAPPED stlye is not used you get the evil error:
// SAXException: Found character data inside an array element while deserializing
// see
// http://www.opensubscriber.com/message/axis-user@ws.apache.org/1855611.html
// for the solution.
call.setOperationStyle(org.apache.axis.constants.Style.WRAPPED);
Object[] obj_arr = new Object[] {
PID, // The PID of the object.
"STRUCT", // The datastream ID.
altIds, // Alternate identifiers for the datastream, if any.
"METS StructMap for this object", // The label for the datastream.
"text/xml", // The mime type.
"", // Optional format URI of the datastream.
normalarr, // The content of the datastream.
null, // The algorithm used to compute the checksum. One of "DEFAULT", "DISABLED", "MD5", "SHA-1", "SHA-256", "SHA-385", "SHA-512".
null, // The value of the checksum represented as a hexadecimal string.
LogMessage, // A log message.
false // Force the update even if it would break a data contract.
};
call.invoke( obj_arr);
}