Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

c# - GetRepositories(parameters) throws CmisRuntimeException

Hi Everyone,

I'm currently trying to Connect to Alfresco (DMS), using DotCMIS/C#, so that I can create/locate/retrieve/archive files from it through my program.

Reference: https://chemistry.apache.org/dotnet/getting-started-with-dotcmis.html

Note: I tried different "AtomPubUrl" to test which URL might work.

[CMIS v1.0]
For Alfresco Version 3.x: http://[host]:[port]/alfresco/service/cmis
For Alfresco 4.0.x and Alfresco 4.1.x : http://[host]:[port]/alfresco/cmisatom
For Alfresco 4.2: http://[host]:[port]/alfresco/api/-default-/public/cmis/versions/1.0/atom

[CMIS v1.1]
For Alfresco 4.2: http://[host]:[port]/alfresco/api/-default-/public/cmis/versions/1.1/atom

Here's my code:

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;

//parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:8080/alfresco/service/cmis";
//Throws: "Not Found

//parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:8080/alfresco/cmisatom";
//Throws: "Unauthorized

//parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom";
//Throws: "Unauthorized

//parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom";
//Throws: "Unauthorized

parameters[DotCMIS.SessionParameter.User] = "admin ";
parameters[DotCMIS.SessionParameter.Password] = "admin";
SessionFactory factory = SessionFactory.NewInstance();
ISession session = factory.GetRepositories(parameters)[0].CreateSession();

Before, I encountered an exception CmisRuntimeException - "SendFailure", but now it changes into "Not Found"/"Unauthorized".

Can somebody explain me why am I encountering these errors? or What is wrong with my code?

Thanks in advance!

Best Regards!

Have a nice day.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Promoting a comment to an answer

You need to use the correct CMIS Service URL for the version of Alfresco you are running. Trying to use the 3.x URL on a 5.x server isn't likely to work. You can find the CMIS service URL for a given version in that version's documentation, or you can get an overview of all the URLs from the Alfresco Wiki

Secondly, you'll need to be authenticating to the CMIS server. You don't have to use admin, but you do need to use valid credentials

Assuming you have a 4.2 server, with an administrator account called admin and a password of admin, you would want something like

parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom";
parameters[DotCMIS.SessionParameter.User] = "admin ";
parameters[DotCMIS.SessionParameter.Password] = "admin";
SessionFactory factory = SessionFactory.NewInstance();
ISession session = factory.GetRepositories(parameters)[0].CreateSession();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...