WF4 WCF 关联和 MessageContract 不起作用

发布于 2025-01-03 21:51:03 字数 17130 浏览 1 评论 0 原文

我有一个 WF4 WCF 服务,我试图通过肥皂消息使用基于内容的相关性来工作。

我收到以下错误消息:

<Message>A correlation query yielded an empty result set. Please ensure correlation queries for the endpoint are correctly configured.</Message>
           <StackTrace><![CDATA[at System.ServiceModel.Activities.Dispatcher.CorrelationKeyCalculator.Calculator`1.CalculateKeys(T target, Message messageToReadHeaders, InstanceKey& instanceKey, ICollection`1& additionalKeys)
   at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.GetInstanceKeys(OperationContext operationContext, InstanceKey& instanceKey, ICollection`1& additionalKeys)
at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.ControlOperationAsyncResult.EnsureInstanceId()
at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.ControlOperationAsyncResult.Process()
at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.ControlOperationAsyncResult..ctor(ControlOperationInvoker invoker, Object[] inputs, IInvokeReceivedNotification notification, TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.InvokeBegin(Object instance, Object[] inputs, IInvokeReceivedNotification notification, AsyncCallback callback, Object state)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)]]></StackTrace>

这是我的类

[MessageContract(IsWrapped = false)]
public class ClaimObj
{
    [MessageHeader]
    public string CorrelationId { get; set; }

    [MessageBodyMember]
    public string InstanceId { get; set; }
}

这是我的 xaml,由于专有原因更改了命名空间

<Activity mc:Ignorable="sap" x:Class="Project.WorkFlow.Activities.Activity4" sap:VirtualizedContainerService.HintSize="654,676" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="http://ns.ns2.com/" xmlns:p1="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel" xmlns:qm="clr-namespace:Project.MessageWrappers;assembly=Project.MessageWrappers" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:ssa="clr-namespace:System.ServiceModel.Activities;assembly=System.ServiceModel.Activities" xmlns:ssx="clr-namespace:System.ServiceModel.XamlIntegration;assembly=System.ServiceModel" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Flowchart sad:XamlDebuggerXmlReader.FileName="D:\Activity4.xaml" sap:VirtualizedContainerService.HintSize="614,636">
<Flowchart.Variables>
  <Variable x:TypeArguments="qm:ClaimObj" Name="RequestObj" />
  <Variable x:TypeArguments="p1:CorrelationHandle" Name="handle" />
</Flowchart.Variables>
<sap:WorkflowViewStateService.ViewState>
  <scg3:Dictionary x:TypeArguments="x:String, x:Object">
    <x:Boolean x:Key="IsExpanded">False</x:Boolean>
    <av:Point x:Key="ShapeLocation">270,2.5</av:Point>
    <av:Size x:Key="ShapeSize">60,75</av:Size>
    <av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 290,107.5 290,115</av:PointCollection>
  </scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<Flowchart.StartNode>
  <FlowStep x:Name="__ReferenceID1">
    <sap:WorkflowViewStateService.ViewState>
      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
        <av:Point x:Key="ShapeLocation">162.5,115</av:Point>
        <av:Size x:Key="ShapeSize">255,90</av:Size>
        <av:PointCollection x:Key="ConnectorLocation">290,205 290,235</av:PointCollection>
      </scg3:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <p1:Receive x:Name="__ReferenceID0" CanCreateInstance="True" CorrelatesWith="[handle]" sap:VirtualizedContainerService.HintSize="255,90" OperationName="Process" ServiceContractName="p:IActivity4Service">
      <p1:Receive.CorrelatesOn>
        <p1:XPathMessageQuery x:Key="key1">
          <p1:XPathMessageQuery.Namespaces>
            <ssx:XPathMessageContextMarkup>
              <x:String x:Key="xg0">http://schemas.datacontract.org/2004/07/Project.MessageWrappers</x:String>
            </ssx:XPathMessageContextMarkup>
          </p1:XPathMessageQuery.Namespaces>sm:header()/tempuri:CorrelationId</p1:XPathMessageQuery>
      </p1:Receive.CorrelatesOn>
      <p1:ReceiveMessageContent DeclaredMessageType="qm:ClaimObj">
        <OutArgument x:TypeArguments="qm:ClaimObj">[RequestObj]</OutArgument>
      </p1:ReceiveMessageContent>
    </p1:Receive>
    <FlowStep.Next>
      <FlowStep x:Name="__ReferenceID2">
        <sap:WorkflowViewStateService.ViewState>
          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
            <av:Point x:Key="ShapeLocation">162.5,235</av:Point>
            <av:Size x:Key="ShapeSize">255,90</av:Size>
          </scg3:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <p1:SendReply Request="{x:Reference __ReferenceID0}" DisplayName="SendReplyToReceive" sap:VirtualizedContainerService.HintSize="255,90">
          <p1:SendMessageContent DeclaredMessageType="qm:ClaimObj">
            <InArgument x:TypeArguments="qm:ClaimObj">[RequestObj]</InArgument>
          </p1:SendMessageContent>
        </p1:SendReply>
      </FlowStep>
    </FlowStep.Next>
  </FlowStep>
</Flowchart.StartNode>
<x:Reference>__ReferenceID1</x:Reference>
<x:Reference>__ReferenceID2</x:Reference>

我知道问题出在我的 xpath 相关性上。我尝试了许多不同的想法,唯一有效的是 11445 (http:// msdn.microsoft.com/en-us/library/ee358742.aspx),但这并没有给我提供相关性的跟踪。这些不起作用

sm:body()/xg0:ClaimObj/xg0:CorrelationId    
sm:header()/tempuri:CorrelationId
sm:header()/xg0:ClaimObj/xg0:CorrelationId
sm:header()/tempuri:ClaimObj/tempuri:CorrelationId

我可以让它与 DataContracts 一起正常工作,但我需要使用 MessageContracts

UPDATE: 这是我真正需要做的:

接收请求
向服务器 X 发送单向 WCF 调用
(第二次接收)服务器 X 在新的 wcf 调用中使用相关 ID 发送回工作流,而不是回复
做一些其他的事情
发送回复原始接收

这是我正在尝试开始工作的基本工作流程。问题是由于未找到 xpath,因此未调用第二个接收。

顺便说一句,当我尝试在第一次接收中使用correlationinitializer时,我遇到了同样的问题

<Activity mc:Ignorable="sap" x:Class="Project.WorkFlow.Activities.Activity4" sap:VirtualizedContainerService.HintSize="828,872" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="http://ns.domain.com/" xmlns:p1="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel" xmlns:qm="clr-namespace:Project.MessageWrappers;assembly=Project.MessageWrappers" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:ssa="clr-namespace:System.ServiceModel.Activities;assembly=System.ServiceModel.Activities" xmlns:ssx="clr-namespace:System.ServiceModel.XamlIntegration;assembly=System.ServiceModel" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Flowchart sad:XamlDebuggerXmlReader.FileName="D:\Activity4.xaml" sap:VirtualizedContainerService.HintSize="788,832">
<Flowchart.Variables>
  <Variable x:TypeArguments="qm:ClaimObj" Name="RequestObj" />
  <Variable x:TypeArguments="p1:CorrelationHandle" Name="handle" />
  <Variable x:TypeArguments="qm:GetClaimObj" Name="GetClaimIn" />
</Flowchart.Variables>
<sap:WorkflowViewStateService.ViewState>
  <scg3:Dictionary x:TypeArguments="x:String, x:Object">
    <x:Boolean x:Key="IsExpanded">False</x:Boolean>
    <av:Point x:Key="ShapeLocation">270,2.5</av:Point>
    <av:Size x:Key="ShapeSize">60,75</av:Size>
    <av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 290,107.5 290,115</av:PointCollection>
    <x:Double x:Key="Width">773.5</x:Double>
    <x:Double x:Key="Height">796.04</x:Double>
  </scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<Flowchart.StartNode>
  <FlowStep x:Name="__ReferenceID1">
    <sap:WorkflowViewStateService.ViewState>
      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
        <av:Point x:Key="ShapeLocation">162.5,115</av:Point>
        <av:Size x:Key="ShapeSize">255,90</av:Size>
        <av:PointCollection x:Key="ConnectorLocation">290,205 290,209 241,209 241,239</av:PointCollection>
      </scg3:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <p1:Receive x:Name="__ReferenceID0" CanCreateInstance="True" CorrelatesWith="[handle]" sap:VirtualizedContainerService.HintSize="255,90" OperationName="Process" ServiceContractName="p:IActivity4Service">
      <p1:Receive.KnownTypes>
        <x:Type Type="qm:ClaimObj" />
      </p1:Receive.KnownTypes>
      <p1:ReceiveMessageContent DeclaredMessageType="qm:ClaimObj">
        <OutArgument x:TypeArguments="qm:ClaimObj">[RequestObj]</OutArgument>
      </p1:ReceiveMessageContent>
    </p1:Receive>
    <FlowStep.Next>
      <FlowStep x:Name="__ReferenceID2">
        <sap:WorkflowViewStateService.ViewState>
          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
            <av:Point x:Key="ShapeLocation">120,239</av:Point>
            <av:Size x:Key="ShapeSize">242,93</av:Size>
            <av:PointCollection x:Key="ConnectorLocation">241,332 240,332 240,355</av:PointCollection>
          </scg3:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <p1:InitializeCorrelation Correlation="[handle]" sap:VirtualizedContainerService.HintSize="242,93">
          <InArgument x:TypeArguments="x:String" x:Key="key1">[RequestObj.CorrelationId]</InArgument>
        </p1:InitializeCorrelation>
        <FlowStep.Next>
          <FlowStep x:Name="__ReferenceID3">
            <sap:WorkflowViewStateService.ViewState>
              <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                <av:Point x:Key="ShapeLocation">112.5,355</av:Point>
                <av:Size x:Key="ShapeSize">255,90</av:Size>
                <av:PointCollection x:Key="ConnectorLocation">240,445 240,475 241,475 241,479</av:PointCollection>
              </scg3:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <p1:Receive CorrelatesWith="[handle]" sap:VirtualizedContainerService.HintSize="255,90" OperationName="GetClaim" ServiceContractName="p:IActivity4Service">
              <p1:Receive.CorrelatesOn>
                <p1:XPathMessageQuery x:Key="key1">
                  <p1:XPathMessageQuery.Namespaces>
                    <ssx:XPathMessageContextMarkup>
                      <x:String x:Key="xg0">http://schemas.datacontract.org/2004/07/Project.MessageWrappers</x:String>
                    </ssx:XPathMessageContextMarkup>
                  </p1:XPathMessageQuery.Namespaces>sm:header()/xg0:CorrelationId</p1:XPathMessageQuery>
              </p1:Receive.CorrelatesOn>
              <p1:ReceiveMessageContent DeclaredMessageType="qm:GetClaimObj">
                <OutArgument x:TypeArguments="qm:GetClaimObj">[GetClaimIn]</OutArgument>
              </p1:ReceiveMessageContent>
            </p1:Receive>
            <FlowStep.Next>
              <FlowStep x:Name="__ReferenceID4">
                <sap:WorkflowViewStateService.ViewState>
                  <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                    <av:Point x:Key="ShapeLocation">120,479</av:Point>
                    <av:Size x:Key="ShapeSize">242,58</av:Size>
                    <av:PointCollection x:Key="ConnectorLocation">241,537 240,537 240,565</av:PointCollection>
                  </scg3:Dictionary>
                </sap:WorkflowViewStateService.ViewState>
                <Assign sap:VirtualizedContainerService.HintSize="242,58">
                  <Assign.To>
                    <OutArgument x:TypeArguments="x:String">[GetClaimIn.InstanceId]</OutArgument>
                  </Assign.To>
                  <Assign.Value>
                    <InArgument x:TypeArguments="x:String">Get is called</InArgument>
                  </Assign.Value>
                </Assign>
                <FlowStep.Next>
                  <FlowStep x:Name="__ReferenceID5">
                    <sap:WorkflowViewStateService.ViewState>
                      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                        <av:Point x:Key="ShapeLocation">112.5,565</av:Point>
                        <av:Size x:Key="ShapeSize">255,90</av:Size>
                      </scg3:Dictionary>
                    </sap:WorkflowViewStateService.ViewState>
                    <p1:SendReply Request="{x:Reference __ReferenceID0}" DisplayName="SendReplyToReceive" sap:VirtualizedContainerService.HintSize="255,90">
                      <p1:SendMessageContent DeclaredMessageType="qm:GetClaimObj">
                        <InArgument x:TypeArguments="qm:GetClaimObj">[GetClaimIn]</InArgument>
                      </p1:SendMessageContent>
                    </p1:SendReply>
                  </FlowStep>
                </FlowStep.Next>
              </FlowStep>
            </FlowStep.Next>
          </FlowStep>
        </FlowStep.Next>
      </FlowStep>
    </FlowStep.Next>
  </FlowStep>
</Flowchart.StartNode>
<x:Reference>__ReferenceID1</x:Reference>
<x:Reference>__ReferenceID2</x:Reference>
<x:Reference>__ReferenceID3</x:Reference>
<x:Reference>__ReferenceID4</x:Reference>
<x:Reference>__ReferenceID5</x:Reference>

I have a WF4 WCF service that i am trying to get correlation to work using Content based through the soap message.

I am getting the following error message:

<Message>A correlation query yielded an empty result set. Please ensure correlation queries for the endpoint are correctly configured.</Message>
           <StackTrace><![CDATA[at System.ServiceModel.Activities.Dispatcher.CorrelationKeyCalculator.Calculator`1.CalculateKeys(T target, Message messageToReadHeaders, InstanceKey& instanceKey, ICollection`1& additionalKeys)
   at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.GetInstanceKeys(OperationContext operationContext, InstanceKey& instanceKey, ICollection`1& additionalKeys)
at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.ControlOperationAsyncResult.EnsureInstanceId()
at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.ControlOperationAsyncResult.Process()
at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.ControlOperationAsyncResult..ctor(ControlOperationInvoker invoker, Object[] inputs, IInvokeReceivedNotification notification, TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Activities.Dispatcher.ControlOperationInvoker.InvokeBegin(Object instance, Object[] inputs, IInvokeReceivedNotification notification, AsyncCallback callback, Object state)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)]]></StackTrace>

