【问题标题】:hosting Wcf service via ServerHost in IIS,Console or winform App can add reference?在 IIS 中通过 ServerHost 托管 Wcf 服务,Console 或 winform App 可以添加引用吗?
【发布时间】:2013-11-03 14:39:40
【问题描述】:

在 IIS 中托管,web.config

<?xml version="1.0"?>
<configuration>
  <appSettings/>
  <connectionStrings/>
  <system.web>
    <compilation debug="true">
    </compilation>
    <authentication mode="Forms"/>
  </system.web>
  <system.serviceModel>

    <behaviors>
      <endpointBehaviors>
        <behavior name="AllenBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="mexBehavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
          <serviceThrottling maxConcurrentCalls="1000"  maxConcurrentSessions="1000" />
        </behavior>
      </serviceBehaviors>

    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <services>
      <service name="jqueryWCF.WCFservice" behaviorConfiguration="mexBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://127.0.0.1:9999/Service"/>
          </baseAddresses>
        </host>
        <endpoint address="" behaviorConfiguration="AllenBehavior" binding="webHttpBinding" contract="jqueryWCF.WCFservice" />
        <endpoint address="mex" binding="mexHttpBinding"
 contract="IMetadataExchange" />
      </service>

    </services>
  </system.serviceModel>

1 网页通过 JQuery ajax 访问成功 2 元数据也释放,URL访问成功;

*但是为什么控制台应用添加服务引用会出现“object reference not set to an instance of an object”????*

【问题讨论】:

  • 问题似乎出在控制台应用程序中。最好将发生错误的代码贴出来

标签: c# asp.net wcf iis


【解决方案1】:

您的 WCF 服务的元数据似乎有问题。 检查运营合同定义。 您的合同名称没有冲突吗?

尝试使用ServiceModel Metadata Utility Tool (Svcutil.exe) 从 WSDL 而不是 Visual Studio 工具生成客户端代码

【讨论】:

    猜你喜欢
    • 2012-02-23
    • 2012-04-15
    • 1970-01-01
    • 2012-02-22
    • 2016-03-07
    • 1970-01-01
    • 2011-07-13
    • 2022-12-13
    • 2019-08-29
    相关资源
    最近更新 更多