Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have this code in the call external method.

private void callExternalMethodActivity1_MethodInvoking(object sender, EventArgs e)

{

callExternalMethodActivitysitename = twInfo.Code;

callExternalMethodActivityurl = workflowProperties.WebUrl;

}

AND the method in the pluggable workflow service has:

public void CreateTrainingSite(string sitename, string url) { //CODE HERE }

When I step into the first method the properties are filled, however when I step into the second method the variables are null.

Please help


Edited:

namespace TrainingApprovalSiteWorkflow {

[ExternalDataExchange]
public interface ITrainingSiteCreationService
{
    event EventHandler<CommunicationObjArgs> MessageIn;
    void CreateTrainingSite(string sitename, string url);
}

[Serializable]
public class CommunicationObjArgs : ExternalDataEventArgs
{
    public CommunicationObjArgs(Guid id) : base(id) { }
    public string webID;
}

class StateObject
{
    public SPWeb web;
    public Guid instanceId;
    public StateObject(Guid instanceId, SPWeb web)
    {
        this.instanceId = instanceId;
        this.web = web;
    }
}

class TrainingSiteCreationService : SPWorkflowExternalDataExchangeService, ITrainingSiteCreationService
{
    public event EventHandler<CommunicationObjArgs> MessageIn;

    public void CreateTrainingSite(string sitename, string url)
    {
        ThreadPool.QueueUserWorkItem(delegate(object state)
        {
            StateObject sObject = state as StateObject;
            string webID = string.Empty;
            using (SPSite siteCollection = new SPSite(url))
            {
                using (SPWeb web = siteCollection.OpenWeb())
                {
                    using (SPWeb trainingWeb = web.Webs.Add(sitename))
                    {
                        trainingWeb.Description = "This site is created by a pluggable workflow service.";
                        trainingWeb.Title = sitename;
                        trainingWeb.Update();
                        webID = trainingWeb.ID.ToString();
                    }

                }
            }
            RaiseEvent(sObject.web, sObject.instanceId,
                typeof(ITrainingSiteCreationService),
                "MessageIn", new object[] { webID });
        }, new StateObject(WorkflowEnvironment.WorkflowInstanceId,
            this.CurrentWorkflow.ParentWeb));
    }

    public override void  CallEventHandler(Type eventType, string eventName, object[] eventData, SPWorkflow workflow, string identity, IPendingWork workHandler, object workItem)
    {
        var msg = new CommunicationObjArgs(workflow.InstanceId);
        msg.webID = eventData[0].ToString();
        msg.WorkHandler = workHandler;
        msg.WorkItem = workItem;
        msg.Identity = identity;
        this.MessageIn(null, msg);
    }

    public override void CreateSubscription(MessageEventSubscription subscription)
    {
        throw new NotImplementedException();
    }

    public override void DeleteSubscription(Guid subscriptionId)
    {
        throw new NotImplementedException();
    }
}

}

share|improve this question

2 Answers 2

I would suggest you to create a custom business object which has these two properties. Further you need to make this object serializable and use this object to communicate with the method in your workflow service.

I did something like this yestarday and it works like a charm when you need to supply multiple parameters to your WF service.

share|improve this answer
    
I already have that done –  Luis Valencia Sep 6 '10 at 16:35
    
and it doesnt work! –  Luis Valencia Sep 7 '10 at 0:52
    
Can you share Interface declaration and eventargs declaration.. –  Vivek Sep 7 '10 at 2:38
    
Just did on the main question, please check. –  Luis Valencia Sep 8 '10 at 3:29
    
The above code looks perfect.. strange why it is not working. –  Vivek Sep 8 '10 at 7:11
up vote 0 down vote accepted

I was able to find the problem.

On the onworkflow activated Invoking method I was setting another fields,

and no these

callExternalMethodActivitysitename = twInfo.Code;

callExternalMethodActivityurl = workflowProperties.WebUrl;

so, when it gets to the call external method, they were blank, too obvius after looking it very detailed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.