here is my class

[MessageContract(IsWrapped = false)]
public class ClaimObj
{
    [MessageHeader]
    public string CorrelationId { get; set; }

    [MessageBodyMember]
    public string InstanceId { get; set; }
}

here is my xaml with the namespaces changed for proprietary reasons

<Activity mc:Ignorable="sap" x:Class="Project.WorkFlow.Activities.Activity4" sap:VirtualizedContainerService.HintSize="654,676" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="http://ns.ns2.com/" xmlns:p1="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel" xmlns:qm="clr-namespace:Project.MessageWrappers;assembly=Project.MessageWrappers" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:ssa="clr-namespace:System.ServiceModel.Activities;assembly=System.ServiceModel.Activities" xmlns:ssx="clr-namespace:System.ServiceModel.XamlIntegration;assembly=System.ServiceModel" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Flowchart sad:XamlDebuggerXmlReader.FileName="D:\Activity4.xaml" sap:VirtualizedContainerService.HintSize="614,636">
<Flowchart.Variables>
  <Variable x:TypeArguments="qm:ClaimObj" Name="RequestObj" />
  <Variable x:TypeArguments="p1:CorrelationHandle" Name="handle" />
</Flowchart.Variables>
<sap:WorkflowViewStateService.ViewState>
  <scg3:Dictionary x:TypeArguments="x:String, x:Object">
    <x:Boolean x:Key="IsExpanded">False</x:Boolean>
    <av:Point x:Key="ShapeLocation">270,2.5</av:Point>
    <av:Size x:Key="ShapeSize">60,75</av:Size>
    <av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 290,107.5 290,115</av:PointCollection>
  </scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<Flowchart.StartNode>
  <FlowStep x:Name="__ReferenceID1">
    <sap:WorkflowViewStateService.ViewState>
      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
        <av:Point x:Key="ShapeLocation">162.5,115</av:Point>
        <av:Size x:Key="ShapeSize">255,90</av:Size>
        <av:PointCollection x:Key="ConnectorLocation">290,205 290,235</av:PointCollection>
      </scg3:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <p1:Receive x:Name="__ReferenceID0" CanCreateInstance="True" CorrelatesWith="[handle]" sap:VirtualizedContainerService.HintSize="255,90" OperationName="Process" ServiceContractName="p:IActivity4Service">
      <p1:Receive.CorrelatesOn>
        <p1:XPathMessageQuery x:Key="key1">
          <p1:XPathMessageQuery.Namespaces>
            <ssx:XPathMessageContextMarkup>
              <x:String x:Key="xg0">http://schemas.datacontract.org/2004/07/Project.MessageWrappers</x:String>
            </ssx:XPathMessageContextMarkup>
          </p1:XPathMessageQuery.Namespaces>sm:header()/tempuri:CorrelationId</p1:XPathMessageQuery>
      </p1:Receive.CorrelatesOn>
      <p1:ReceiveMessageContent DeclaredMessageType="qm:ClaimObj">
        <OutArgument x:TypeArguments="qm:ClaimObj">[RequestObj]</OutArgument>
      </p1:ReceiveMessageContent>
    </p1:Receive>
    <FlowStep.Next>
      <FlowStep x:Name="__ReferenceID2">
        <sap:WorkflowViewStateService.ViewState>
          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
            <av:Point x:Key="ShapeLocation">162.5,235</av:Point>
            <av:Size x:Key="ShapeSize">255,90</av:Size>
          </scg3:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <p1:SendReply Request="{x:Reference __ReferenceID0}" DisplayName="SendReplyToReceive" sap:VirtualizedContainerService.HintSize="255,90">
          <p1:SendMessageContent DeclaredMessageType="qm:ClaimObj">
            <InArgument x:TypeArguments="qm:ClaimObj">[RequestObj]</InArgument>
          </p1:SendMessageContent>
        </p1:SendReply>
      </FlowStep>
    </FlowStep.Next>
  </FlowStep>
