locked
Cancel a .xamlx Workflow RRS feed

  • Question

  • Hello

    I have searched the chasms of the internet for an answer to this but am having no luck. I have a .xamlx workflow with a CancellationScope defined, but can't seem to touch it from my web application that references it as a Service Reference. The code I am using from my web application behind the "Cancel" button is the following:

    WorkflowControlClient controlClient = new WorkflowControlClient(new BasicHttpBinding(), new EndpointAddress(new Uri("http://xxxxx/IdentityServices/RequestWorkflow.xamlx")));
    
    controlClient.Cancel(localRequest.WorkflowInstanceId);
    
    

    This is supposedly supposed to cancel the instance, and hit whatever is in the cancellation handler. When I run this in the debugger, I get the following error:

    The message with Action 'http://schemas.datacontract.org/2008/10/WorkflowServices/IWorkflowInstanceManagement/Cancel' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

    I have checked the endpoints and made sure my Service Reference is updated on web application, so I am at a loss. Can anyone tell me the proper way to Cancel a .xamlx workflow and have it execute what is in the CancellationScope container?

    Thanks!

    Daniel

    Monday, July 12, 2010 8:38 PM

Answers

  • Thanks Andrew, I have seen that link before but it wasn't my issue.

    I finally got everything working. I am posting what I had to do here in hopes that it helps someone else in the future that encounters same problem I did.

    What I think fixed the issue was deleting my Service Reference from my Web Application, and re-adding it back using the machine name in the URL for the xamlx service instead of using the DNS alias (CNAME). For some reason, using the DNS alias caused weird behaviors with the WorkflowControlEndpoint and caused the errors I listed in this post. So changing it there as well as in the web.config for the xamlx service and the web application did the trick.

    Here is what I have in my .xamlx web.config now for reference as well. I took out my actual values and put words in (  ) for the example:

    <system.serviceModel>
     <bindings>
      <basicHttpBinding>
      <binding name="BasicHttpBinding_IRequestService" closeTimeout="00:01:00"
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
       maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
       messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
       useDefaultWebProxy="true">
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
       maxBytesPerRead="4096" maxNameTableCharCount="16384" />
       <security mode="None">
       <transport clientCredentialType="None" proxyCredentialType="None"
        realm="" />
       <message clientCredentialType="UserName" algorithmSuite="Default" />
       </security>
      </binding>
      </basicHttpBinding>
     </bindings>
     <services>
      <service behaviorConfiguration="myServiceBehavior" name="RequestService">
      <endpoint address="wce" binding="basicHttpBinding" name="wceEndpoint" kind="workflowControlEndpoint" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRequestService"
       name="BasicHttpBinding_IRequestService" contract="IRequestService" />
      <host>
       <baseAddresses>
       <add baseAddress="http://(Machine Name, Fully Qualified)/IdentityServices/Workflow.xamlx/" />
       </baseAddresses>
      </host>
      </service>
     </services>
     <behaviors>
      <endpointBehaviors>
      <behavior name="myServiceBehavior">
       <webHttp/>
      </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
      <behavior name="myServiceBehavior">
       <serviceMetadata httpGetEnabled="true"/>
       <serviceDebug includeExceptionDetailInFaults="True" />
       <sqlWorkflowInstanceStore connectionString="Data Source=(SQL Server Machine Name);Initial Catalog=(SQL Server Database Name);Integrated Security=True;Asynchronous Processing=True" />
       <workflowIdle timeToPersist="0"/>
       <etwTracking profileName="HealthMonitoring Tracking Profile"/>
      </behavior>
      </serviceBehaviors>
     </behaviors>
    

    And in the code I call the Cancel operation of the WorkflowControlEndpoint like this:

    // Create the WorkflowControlClient with the WorkflowControlEndpoint
    WorkflowControlClient controlClient = new WorkflowControlClient(new BasicHttpBinding(), new EndpointAddress(new Uri("http://(Machine Name, Fully Qualified)/IdentityServices/Workflow.xamlx/wce")));
    
    // Cancel the particular workflow
    controlClient.Cancel(WorkflowInstanceId);
    
    // Close the controlClient
    controlClient.Close();
    
    • Marked as answer by dlackey Thursday, July 22, 2010 6:33 PM
    Thursday, July 22, 2010 6:31 PM

