在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>
通过JQuery ajax获得1个网页访问成功 2元数据也被释放,URL访问成功;
* 但为什么控制台应用添加服务引用会出现“对象引用未设置为对象的实例 ”???? *
答案 0 :(得分:0)
您的WCF服务的元数据看起来有问题。 检查运营合同定义。 你有没有冲突的合同名称?
尝试使用ServiceModel Metadata Utility Tool (Svcutil.exe)从WSDL而不是Visual Studio工具生成客户端代码