I need to get list of all the workflows using a custom activity.

I visited a workflow using designer and have the name of the activity.

I just need to read that xoml file and see whether that file contains the name of the custom activity or not.

I am able to get the workflow associations for the lists but do not know how to read the xoml file.

PS: SoapXML property of workflowassociation is not giving me the desired result.

  • 1
    So what result does SoapXml give then? Is it empty or missing some elements? Commented Sep 6, 2014 at 12:02

1 Answer 1


You can try following code:

public static string 
  GetXOMLFromWorkflowInstance(SPListItem item, Guid wfInstanceId)
    SPWorkflow wf = new SPWorkflow(item, wfInstanceId);
    SPWorkflowAssociation assoc = 

    XmlDocument doc = new XmlDocument();
    doc.Load(new StringReader(assoc.SoapXml));

    XmlNode node = doc.SelectSingleNode("/WorkflowTemplate");
    XmlAttribute attribute = node.Attributes["Name"];
    string wfName = attribute.Value.Replace(" ", "%20");            
    string webRelativeFolder = "Workflows/" + wfName;            
    string xomlFileName = wfName + ".xoml";

    SPFolder wfFolder = assoc.ParentWeb.GetFolder(webRelativeFolder);
    SPFile xomlFile = wfFolder.Files[xomlFileName];

    doc = new XmlDocument();
    using (Stream xomlStream = xomlFile.OpenBinaryStream())
    return doc.OuterXml;



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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