All replies

  • Do you have a Workflow Management Endpoint configured on your service? It listens on a differend endpoint than the service that you define, so you need to address control messages to a different URI.

    Check out the sample at http://msdn.microsoft.com/en-us/library/dd807500.aspx

    Wednesday, July 14, 2010 12:45 AM
  • Hi Dan,

    Thanks for the response. I've been looking at this and can't quite figure out what I am doing wrong. I tried to create a Workflow Control Endpoint on my service but can't seem to get it to work.

    My service is a .xamlx workflow so there isn't much to the application itself. I have the .xamlx file and a web.config essentially. Here is what I added to my web.config for the service hosted in IIS:

     

    <services>
     <service name="MyWorkflowService">
     <endpoint address="wce" binding="basicHttpBinding" kind="workflowControlEndpoint" 
       behaviorConfiguration="myServiceBehavior" name="wceEndpoint" 
       contract="System.ServiceModel.Activities.IWorkflowInstanceManagement" />
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
     <endpoint address="http://(DNS alias)/IdentityServices/Workflow.xamlx"
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPRequestService"
      contract="IPRequestService" name="BasicHttpBinding_IRequestService" />
     </service>
     </services>
    

     

    Along with the behavior:

     

    <serviceBehaviors>
    	<behavior name="myServiceBehavior">
       <serviceMetadata httpGetEnabled="True"/>
       <serviceDebug includeExceptionDetailInFaults="True" />
      </behavior>
    </serviceBehaviors>

     

    And again the code I use in the Web Application default.aspx.cs 

     

     WorkflowControlClient controlClient = new WorkflowControlClient(new BasicHttpBinding(), new EndpointAddress(new Uri("http://(DNS Host Name)/IdentityServices/RequestWorkflow.xamlx/wce")));
     controlClient.Cancel(localRequest.WorkflowInstanceId);
    

     

     

    So now when I test this, I get a different error message:

    The message with To 'http://(machine name)/IdentityServices/RequestWorkflow.xamlx/wce' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher.  Check that the sender and receiver's EndpointAddresses agree.

     

    Looks like I am closer but have hit another roadblock. The error shows the machine name now and not the DNS host name, which is what I use in the URL in web.config and in the code.

    Anyone have any ideas here? Really would appreciate it

    • Edited by dlackey Thursday, July 22, 2010 6:35 PM
    Sunday, July 18, 2010 7:29 PM
  • Hi,

    This error message seems like a WCF error message, I made some search and find this:
    http://stackoverflow.com/questions/339421/resolving-configuration-error-in-wcf-addressfilter-mismatch

    Hope it helps
    Regards
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com
    Tuesday, July 20, 2010 4:04 AM
  • Thanks Andrew, I have seen that link before but it wasn't my issue.

    I finally got everything working. I am posting what I had to do here in hopes that it helps someone else in the future that encounters same problem I did.

    What I think fixed the issue was deleting my Service Reference from my Web Application, and re-adding it back using the machine name in the URL for the xamlx service instead of using the DNS alias (CNAME). For some reason, using the DNS alias caused weird behaviors with the WorkflowControlEndpoint and caused the errors I listed in this post. So changing it there as well as in the web.config for the xamlx service and the web application did the trick.

    Here is what I have in my .xamlx web.config now for reference as well. I took out my actual values and put words in (  ) for the example:

    <system.serviceModel>
     <bindings>
      <basicHttpBinding>
      <binding name="BasicHttpBinding_IRequestService" closeTimeout="00:01:00"
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
       maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
       messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
       useDefaultWebProxy="true">
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
       maxBytesPerRead="4096" maxNameTableCharCount="16384" />
       <security mode="None">
       <transport clientCredentialType="None" proxyCredentialType="None"
        realm="" />
       <message clientCredentialType="UserName" algorithmSuite="Default" />
       </security>
      </binding>
      </basicHttpBinding>
     </bindings>
     <services>
      <service behaviorConfiguration="myServiceBehavior" name="RequestService">
      <endpoint address="wce" binding="basicHttpBinding" name="wceEndpoint" kind="workflowControlEndpoint" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRequestService"
       name="BasicHttpBinding_IRequestService" contract="IRequestService" />
      <host>
       <baseAddresses>
       <add baseAddress="http://(Machine Name, Fully Qualified)/IdentityServices/Workflow.xamlx/" />
       </baseAddresses>
      </host>
      </service>
     </services>
     <behaviors>
      <endpointBehaviors>
      <behavior name="myServiceBehavior">
       <webHttp/>
      </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
      <behavior name="myServiceBehavior">
       <serviceMetadata httpGetEnabled="true"/>
       <serviceDebug includeExceptionDetailInFaults="True" />
       <sqlWorkflowInstanceStore connectionString="Data Source=(SQL Server Machine Name);Initial Catalog=(SQL Server Database Name);Integrated Security=True;Asynchronous Processing=True" />
       <workflowIdle timeToPersist="0"/>
       <etwTracking profileName="HealthMonitoring Tracking Profile"/>
      </behavior>
      </serviceBehaviors>
     </behaviors>
    

    And in the code I call the Cancel operation of the WorkflowControlEndpoint like this:

    // Create the WorkflowControlClient with the WorkflowControlEndpoint
    WorkflowControlClient controlClient = new WorkflowControlClient(new BasicHttpBinding(), new EndpointAddress(new Uri("http://(Machine Name, Fully Qualified)/IdentityServices/Workflow.xamlx/wce")));
    
    // Cancel the particular workflow
    controlClient.Cancel(WorkflowInstanceId);
    
    // Close the controlClient
    controlClient.Close();
    
    • Marked as answer by dlackey Thursday, July 22, 2010 6:33 PM
    Thursday, July 22, 2010 6:31 PM
  • dlackey, Thanks for your sharing.
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com
    Friday, July 23, 2010 12:55 AM