Publishing workflow as an ASP.NET Web Service.


 

The workflows developed using windows workflow foundation can be published as a web service. To publish a workflow as a web service, we are provided with two activities. WebServiceInput and WebServiceOutput activity.

 

To create a workflow to be published as a web service do the following

 

Create a new Empty Workflow Project.

 

Add a new interface class to the project which would be used by our WebServiceInput activity.

 

Suppose this is our interface class.

 

interface IAddInterface

                {

        int AddNumber(int firstNumber, int secondNumber);

                }

 

Now right click on the project and add a new Sequential Workflow.

 

Now drag and drop three activities. First WebServiceInput, Code and WebServiceOutput.

 

For webServiceInputActivity1 specify following properties.

 

InterfaceType –IAddInterface.

MethodName AddNumber

 

As soon as method is added we’ll see two new properties added over there one for each parameter specified in the interface method.

i.e. firstNumber and secondNumber.

 

Create two variables to bind with them and one more variable to hold the result.

 

  public int intFirstNumber;

  public int intSecondNumber;

  public int total;

 

 

Specify intFirstNumber, intSecondNumber for firstNumber and secondNumber property of webServiceInputActivity1.

 

Finally set IsActivating as true;

 

 

Now right click code activity and select generate handlers to create a handler method and specify the following code for it

 

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

        {

            total = intFirstNumber + intSecondNumber;

        }

 

Now select webServiceOutputActivity1 and set its properties as following

 

InputActivityName = webServiceInputActivity1

 

ReturnValue = Activity=AddWebServiceWorkflow, Path=total (i.e. to total variable)

 

That’s it now we want to publish it as workflow.

 

For this right click the project and Select Publish as a web servcie option.

 

 

This would create a new webservice which would be named as worklflowProjectName.worfklowMethodName_WebService.asmx.

 

Now we could use it just like any other web service created using ASP.NET.

 

WebServiceInputActivity recieves input from the client using the webservice. It can be  associated with single web service method defined inside the interface. The WebServiceInputActivity can be followed by the set of activities which could be built in or custom activity. If the response has to sent back to the calling client than we need to make use of WebServiceOutputActivity.

Failed on Start (retrying) or Correlation Token in SharePoint Workflow


This error occurs mostly when the Correlation Token values has been not set properly for activities.

Correlation token– A correlation token is essentially a means of uniquely identifying each instance of a workflow, modification or task.

OnWorkflowActivated, OnWorkflowItemChanged,OnWorkflowItemDeleted, SetState, SendEmail and UpdateAllTasks these activities should be using same workflow token for e.g. workflowToken.

CreateTask, CreateTaskWithContentType,UpdateTask, DeleteTask, CompleteTask,RollbackTask, OnTaskChanged, OnTaskDeleted, OnTaskCreated these activites should be using same correlation token for e.g. taskToken.

EnableWorkflowModification, OnWorkflowModified should be sharing same correlation token for e.g. modificationToken.

Each distinct task or modification would be having it own distinct token.

SharePoint Designer Workflow not updating issue


I have developed certain workflows using SharePoint designer, everything was working fine. Than suddenly an issue started to show up i.e whenever i was making a modification in the workflow it was not getting reflected back on the site, until i found the solution for it.

http://b3no.wordpress.com/2008/09/09/workflow-not-updating-using-sharepoint-designer/

http://blogs.msdn.com/sharepointdesigner/archive/2007/03/27/tip-clearing-the-spd-workflow-assembly-cache.aspx

Bye…

Error: The form has been closed. This form cannot be opened. It is not workflow enabled. The specified form cannot be found when using InfoPath form in SharePoint Workflow.


These errors occur if the InfoPath form haven’t been published properly.

Always make sure that you have followed the below steps mentioned in the document while publishing the InfoPath form within SharePoint workflow

 https://nishantrana.me/wp-content/uploads/2009/02/errorininfopathform.doc

Bye…

 

The form template is trying to access files and settings on your computer. InfoPath cannot grant access to these files and settings because the form template is not fully trusted. For a form to run with full trust, it must be installed or digitally signed with a certificate.


It may be because the security level would be set as Full Trust, which requires the form to be digitally signed. Change the security level to Domain.

Go To Tools àForm Option àSecurity and Trust to change the security level.

Bye..

Read only field in SharePoint EditForm.aspx


Using JavaScript

First find out the tag corresponding to the input field which would like to set as read only

For this open up the editform.aspx page right click it and select view source

Say this is the tag of the input field

<input name=”TextField” type=”text” value=”Approved” maxlength=”255″ id=”4_ctl00_ctl00_TextField” title=”Status of Idea” class=”ms-long” />

Now open your editform.aspx page in SharePoint designer and add the following script to it

<script type=”text/javascript”>

function SetReadOnly()

{

// find all the elements with tag Name as INPUT

var elements=document.body.getElementsByTagName(“INPUT”);

// loop through all the elements till we find an element with type text and title as name of our field

for (index=0; index < elements.length;++index)

{

if(elements[index].type==“text”)

{

if(elements[index].title==“Status of Idea”)

{

elements[index].readOnly=true;

}

}

}

}

_spBodyOnLoadFunctionNames.push(“SetReadOnly()”);

</script>

Or

<script type=”text/javascript”>

function SetReadOnly()

{

var elements=document.getElementById(‘4_ctl00_ctl00_TextField’);

elements.readOnly=true;

}

_spBodyOnLoadFunctionNames.push(“SetReadOnly()”);

</script>

Or using event handler as mentioned over here

http://blogs.msdn.com/sowmyancs/archive/2008/03/25/creating-a-read-only-field-with-default-value-in-a-sharepoint-list.aspx

Or

Using CAML

http://forums.asp.net/t/1166224.aspx

And to hide button say OK button than

function SetHidden()
{
alert(‘Hi’);
var x=document.getElementsByTagName(“input”);
for (var i=0;i<x.length;i++)
{
if (x.item(i).type==”button”&&x.item(i).value==”OK”)
{
x.item(i).style.display = “none”
};
}
}
_spBodyOnLoadFunctionNames.push(“SetHidden()”);


Bye…