0

在 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 ”????*

4

1 回答 1

0

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

尝试使用ServiceModel 元数据实用工具 (Svcutil.exe)从 WSDL 而不是 Visual Studio 工具生成客户端代码

于 2013-11-03T17:18:15.880 回答