2010-09-14 50 views
0

我在一個BizTalk 2009年整合的另一面,我有一個非常簡單的合同站了起來,看起來是這樣的:當使用BizTalk消費WCF端點時,會導致對象引用錯誤的原因是什麼?

[ServiceContract(Name = "ReceiverService", Namespace = "http://services.company.org/")] 
public interface IReceiverService : ILoadBalanced 
{ 
[OperationContract] 
void FinishedRouting(long applicationId); 

[OperationContract] 
void ResponsePending(long applicationId, string stringId, short count); 

[OperationContract] 
void ReportException(long applicationId, string errorMessage, string stringId); 

[OperationContract] 
void SaveResponse(WebResponseDto decision); 
} 

然而,當BizTalk組嘗試使用WCF服務消費嚮導,它扼流圈和提供該堆棧跟蹤:

[5096] System.NullReferenceException: Object reference not set to an instance of an object. 
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Exporters.BindingInfoExporter.CreatePrimaryTransport(ServiceEndpoint serviceEndpoint, Boolean custom) 
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Exporters.BindingInfoExporter.CreateSendPort(ServiceEndpoint endpoint, Port port, Boolean custom) 
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Exporters.BindingInfoExporter.Export(ServiceEndpointCollection endpoints, ServiceDescriptionCollection wsdlDocuments, Boolean custom) 
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Consumer.CreateBindingFiles(MetadataSet metadataSet, String serviceName) 

然後再在這裏:

[5096] System.NullReferenceException: Object reference not set to an instance of an object. 
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Implementation.ClientImplementation.AddFilesToProject(String schemaNamespace) 
[5096] System.NullReferenceException: Object reference not set to an instance of an object. 
[5096] at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) 
[5096] at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) 
[5096] at Microsoft.BizTalk.Adapter.Wcf.Consuming.Consumer.Consume(ISynchronizeInvoke synchronizeInvoke, DTE dte, MetadataSet metadataSet, Project project, String importNamespace) 

任何人都知道從哪裏開始尋找這一個?

回答

1

這可能是類似這些 - herehere,即:

  • svcutil.exe的使用和/或Wsdl.exe用對你的WCF客戶端,以確保代理可以由非的BizTalk生成客戶
  • 檢查所有的WSDL,以確保所有元素存在目標命名空間 - 在您的實例,也記得要檢查你的基本合同(ILoadBalanced)和你的實體(WebResponseDto)

你能確認你可以使用在一個微不足道的WCF服務(沒有基礎接口,一個操作,字符串輸入和字符串返回)上的WCF消費嚮導?否則,可能是您的VS IDE損壞了。

FWIW虛空的回報似乎並不成爲一個問題 - BTS創建無效操作

<xs:element name="GetDataResponse"> 
    <xs:complexType> 
     <xs:sequence /> 
    </xs:complexType> 
    </xs:element> 

,並把合同並在不同的命名空間基本合同接口還行以下響應模式。

但是添加非序列化屬性的DTO /實體都失敗SvcUtil工具和BizTalk WCF嚮導

HTH

namespace WcfService1 
{ 
    [ServiceContract(Namespace = "http://someorl.org/ns1")] 
    public interface IBase 
    { 
     [OperationContract] 
     void SomeBaseMethod(int value); 
    } 

    [ServiceContract(Namespace = "http://someorl.org/ns2")] 
    public interface IService1 : IBase 
    { 

     [OperationContract] 
     void GetData(int value); 

     [OperationContract] 
     CompositeType GetDataUsingDataContract(CompositeType composite); 

     // TODO: Add your service operations here 
    } 


    // Use a data contract as illustrated in the sample below to add composite types to service operations. 
    [DataContract] 
    public class CompositeType 
    { 
     bool boolValue = true; 
     string stringValue = "Hello "; 

     [DataMember] 
     public bool BoolValue 
     { 
      get { return boolValue; } 
      set { boolValue = value; } 
     } 

     [DataMember] 
     public string StringValue 
     { 
      get { return stringValue; } 
      set { stringValue = value; } 
     } 

     //[DataMember] 
     //public XmlDocument NonSerializable 
     //{ 
     // get; 
     // set; 
     //} 
    } 
} 
+0

感謝徹底反應!這最終導致我回答我的答案......挖掘LoadBalanced契約,有一個WebGet方法最終打破了BizTalk的導入。 WCF測試客戶端可以看到它,但確實在它旁邊放了一點紅色感嘆號......我想BizTalk在這種情況下拒絕繼續。 – 2010-09-30 15:25:33

0

WCF客戶端應用程序無法使用具有單向操作的服務契約將消息發送到您的WCF接收位置。客戶端合同上的操作應使用IsOneWay = false和ReplyAction =「*」進行註釋。唯一的例外是當您使用NetMsmqBinding時,在這種情況下,客戶端合同上的所有操作應該是單向的。

相關問題