使用 BizTalk 使用 WCF 终结点时,什么会导致对象引用错误?

发布于 2024-09-18 18:28:02 字数 2135 浏览 7 评论 0原文

我在 BizTalk 2009 集成的另一边,我有一个相当简单的合同,看起来像这样:

[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) 

有人知道从哪里开始看这个吗?

I'm on the other side of a BizTalk 2009 integration, and I have a fairly simple contract stood up that looks something like this:

[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);
}

However, when the BizTalk group attempts to use the WCF Service Consuming Wizard, it chokes and provides this stack trace:

[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) 

And then again here:

[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) 

Anyone know where to start looking on this one?

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

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

发布评论

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

评论(2

嘿咻 2024-09-25 18:28:03

WCF 客户端应用程序无法使用具有单向操作的服务协定将消息发送到 WCF 接收位置。客户端合约上的操作应标注 IsOneWay=false 和 ReplyAction=”*”。唯一的例外是当您使用 NetMsmqBinding 时,在这种情况下,客户端合约上的所有操作都应该是单向的。

WCF client applications cannot use service contracts with one-way operations to send messages to your WCF receive locations. The operations on the client-side contract should be annotated with IsOneWay=false and ReplyAction=”*”. The only exception is when you’re using NetMsmqBinding, in which case all operations on the client contract should be one-way.

人生百味 2024-09-25 18:28:02

它可能类似于这些 - 此处此处,即:

  • 对 WCF 客户端使用 svcutil.exe 和/或 wsdl.exe,以确保非 BizTalk 客户端可以生成代理
  • 检查所有 WSDL 以确保目标命名空间存在对于所有元素 - 在您的实例中,还记得检查您的基础协定 (ILoadBalanced) 和您的实体 (WebResponseDto)

您能否确认您可以在一个简单的 WCF 服务上使用 WCF 使用向导(没有基本接口、一个操作、字符串输入)并返回字符串)?如果没有,则可能是您的 VS IDE 已损坏。

FWIW void 返回似乎不是问题 - BTS 为 void 操作创建以下响应模式

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

并将 Contract 和 Base Contract 接口放在不同的命名空间中也可以。

但是,向 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;
        //}
    }
}

It might be similar to these - here and here, viz:

  • Use svcutil.exe and / or wsdl.exe against your WCF client to ensure that a proxy can be generated by a non-BizTalk client
  • Check all the WSDL to ensure target namespaces exist for all elements - in your instance, also remember to check your base contract (ILoadBalanced) and your Entities (WebResponseDto)

Can you confirm that you can use the WCF Consume Wizard on a trivial WCF service (no base interface, one Operation, string input and string return)? If not, it may be that your VS IDE is corrupt.

FWIW the void returns don't seem to be an issue - BTS creates the following response schema for void operations

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

And placing the Contract and Base Contract interfaces in different namespaces was also OK.

However adding a non-serializable property to the DTO / entity failed both svcutil and the BizTalk WCF Wizard

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