cancel
Showing results for 
Search instead for 
Did you mean: 

Using RepositoryService to upload a file in C#

uheber
Champ in-the-making
Champ in-the-making
Hello community,

currently we evalute the enterprise edition of Alfresco_3.1 as a new document management system in our company. As development environment we use Visual Studio 2008 and the web services example "dotNET" (http://forge.alfresco.com/frs/download.php/80/alfresco-dotNet-0.2Beta.zip).

After solving minor issues with calling Alfreco web services (Tutorial » http://sangosthi.blogspot.com/2009/04/calling-alfresco-web-services-from-c.html) the application can be built. But during execution the ImageUploadExample or ImageUploadExample2 we get an exception 

   on System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)   on System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)   on Alfresco.RepositoryWebService.RepositoryService.update(CML statements) in U:\InfoPath\Alfresco\alfresco-dotNet-2\Alfresco\Web References\RepositoryWebService\Reference.cs:Line 356.   on Samples.ImageUploadExample.btnUpload_Click(Object sender, EventArgs e) in U:\InfoPath\Alfresco\alfresco-dotNet-2\Samples\ImageUploadExample.cs:Line 110.‍‍‍‍
  
when the repository service is called:
  
UpdateResult[] updateResult = repoService.update(cml);‍

All other web service examples work fine.

There may be problems in use Visual Studio 2005 vs. 2008? I have read, in VS2005 will be used the WSE 3.0 (Web Services Enhancements) framework which in VS2008 is obsolete. Microsoft uses for it in VS2008 the WCF (Windows Communication Foundation) framework. Are there any problems if the application is built?

The second question is, why are the content (reference.cs) of web services are different? When I create a new class library and add a web service from WSDL (eq. http://localhost:8080/alfresco/wsdl/repository-service.wsdl), the content of this service is in the object browser different than the original from the Alfresco project example "dotNET". 

The file upload via web service is an important feature, which our prototype must be have. Is there a working example, which was developed in VS2008 and use this service?

Thank you for your help. 

Best Regards,
Uwe
1 REPLY 1

uheber
Champ in-the-making
Champ in-the-making
Hello together,

there are so few friends in the Alfresco community, which using C# in Visual Studio 2008 for custoumizing? Perhaps my question was too specific.

After a wile I find out, that may be the syntax of
parentReference.path = "/app:company_home/app:user_homes/cm:x-alfresco";‍
are a problem in the example "ImageUpload2.cs".

To save a file in the home directory of each user, now I determine the UUID of the node:
        private String getUuid(Alfresco.RepositoryWebService.Store spacesStore)        {            String uuid = "";            Alfresco.RepositoryWebService.Query query = new Alfresco.RepositoryWebService.Query();            query.language = Alfresco.RepositoryWebService.QueryLanguageEnum.lucene;            query.statement = "@cm\\:name:\"x-alfresco\"";            QueryResult result = this.repoService.query(spacesStore, query, true);            if (result.resultSet.rows != null)            {                uuid = result.resultSet.rows[0].node.id;            }            return uuid;        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
and set theses in
//  Determine the uuid of the node, where the content should be saved                parentReference.uuid = getUuid(spacesStore);‍‍

Now the rebuilt and execution of example "ImageUpload2.cs" works fine. Inportant in this context, that the content of StoreEnum in RepositoryWebService is changed! Therefore see the details under http://sangosthi.blogspot.com/2009/04/calling-alfresco-web-services-from-c.html

Best regards,
Uwe