2010-01-13 65 views
1

我有最煩人的問題;BizTalk WCF-SQL適配器從視圖中選擇

我有一個編排進行查看與視圖。 它在本地和我們的開發服務器上工作,但不在QA或UAT中。 相同的代碼。相同的看法。只是不同的環境。

爲了驗證這一點,並確保它不是一個編碼的問題,我把我的本地的BizTalk,配置端口服務器A,火災的消息,它將按預期工作。 然後,我將發送端口的配置更改爲服務器B(這就是我所做的一切),併發送相同的消息,並且失敗。

我得到兩個錯誤,對於相同的觀點相同的操作之一,所以甚至沒有錯誤消息是一致的。

Event Type: Warning 
Event Source: BizTalk Server 2009 
Event Category: (1) 
Event ID: 5743 
Date: 13/01/2010 
Time: 16:53:07 
User: N/A 
Computer: VM-RC-BTS2009 
Description: 
The adapter failed to transmit message going to send port "AX Lookup CRM_CUST" with URL "mssql://server//db?". It will be retransmitted after the retry interval specified for this Send Port. Details:"Microsoft.ServiceModel.Channels.Common.XmlReaderGenerationException: The columns BANKACCOUNTRECID and BLOCKED are either duplicated or not in a sequence. Each column can only be selected one time, and columns must be selected in sequence. 
    at Microsoft.Adapters.Sql.SelectBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer) 
    at System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer) 
    at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer) 
    at System.ServiceModel.Channels.Message.WriteBodyContents(XmlDictionaryWriter writer) 
    at Microsoft.Adapters.AdapterUtilities.AdapterMessage.OnWriteBodyContents(XmlDictionaryWriter writer) 
    at System.ServiceModel.Channels.Message.WriteBodyContents(XmlDictionaryWriter writer) 
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfMarshaller.CreateBizTalkMessageStream(Message wcfMessage, IAdapterConfigInboundMessageMarshalling config) 
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfMarshaller.CreateBizTalkMessage(IBaseMessageFactory messageFactory, IAdapterConfigInboundMessageMarshalling marshallingConfig, Message wcfMessage) 
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)". 

或者

Event Type: Warning 
Event Source: BizTalk Server 2009 
Event Category: (1) 
Event ID: 5743 
Date: 13/01/2010 
Time: 16:45:49 
User: N/A 
Computer: VM-RC-BTS2009.ad.integralgroup.co.nz 
Description: 
The adapter failed to transmit message going to send port "AX Lookup CRM_CUST" with URL "mssql://vm-lesmillsnzqa.aplplus.local//LMNZ_AX_Improve?". It will be retransmitted after the retry interval specified for this Send Port. Details:"Microsoft.ServiceModel.Channels.Common.XmlReaderGenerationException: The columns ACCOUNTNUM and BANKACCOUNTRECID are either duplicated or not in a sequence. Each column can only be selected one time, and columns must be selected in sequence. 
    at Microsoft.Adapters.Sql.SelectBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer) 
    at System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer) 
    at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer) 
    at System.ServiceModel.Channels.Message.WriteBodyContents(XmlDictionaryWriter writer) 
    at Microsoft.Adapters.AdapterUtilities.AdapterMessage.OnWriteBodyContents(XmlDictionaryWriter writer) 
    at System.ServiceModel.Channels.Message.WriteBodyContents(XmlDictionaryWriter writer) 
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfMarshaller.CreateBizTalkMessageStream(Message wcfMessage, IAdapterConfigInboundMessageMarshalling config) 
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfMarshaller.CreateBizTalkMessage(IBaseMessageFactory messageFactory, IAdapterConfigInboundMessageMarshalling marshallingConfig, Message wcfMessage) 
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)". 
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. 

我要求<Columns>*</Columns><Query>WHERE FIELD='xyz'</Query>

下面是實際的消息;

<ns0:Select xmlns:ns3="http://schemas.microsoft.com/Sql/2008/05/Types/Views/dbo" xmlns:ns0="http://schemas.microsoft.com/Sql/2008/05/ViewOp/dbo/CRM_CUST"> 
<ns0:Columns>*</ns0:Columns> 
<ns0:Query>WHERE ACCOUNTNUM='id_0'</ns0:Query> 
</ns0:Select> 

