用于在Server上部署的WCF Web.config

时间:2016-10-20 14:03:14

标签: .net wcf iis web-config

我已经开发了WCF REST服务但是无法在IIS上配置它,尽管它可以通过Visual Studio正常工作。

这是IIS的Web.config

<?xml version="1.0" encoding="UTF-8"?>

<connectionStrings>
<add name="IWGIConnectionString" connectionString="Data Source=xx.xxx.xx.xx,4567;User ID=xxx;Password=xxxx;Initial Catalog=IWGI_SVCS" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
 <compilation debug="true" targetFramework="4.0" />
 <httpRuntime maxUrlLength="4096" requestPathInvalidCharacters="" requestValidationMode="2.0" />

</system.web>
<system.serviceModel>
<client>
  <endpoint binding="basicHttpBinding" bindingConfiguration=""
    contract="IWMDSvcs.IIWMDService" name="BasicHtttp" />
</client>
<bindings>
  <basicHttpBinding>
    <binding name="basicHTTP" maxBufferSize="655360000" maxReceivedMessageSize="655360000" />
  </basicHttpBinding>
  <webHttpBinding>
    <binding name="webhttp"></binding>
  </webHttpBinding>
  <wsHttpBinding>
    <binding name="WsPlainBinding">
      <security mode="None">
        <transport clientCredentialType="None" />
        <message clientCredentialType="None" negotiateServiceCredential="false"
          establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<services>
  <service behaviorConfiguration="mexBehaviour" name="IWMDSvcs.IWMDService">
    <endpoint address="IWMDSvcs" binding="wsHttpBinding" bindingConfiguration="WsPlainBinding"
      contract="IWMDSvcs.IIWMDService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="BasicIWMDSvcs" binding="basicHttpBinding"
   bindingConfiguration="" name="basicHttp" contract="IWMDSvcs.IIWMDService" />
    <endpoint address="md" binding="webHttpBinding"
      bindingConfiguration="" name="webHttp" contract="IWMDSvcs.IIWMDService" behaviorConfiguration="httpbehavior" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:80/IWMDSvc.svc/md" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="mexBehaviour">
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="httpbehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>

</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
  <add name="svc-Integrated handling" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>

<appSettings>
<!--Log Switch: 0: Close Log; 1: Open Log-->
<add key="LogSwitch" value="1" />
<!--LogLevel: 0 = Only For Error; 1 = For Warning and Error; 2 = For Infor,Warning and Error; Other number will map to 1. -->
<add key="LogLevel" value="2" />

</appSettings>

</configuration>

为了让它在IIS上运行,我需要做些哪些更改?

这是我的Cotract:

[ServiceContract]
public interface IIWMDService
{
    [OperationContract]
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped,
        ResponseFormat = WebMessageFormat.Xml,
        Method = "GET",
        UriTemplate = "Test")]
    ResponseBase WSF001_Test();
}

注意:我想通过Windows Server 2012进行部署。

编辑:我收到以下错误

  

HTTP错误404.0 - 未找到   您要查找的资源已被删除,名称已更改或暂时不可用。

这是我在计算机上的本地IIS上部署后调用的URL。

http://localhost/client/md/test

由于

0 个答案:

没有答案