2012-02-09 57 views
1

我有一個WF4 WCF服務,我試圖通過soap消息使基於內容的關聯工作。WF4 WCF關聯和MessageContract不起作用

我收到以下錯誤消息:

<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: 以下是我真正需要做的:

接收請求
發送單向WCF調用服務器X
(第2接收)服務器X發送回與相關標識,不回覆
一個新的WCF調用工作流做一些其他的東西
發送回覆原來的接收

這是我想要工作的基本工作流程。問題是第二次接收沒有被找到,因爲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> 

回答

1

我很想念你的XAML的CorrelationInitializers。 CorrelationInitializers用於使用原始請求在Receive或SendReply活動上創建關聯。之後,CorrelatesOn將在隨後的接收活動中使用。

+0

我得到了初始化器。我對原始帖子進行了更新 – user456748 2012-02-09 20:25:36

0

我剛剛遇到同樣的問題,您鏈接的文章實際上幫助我解決了這個問題。關於一路下跌的頁面3/4,還有就是讀一個段落...

如果XPath查詢時沒有正確地配置,使得沒有相關 數據被檢索,故障返回以下消息:「A 相關查詢產生了空的結果集,請確保 端點的相關查詢已正確配置。」其中一個 快速解決此問題的方法是用前面部分中所述的 文字值替換XPath查詢。如果在「添加關聯」 「初始化程序」或「關聯定義」對話框中使用XPath查詢構建器,並且您的工作流程 服務使用了消息協定,則可能會發生此問題 。

即使您選擇的屬性是消息頭的一部分,該對話框始終會生成目標消息正文屬性的查詢。訪問頭屬性正確的查詢是:

sm:header()/namespace:property 

注意,屬性名稱不包含對象資格,因此下面的查詢應爲你工作:

sm:header()/tempuri:CorrelationId 

如果你願意喜歡更改標題屬性的名稱空間,請使用MessageHeaderAttribute類的Namespace屬性。