在 3 个不同的 IIS 上发布 Web 服务得到不同的结果,此服务的元数据发布当前被禁用
publishing web service on 3 different IIS gets different result,Metadata publishing for this service is currently disabled
我正在编写 Web 服务程序。当我在 Server1 (Windows 2012 With IIS 8) 上发布 Web 服务时,它工作正常,但是如果我在 Server2 (Windows 2012 With IIS 8) 上发布,它会出现以下错误
Metadata publishing for this service is currently disabled.
我在 Server3 上测试过(Windows 2019 With IIS 10),我得到上面的错误
似乎是 IIS 设置问题,因为在 server1 中它工作正常。
这是服务web.Config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ECartContext" connectionString="metadata=res://*/ECartModel.csdl|res://*/ECartModel.ssdl|res://*/ECartModel.msl;provider=System.Data.SqlClient;provider connection string="data source=databaseServer;initial catalog=ECart;integrated security=True;Connection Timeout=30;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ManagementServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" >
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
使用此配置,服务仅适用于 Server1,不适用于 Server2 和 Server3
如何检查问题?
您需要在服务模型中添加端点:
<services>
<service name="WcfService2.Service1" behaviorConfiguration="ManagementServiceBehaviour">
<endpoint address="" contract="WcfService2.IService1" binding="basicHttpBinding"></endpoint>
</service>
</services>
我怀疑您在 server1 中有端点,但在 serve2 和 server3 中没有端点。
我正在编写 Web 服务程序。当我在 Server1 (Windows 2012 With IIS 8) 上发布 Web 服务时,它工作正常,但是如果我在 Server2 (Windows 2012 With IIS 8) 上发布,它会出现以下错误
Metadata publishing for this service is currently disabled.
我在 Server3 上测试过(Windows 2019 With IIS 10),我得到上面的错误
似乎是 IIS 设置问题,因为在 server1 中它工作正常。
这是服务web.Config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ECartContext" connectionString="metadata=res://*/ECartModel.csdl|res://*/ECartModel.ssdl|res://*/ECartModel.msl;provider=System.Data.SqlClient;provider connection string="data source=databaseServer;initial catalog=ECart;integrated security=True;Connection Timeout=30;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ManagementServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" >
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
使用此配置,服务仅适用于 Server1,不适用于 Server2 和 Server3
如何检查问题?
您需要在服务模型中添加端点:
<services>
<service name="WcfService2.Service1" behaviorConfiguration="ManagementServiceBehaviour">
<endpoint address="" contract="WcfService2.IService1" binding="basicHttpBinding"></endpoint>
</service>
</services>
我怀疑您在 server1 中有端点,但在 serve2 和 server3 中没有端点。