AnsweredAssumed Answered

action execute on alfresco 3.2

Question asked by malfresco on Jul 17, 2009
I try to perform an copy action calling web services from C# (.NET 2.0) application.
Alfresco version is 3.2. (tomcat bundle)

if somebody can confirm/infirm that the following code supposed to work, I'd apreciate it.
because it fails to acomplisg what I need.


using System;
using System.Text;
using DesperadosCopy.Action;


class Program
{



        static void Main(string[] args)
        {
            string userName = "vesa";
            string serverBase = "http://172.30.34.253:8080/alfresco";

            Alfresco.WebServices.Authentication.AuthenticationService aus = new Alfresco.WebServices.Authentication.AuthenticationService(serverBase);
            Alfresco.WebServices.Authentication.AuthenticationResult aur = aus.startSession(userName, userName);
            string ticket = aur.ticket;
            Microsoft.Web.Services3.Security.Tokens.UsernameToken usernameToken = new Microsoft.Web.Services3.Security.Tokens.UsernameToken(userName, ticket, (Microsoft.Web.Services3.Security.Tokens.PasswordOption)2);

            ActionService actionService = new ActionService(serverBase);
            actionService.RequestSoapContext.Security.Timestamp.TtlInSeconds = (long)300;
            actionService.RequestSoapContext.Security.Tokens.Add(usernameToken);

            //destination_________________________________________________
            //workspace://SpacesStore/5b6523c6-30b0-4814-ad00-ddd2805a5180
            //"/app:company_home/app:user_homes/sys:VESA_x0020_Home_x0020_Space/";



            NamedValue destinationNamedValue = createNamedValue(
                "destination-folder",
                "workspace://SpacesStore/998b941c-19a5-478f-94e5-956c0481ee07"
                );

            NamedValue associationTypeNamedValue = createNamedValue(
                "assoc-type",
                "{http://www.alfresco.org/model/system/1.0}node-uuid"  
                );

            NamedValue associationNameNamedValue = createNamedValue(
                "assoc-name",
                "{http://www.alfresco.org/ws/model/content/1.0}copy"
                );

            NamedValue deepNamedValue = createNamedValue(
                "deep-copy",
                "true"
                );

            NamedValue overrideNamedValue = createNamedValue(
                "overwrite-copy",
                "true"
                );

            NamedValue[] parameters = new NamedValue[] {
                destinationNamedValue,
                associationTypeNamedValue,
                associationNameNamedValue,
                deepNamedValue,
                overrideNamedValue
            };


            //source______________________________________________________
            //workspace://SpacesStore/5b6523c6-30b0-4814-ad00-ddd2805a5180
            Predicate where = new Predicate();
            Reference whereReference = new Reference();
            Store whereStore = new Store();
            whereStore.address = "SpacesStore";
            whereStore.scheme = "workspace";
            whereReference.store = whereStore;
            whereReference.uuid = "5b6523c6-30b0-4814-ad00-ddd2805a5180";

            where.Items = new Reference[] { whereReference };

            Action action = new Action();
            action.id = "1";
            action.actionName = "copy";
            action.actionReference = whereReference;

            action.parameters = parameters;

            ActionExecutionResult[] actionExecutionResult = actionService.executeActions(where, new Action[] { action });
        }
        private static NamedValue createNamedValue(string name, string value)
        {
            NamedValue namedValue = new NamedValue();
            namedValue.name = name;
            namedValue.value = value;
            namedValue.isMultiValue = false;
            return namedValue;
        }
}

this throws an exception
Microsoft.Web.Services3.ResponseProcessingException
it got an empty response from the service -The response message contains no body (is null)
{"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."}


Into the tomcat console I get several times the following:

17:47:41,581 User:vesa ERROR [apache.axis.Message] java.io.IOException:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
   {http://xml.apache.org/axis/}exceptionName:org.alfresco.repo.webservice.action.ActionFault
   {http://xml.apache.org/axis/}stackTrace:
   at org.alfresco.repo.webservice.action.ActionWebService.executeActions(ActionWebService.java:863)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
   at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:619)

   {http://xml.apache.org/axis/}hostname:alfresco32.oseleven


   at org.alfresco.repo.webservice.action.ActionWebService.executeActions(ActionWebService.java:863)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
   at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:619)


I have tried to set the destination folder like this:

            NamedValue destinationNamedValue = createNamedValue(
                "destination-folder",
                "/app:company_home/app:user_homes/sys:VESA_x0020_Home_x0020_Space/cm:_x0030_00"
                );

            NamedValue associationTypeNamedValue = createNamedValue(
                "assoc-type",
                "{http://www.alfresco.org/ws/model/content/1.0}contains"  
                );
but in this case I get
System.Web.Services.Protocols.SoapException
0Node found, //doesn't contain "/app:company_home/app:user_homes/sys:VESA_x0020_Home_x0020_Space/cm:_x0030_00




All the services classes are the classes generated by the visual studio 2008, with following addaptation:
1. each service url can be given via constructor
2. I set the super class of all services to
Microsoft.Web.Services3.WebServicesClientProtocol
instead
System.Web.Services.Protocols.SoapHttpClientProtocol
which was set by the "add webservice reference wizard" of the VS2008


both exceptions are throw on this.Invoke… in the class ActionService

public ActionExecutionResult[] executeActions(Predicate predicate, [System.Xml.Serialization.XmlElementAttribute("actions")] Action[] actions)
        {
            try
            {
                object[] results = this.Invoke("executeActions", new object[] {
                        predicate,
                        actions});
                return ((ActionExecutionResult[])(results[0]));
            }
         }

Thanks in advance,
M

Outcomes