AnsweredAssumed Answered

Wordless exception during write

Question asked by mellen on Aug 12, 2008
Latest reply on Aug 13, 2008 by mellen
Hi all. I'm trying to integrate the Alfresco web services with .NET using Visual Studio 2008

I tried the alfresco-dotNET 0.2Beta but it wouldn't compile, so I generated the C# source for the services using WSDL, and changed the object types form System.Web.Services.Protocols.SoapHttpClientProtocol to Microsoft.Web.Service3.WebServicesClientProtocol.

This works ok for authentication, but if I try and write data then I get a SOAP exception with no error message in it. Here's the code:

        AuthenticationService auth = new AuthenticationService();

        AuthenticationResult ar = auth.startSession("Mellen", "Mellen");

        ContentService cs = new ContentService();

        UsernameToken userToken = new UsernameToken(ar.username, ar.ticket, PasswordOption.SendPlainText);
        cs.RequestSoapContext.Security.Timestamp.TtlInSeconds = 300;
        cs.RequestSoapContext.Security.Tokens.Add(userToken);

        StreamReader sr = new StreamReader(Server.MapPath("web.config"));

        byte[] newContent = new byte[sr.BaseStream.Length];

        sr.BaseStream.Read(newContent, 0, (int)sr.BaseStream.Length);

        sr.Close();

        Reference refer = new Reference();
        refer.store = new Store();
        refer.store.address = "SpacesStore";
        refer.store.scheme = "workspace";

        cs.write(refer, "web.config", newContent, new ContentFormat());

        auth.endSession(ar.ticket);

The exception gets thrown on the penultimate line.

I'm really new to Alfresco, so I'm guessing it's something simple.

Any help would be gratefully appreciated.

Outcomes