cancel
Showing results for 
Search instead for 
Did you mean: 

Visual Studio - CMIS - Autentication

bedhead
Champ in-the-making
Champ in-the-making
Hello

I have got a problem by trying out the CMIS interface. I'd like to develop an application in visual studio, which is using the CMIS Web services.

Binding the Web services into the project has been no problem. Also creating an instance of this webservices was very easy.

I got the problem when i was trieing out methods of the webservice.
For example when i trie to call the "getRepositories" method:


   RepositoryService.RepositoryService repositoryService = null;
   repositoryService = new AlfrescoWebCMISTest.RepositoryService.RepositoryService();

   AlfrescoWebCMISTest.RepositoryService.cmisExtensionType cmisExtType = new AlfrescoWebCMISTest.RepositoryService.cmisExtensionType();
   cmisRepositoryEntryType[] reps = repositoryService.getRepositories(cmisExtType);

I got the following exception:

System.Web.Services.Protocols.SoapHeaderException: An error was discovered processing the <wsse:Security> header
   bei System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   bei System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   bei AlfrescoWebCMISTest.RepositoryService.RepositoryService.getRepositories(cmisExtensionType extension) in C:\workspace\trunk\components\CMIS\AlfrescoWebCMISTest\AlfrescoWebCMISTest\Web References\RepositoryService\Reference.cs:Zeile 102.
   bei AlfrescoWebCMISTest.Form1.TestRepositoryService() in C:\workspace\trunk\components\CMIS\AlfrescoWebCMISTest\AlfrescoWebCMISTest\Form1.cs:Zeile 51.

I expect that there is anywhery a need to autenticate. I was trieing an authentication with the network credentials, but this doesnt work.
Has anybody expierence with using the CMIS services in VisualStudio? Sample code would be very helpful.
1 REPLY 1

bedhead
Champ in-the-making
Champ in-the-making
I have found a solution

*1. At first i have to download the "Microsoft WSE 3.0.msi" to get the "Microsoft.Web.Service3.dll".

*2. Edit the Proxyclass for the inbound WebService

Just the definition of the class has to be modified, so that it is derived from another class.
The class has to derive from "Microsoft.Web.Services3.WebServicesClientProtocol " and not from "System.Web.Services.Protocols.SoapHttpClientProtocol "

from:
public partial class RepositoryService : System.Web.Services.Protocols.SoapHttpClientProtocoll 
to:
 
public partial class RepositoryService : Microsoft.Web.Services3.WebServicesClientProtocol 

*3. Add the security header to the Web Service:

            localhost.RepositoryService rs = new Alfresco.localhost.RepositoryService();
            addSecurityHeaderCmis(rs);

        private static void addSecurityHeaderCmis(Microsoft.Web.Services3.WebServicesClientProtocol service)
        {
            UsernameToken userToken = new UsernameToken("admin","admin", (PasswordOption)2);
            service.RequestSoapContext.Security.Timestamp.TtlInSeconds = (long)300;
            service.RequestSoapContext.Security.Tokens.Add(userToken);
        }


That's it, now the webmethods of the service works!  Smiley Very Happy  Smiley Very Happy

Now i'm able to consume the CMIS WebServices with Visual Studio 2005.