然後我有一個雙向Wcf自定義發送端口sqlbinding。這裏的配置

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.serviceModel> 
    <client> 
     <endpoint address="mssql://devserver//DbName?" behaviorConfiguration="EndpointBehavior" binding="sqlBinding" bindingConfiguration="sqlBinding" contract="BizTalk" name="CUST Lookup" /> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="EndpointBehavior" /> 
     </endpointBehaviors> 
    </behaviors> 
    <bindings> 
     <sqlBinding> 
     <binding name="sqlBinding" useAmbientTransaction="false" /> 
     </sqlBinding> 
    </bindings> 
    </system.serviceModel> 
</configuration> 

而這個設置在Action映射中;

ViewOp/Select/dbo/CRM_CUST - 視圖

回答

1

所以名稱;已經放棄了從視圖選擇操作,這應該很簡單,並且懷疑這個適配器的這個特定部分的代碼存在問題,我決定嘗試一個「技巧」。

我創建一個存儲過程,只是不SELECT * FROM圖,其中ID = @Param(即前面所引起的問題相同的視圖),其中參數是我經過到ViewOp標準

然後使用所述AccountNum適配器嚮導生成的TypeStoredProcedure操作而不是ViewOp 改變地圖的模式,產生新的消息 Redploy 而急......現在我可以高興地兩種環境之間切換,而無需任何錯誤!

這樣對我清楚地說,有一個問題與SQL適配器的ViewOp部分!?!? 有人有任何其他的想法/解釋爲什麼會發生此問題,而不是適配器的問題?

我知道大多數人都說不使用視圖和去存儲過程來代替,但有一個非常強的原因,我們正在使用的意見。我們正在針對Microsoft Dynamics AX數據庫進行選擇。 AX發佈這些視圖供外部系統使用。 Microsoft針對AX架構創建存儲過程並不支持它更改其數據庫。如果我們使用CRM視圖,我們也不能隨意創建存儲過程。

因此,解決辦法,我現在可能會奏效,但它不支持。 它將不得不暫停,直到我們得到這個解決雖然

1

我最近遇到了同樣的問題。花了一天之後,我終於開始了一個SQL Profiler並找到了一個原因。出於某種原因,在某些數據庫(包括Ax2009數據庫)中,biztalk所需的列順序和列順序存在差異。它執行下列代碼,並希望該列是按正確的順序(「*」將不會爲你工作):

exec sp_executesql N'SELECT sp.type AS [ObjectType], modify_date AS [LastModified] FROM sys.all_objects AS sp WHERE ([email protected] and SCHEMA_NAME(sp.schema_id)[email protected]);SELECT clmns.name AS [Name], usrt.name AS [DataType], SCHEMA_NAME(usrt.schema_id) AS DataTypeSchemaName, usrt.is_assembly_type AS [IsAssemblyType], clmns.is_identity AS [IsIdentity], ISNULL(baset.name, N'''') AS [SystemType], CAST(CASE WHEN baset.name IN (N''nchar'', N''nvarchar'') AND clmns.max_length <> -1 THEN clmns.max_length/2 ELSE clmns.max_length END AS int) AS [Length], CAST(clmns.[precision] AS int) AS [NumericPrecision], CAST(clmns.[scale] AS int) AS [NumericScale], clmns.is_nullable as [IsNullable], clmns.is_computed as [IsComputed], 0 as [IsFileStream], AT.assembly_qualified_name AS AssemblyQualifiedName, defCst.definition AS [DefaultValue] FROM sys.columns as clmns LEFT OUTER JOIN sys.default_constraints defCst on defCst.parent_object_id = clmns.object_id and defCst.parent_column_id = clmns.column_id LEFT OUTER JOIN sys.types AS usrt ON usrt.user_type_id = clmns.user_type_id LEFT OUTER JOIN sys.types AS baset ON baset.user_type_id = clmns.system_type_id and baset.user_type_id = baset.system_type_id LEFT JOIN sys.assembly_types AT ON AT.[name] = usrt.name AND AT.schema_id = usrt.schema_id WHERE clmns.object_id = (SELECT object_id FROM sys.objects o WHERE [email protected] and SCHEMA_NAME(o.schema_id)[email protected])',N'@ORIGINALOBJECTNAME nvarchar(13),@ORIGINALSCHEMANAME nvarchar(3)',@ORIGINALOBJECTNAME=N'CRM_CFU',@ORIGINALSCHEMANAME=N'dbo' 

只需用視圖名稱替換@ORIGINALOBJECTNAME值,並把列在您的seect在確切的順序。

+0

不錯!感謝那德米特里! – ryancrawcour 2011-08-15 03:35:48

+0

@ryancrawcour:如果這回答你的問題,你應該把它標記爲接受的答案。 – 2013-11-08 20:01:04