AnsweredAssumed Answered

WebService, addAspect and .Net (partialy resolved)

Question asked by lascaux on Nov 27, 2006
Latest reply on Dec 11, 2006 by jtorres
Hi,

I am trying to add an aspect during the node creation in alfresco using the WebService (client program in .Net 2.0)

here is my code :

Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store();
spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace;
spacesStore.address = "SpacesStore";

Alfresco.RepositoryWebService.ParentReference parentReference = new Alfresco.RepositoryWebService.ParentReference();
parentReference.store = spacesStore;
parentReference.path = "/app:company_home/cm:test";

parentReference.associationType = Constants.ASSOC_CONTAINS;
parentReference.childName = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, fileName);

Alfresco.RepositoryWebService.NamedValue[] properties = new Alfresco.RepositoryWebService.NamedValue[] {
                createNamedValue(Constants.PROP_NAME, fileName),
                createNamedValue(Constants.PROP_TITLE, Path.GetFileNameWithoutExtension(fileName)),
                createNamedValue(Constants.PROP_DESCRIPTION, ""),
                createNamedValue("{myModel}myProperty", "1234") };

CMLCreate create = new CMLCreate();
create.id = "1";
create.parent = parentReference;
create.type = Constants.TYPE_CONTENT;
create.property = properties;

CMLAddAspect addAspect = new CMLAddAspect();
addAspect.aspect = "{myModel}myAspect";


CML cml = new CML();
cml.create = new CMLCreate[] { create };
cml.addAspect = new CMLAddAspect[] { addAspect };
UpdateResult[] result = repoService.update(cml);

I get the following Exception during the update(cml) command :

Message: "WSE910: An error happened during the processing of a response message, and you can find the error in the inner exception.  You can also find the response message in the Response property."}
System.Exception: {Microsoft.Web.Services3.ResponseProcessingException}
StackTrace:   at Microsoft.Web.Services3.Xml.SoapEnvelopeReaderWrapper..ctor(SoapClientMessage message, String messageContentType)
              at Microsoft.Web.Services3.WebServicesClientProtocol.GetReaderForMessage(SoapClientMessage message, Int32 bufferSize)
              at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
              at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
              at Alfresco.RepositoryWebService.RepositoryService.update(CML statements) in RepositoryWebService\\Reference.cs:line 355
              at Samples.Search.button2_Click(Object sender, EventArgs e) in Import.cs:line 304"  string
I also try to do the following :
1) creating the node in Alfresco (which is OK)
2) adding the aspect using the following code :

// Create the properties list
nameProperty = new NamedValue();
nameProperty.name = "{myModel}myProperty";
nameProperty.value = Path.GetFileNameWithoutExtension(fileName);
nameProperty.isMultiValue = false;

NamedValue[] myAspectProperties = new NamedValue[1];
myAspectProperties[0] = nameProperty;

CMLAddAspect addAspect = new CMLAddAspect();
addAspect.aspect = "{myModel}myAspect";
addAspect.where = documentPredicate;
addAspect.where_id = documentUUID;
addAspect.property = myAspectProperties;

CML cmlAddAspect = new CML();
cmlAddAspect.addAspect = new CMLAddAspect[] { addAspect };
UpdateResult[] result = repoService.update(cmlAddAspect);
but I get exactly the same error …

Please HELP !!!
I've got 1500 documents to load in alfresco … :

Sylvain

Outcomes