</Flowchart.StartNode>
<x:Reference>__ReferenceID1</x:Reference>
<x:Reference>__ReferenceID2</x:Reference>

I know the issue is with my xpath for the correlation. I have tried many different ideas and the only one that works is 11445 (http://msdn.microsoft.com/en-us/library/ee358742.aspx), but that doesn't give me the tracking with correlation. These don't work

sm:body()/xg0:ClaimObj/xg0:CorrelationId    
sm:header()/tempuri:CorrelationId
sm:header()/xg0:ClaimObj/xg0:CorrelationId
sm:header()/tempuri:ClaimObj/tempuri:CorrelationId

I can get it to work with DataContracts just fine, but i need to use MessageContracts

UPDATE:
Here is what i really need to do:

Receive request
send a one way wcf call to Server X
(2nd receive) Server X sends back to workflow in a new wcf call with correlation id, not a reply
do some other stuff
send reply to original receive

Here is the basic workflow I am trying to get working. The issue is that the 2nd receive is not being called due to the xpath not being found.

on a side note, i get the same issue when i try to use correlationinitializer in the first receive

<Activity mc:Ignorable="sap" x:Class="Project.WorkFlow.Activities.Activity4" sap:VirtualizedContainerService.HintSize="828,872" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="http://ns.domain.com/" xmlns:p1="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel" xmlns:qm="clr-namespace:Project.MessageWrappers;assembly=Project.MessageWrappers" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:ssa="clr-namespace:System.ServiceModel.Activities;assembly=System.ServiceModel.Activities" xmlns:ssx="clr-namespace:System.ServiceModel.XamlIntegration;assembly=System.ServiceModel" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Flowchart sad:XamlDebuggerXmlReader.FileName="D:\Activity4.xaml" sap:VirtualizedContainerService.HintSize="788,832">
<Flowchart.Variables>
  <Variable x:TypeArguments="qm:ClaimObj" Name="RequestObj" />
  <Variable x:TypeArguments="p1:CorrelationHandle" Name="handle" />
  <Variable x:TypeArguments="qm:GetClaimObj" Name="GetClaimIn" />
</Flowchart.Variables>
<sap:WorkflowViewStateService.ViewState>
  <scg3:Dictionary x:TypeArguments="x:String, x:Object">
    <x:Boolean x:Key="IsExpanded">False</x:Boolean>
    <av:Point x:Key="ShapeLocation">270,2.5</av:Point>
    <av:Size x:Key="ShapeSize">60,75</av:Size>
    <av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 290,107.5 290,115</av:PointCollection>
    <x:Double x:Key="Width">773.5</x:Double>
    <x:Double x:Key="Height">796.04</x:Double>
  </scg3:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<Flowchart.StartNode>
  <FlowStep x:Name="__ReferenceID1">
    <sap:WorkflowViewStateService.ViewState>
      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
        <av:Point x:Key="ShapeLocation">162.5,115</av:Point>
        <av:Size x:Key="ShapeSize">255,90</av:Size>
        <av:PointCollection x:Key="ConnectorLocation">290,205 290,209 241,209 241,239</av:PointCollection>
      </scg3:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <p1:Receive x:Name="__ReferenceID0" CanCreateInstance="True" CorrelatesWith="[handle]" sap:VirtualizedContainerService.HintSize="255,90" OperationName="Process" ServiceContractName="p:IActivity4Service">
      <p1:Receive.KnownTypes>
        <x:Type Type="qm:ClaimObj" />
      </p1:Receive.KnownTypes>
      <p1:ReceiveMessageContent DeclaredMessageType="qm:ClaimObj">
        <OutArgument x:TypeArguments="qm:ClaimObj">[RequestObj]</OutArgument>
      </p1:ReceiveMessageContent>
    </p1:Receive>
    <FlowStep.Next>
      <FlowStep x:Name="__ReferenceID2">
        <sap:WorkflowViewStateService.ViewState>
          <scg3:Dictionary x:TypeArguments="x:String, x:Object">
            <av:Point x:Key="ShapeLocation">120,239</av:Point>
            <av:Size x:Key="ShapeSize">242,93</av:Size>
            <av:PointCollection x:Key="ConnectorLocation">241,332 240,332 240,355</av:PointCollection>
          </scg3:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <p1:InitializeCorrelation Correlation="[handle]" sap:VirtualizedContainerService.HintSize="242,93">
          <InArgument x:TypeArguments="x:String" x:Key="key1">[RequestObj.CorrelationId]</InArgument>
        </p1:InitializeCorrelation>
        <FlowStep.Next>
          <FlowStep x:Name="__ReferenceID3">
            <sap:WorkflowViewStateService.ViewState>
              <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                <av:Point x:Key="ShapeLocation">112.5,355</av:Point>
                <av:Size x:Key="ShapeSize">255,90</av:Size>
                <av:PointCollection x:Key="ConnectorLocation">240,445 240,475 241,475 241,479</av:PointCollection>
              </scg3:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <p1:Receive CorrelatesWith="[handle]" sap:VirtualizedContainerService.HintSize="255,90" OperationName="GetClaim" ServiceContractName="p:IActivity4Service">
              <p1:Receive.CorrelatesOn>
                <p1:XPathMessageQuery x:Key="key1">
                  <p1:XPathMessageQuery.Namespaces>
                    <ssx:XPathMessageContextMarkup>
                      <x:String x:Key="xg0">http://schemas.datacontract.org/2004/07/Project.MessageWrappers</x:String>
                    </ssx:XPathMessageContextMarkup>
                  </p1:XPathMessageQuery.Namespaces>sm:header()/xg0:CorrelationId</p1:XPathMessageQuery>
              </p1:Receive.CorrelatesOn>
              <p1:ReceiveMessageContent DeclaredMessageType="qm:GetClaimObj">
                <OutArgument x:TypeArguments="qm:GetClaimObj">[GetClaimIn]</OutArgument>
              </p1:ReceiveMessageContent>
            </p1:Receive>
            <FlowStep.Next>
              <FlowStep x:Name="__ReferenceID4">
                <sap:WorkflowViewStateService.ViewState>
                  <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                    <av:Point x:Key="ShapeLocation">120,479</av:Point>
                    <av:Size x:Key="ShapeSize">242,58</av:Size>
                    <av:PointCollection x:Key="ConnectorLocation">241,537 240,537 240,565</av:PointCollection>
                  </scg3:Dictionary>
                </sap:WorkflowViewStateService.ViewState>
                <Assign sap:VirtualizedContainerService.HintSize="242,58">
                  <Assign.To>
                    <OutArgument x:TypeArguments="x:String">[GetClaimIn.InstanceId]</OutArgument>
                  </Assign.To>
                  <Assign.Value>
                    <InArgument x:TypeArguments="x:String">Get is called</InArgument>
                  </Assign.Value>
                </Assign>
                <FlowStep.Next>
                  <FlowStep x:Name="__ReferenceID5">
                    <sap:WorkflowViewStateService.ViewState>
                      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                        <av:Point x:Key="ShapeLocation">112.5,565</av:Point>
                        <av:Size x:Key="ShapeSize">255,90</av:Size>
                      </scg3:Dictionary>
                    </sap:WorkflowViewStateService.ViewState>
                    <p1:SendReply Request="{x:Reference __ReferenceID0}" DisplayName="SendReplyToReceive" sap:VirtualizedContainerService.HintSize="255,90">
                      <p1:SendMessageContent DeclaredMessageType="qm:GetClaimObj">
                        <InArgument x:TypeArguments="qm:GetClaimObj">[GetClaimIn]</InArgument>
                      </p1:SendMessageContent>
                    </p1:SendReply>
                  </FlowStep>
                </FlowStep.Next>
              </FlowStep>
            </FlowStep.Next>
          </FlowStep>
        </FlowStep.Next>
      </FlowStep>
    </FlowStep.Next>
  </FlowStep>
</Flowchart.StartNode>
<x:Reference>__ReferenceID1</x:Reference>
<x:Reference>__ReferenceID2</x:Reference>
<x:Reference>__ReferenceID3</x:Reference>
<x:Reference>__ReferenceID4</x:Reference>
<x:Reference>__ReferenceID5</x:Reference>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无敌元气妹 2025-01-10 21:51:03

我在 XAML 中缺少 CorrelationInitializers。 CorrelationInitializers 用于在 Receive 或 SendReply 活动上创建与原始请求的关联。此后,CorrelatesOn 将用于后续的接收活动。

I am missing the CorrelationInitializers in your XAML. The CorrelationInitializers is used to create a correlation on the Receive or SendReply activity with the original request. After that the CorrelatesOn is used in subsequent Receive activities.

霓裳挽歌倾城醉 2025-01-10 21:51:03

我刚刚遇到了同样的问题,您链接的文章实际上帮助我解决了这个问题。页面下方大约 3/4 处,有一段写着……

如果 XPath 查询配置不正确,导致没有关联
检索数据时,会返回错误并显示以下消息:“A
相关查询产生空结果集。请确保
端点的相关查询已正确配置。” 一
解决此问题的快速方法是将 XPath 查询替换为
如上一节所述的文字值。这个问题可以
如果您在“添加关联”中使用 XPath 查询构建器,则会发生这种情况
Initializers 或 CorrelatesOn Definition 对话框和您的工作流程
服务使用消息契约。

该对话框始终生成针对消息正文属性的查询,即使您选择的属性是消息标头的一部分也是如此。访问标头属性的正确查询是:

sm:header()/namespace:property

请注意,属性名称未由包含对象限定,因此以下查询应该适合您:

sm:header()/tempuri:CorrelationId

如果您想更改标头属性的命名空间,请使用 MessageHeaderAttribute 类的 >Namespace 属性。

I just ran into the same problem and the article you linked to actually helped me resolve it. About 3/4 of the way down the page, there is a paragraph that reads...

If an XPath query is configured incorrectly such that no correlation
data is retrieved, a fault is returned with the following message: "A
correlation query yielded an empty result set. Please ensure
correlation queries for the endpoint are correctly configured." One
quick way to troubleshoot this is to replace the XPath query with a
literal value as described in the previous section. This issue can
occur if you use the XPath query builder in the Add Correlation
Initializers or CorrelatesOn Definition dialog boxes and your workflow
service uses message contracts.

The dialog box always generates queries that target message body properties, even when the property you select is part of the message header. The correct query to access a header property is:

sm:header()/namespace:property

Note that the property name is not qualified by the containing object, so the following query should work for you:

sm:header()/tempuri:CorrelationId

If you'd like to change the namespace of the header property, use the Namespace property of the MessageHeaderAttribute class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文