简体   繁体   English

Biztalk-通过外部程序集使用WCF

[英]Biztalk - Consuming WCF via an external assembly

I've a WCF service which is referenced into an assembly. 我有一个WCF服务,该服务被引用到程序集中。 This Assembly has been referenced in a BizTalk project. BizTalk项目中已经引用了该程序集。 While calling the WCF method via Orchestration it gave following error: Could not find default endpoint element that references contract 'SubscriberService.ISubscriber' in the ServiceModel client configuration section. 通过Orchestration调用WCF方法时,出现以下错误: 在ServiceModel客户端配置部分中找不到引用合同'SubscriberService.ISubscriber'的默认终结点元素。

I've googled it and it is a known issue if you try to call the WCF via assembly in a Window project or web application. 我已经用谷歌搜索过,如果您尝试通过Window项目或Web应用程序中的程序集调用WCF,这是一个已知问题。 This can be resolved if we adds configuration in the project which is calling the assembly. 如果我们在调用程序集的项目中添加配置,则可以解决此问题。 And I've tested the scenario in sample project and copying the client configuration to my test project resolves the issue but this is not working in BIZTALK project. 而且我已经在示例项目中测试了该方案,并将客户端配置复制到我的测试项目中可以解决此问题,但这在BIZTALK项目中不起作用。

Configuration in App.Config file of assembly: 程序集的App.Config文件中的配置:

<configuration>

  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="CustomerMain.HelperAssembly.CoreProcess.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <system.serviceModel>
    <protocolMapping>
      <add binding="basicHttpBinding" scheme="http" />
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ISubscriber" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:81/SubscriberService.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISubscriber"
          contract="SubscriberService.ISubscriber" name="BasicHttpBinding_ISubscriber" />
    </client>
  </system.serviceModel>

</configuration>

Configuration in Biztalk Project's App.Config file: Biztalk Project的App.Config文件中的配置:

<configuration>

  <system.serviceModel>
    <protocolMapping>
      <add binding="basicHttpBinding" scheme="http" />
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ISubscriber" bypassProxyOnLocal="true" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:81/SubscriberService.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISubscriber"
          contract="SubscriberService.ISubscriber" name="BasicHttpBinding_ISubscriber" />
    </client>
  </system.serviceModel>

</configuration>

Thanks 谢谢

Because this is a BizTalk project, the answer begins with do not do this . 因为这是一个BizTalk项目,所以答案始于不要这样做

While you can, it is not the correct way to call a Service in a BizTalk app. 虽然可以,但这不是在BizTalk应用程序中调用服务的正确方法。

So, the correct way to address this is to add that Service to your app using the BizTalk WCF Adapter. 因此,解决此问题的正确方法是使用BizTalk WCF适配器将该服务添加到您的应用程序中。

If anyone on you team raises any objections, we're happy to help you address those. 如果您团队中的任何人提出异议,我们很乐意帮助您解决这些问题。 There is no scenario where what you describe is the right thing to do. 在任何情况下,您描述的都是正确的做法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM