在WCF服务器web.config中配置<service>端点地址

时间:2015-11-13 11:33:48

标签: c# asp.net .net web-services wcf

我无法在<service>文件中找到endpoint address部分web.config的配置影响。如果我评论所有可用的&#39;&#39;并在Visual Studio中的ASP网站项目上启动我的WCF,WCF测试客户端实用程序启动并允许函数调用,就像在未注释的情况下一样。并且可以在浏览器的http://localhost:35168/kmNNN.svc地址转到标准页面,其中包含有关WSDL和服务使用示例的信息,就像我之前所做的那样。

如何在endpoint address中定义的地址提供测试服务?

我如何测试MEX服务是否已启动?我以为我可以去浏览http://localhost:35168/kmNNN.svc/MEX并在浏览器中查看内容,但这不起作用。

的web.config:

               

    

  <endpointBehaviors>
    <behavior name="kmNNNwebSrv.WCFJSproxyBehavior">
      <!--<enableWebScript/>-->
    </behavior>
  </endpointBehaviors>

  <serviceBehaviors>
    <behavior name="MEX">
      <serviceMetadata/>
    </behavior>

    <behavior name="">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
    multipleSiteBindingsEnabled="true" />

<services>

  <service name="kmNNNwebSrv.kmNNNDevice">
    <endpoint address="" 
              behaviorConfiguration="kmNNNwebSrv.WCFJSproxyBehavior"
              binding="basicHttpBinding" contract="kmNNNwebSrv.IkmNNNDevice">
    </endpoint>
  </service>

  <service name="MyService" behaviorConfiguration="MEX">
    <endpoint
        address="MEX"
        binding="mexHttpBinding"
        contract="IMetadataExchange"/>
  </service>


</services>

    

1 个答案:

答案 0 :(得分:0)

您的配置文件不明确。我认为您的服务是kmNNN服务命名空间中的kmNNN服务声明。 ho它有帮助  拿这一个

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section  ...-Your Conf-...></section>
  </configSections>

  <connectionStrings>
     <add ....-Your connection string-.></add> 
  </connectionStrings>

  <applicationSettings>
  </applicationSettings>

  <system.serviceModel>
    <services>

      <service behaviorConfiguration="endpointBehavior" name="NamespaceOfYourService.YourService">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcpBinding.NamespaceOfYourService" contract="NamespaceOfYourInterface.YourInterface">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:port/YourService/" />
          </baseAddresses>
        </host>
      </service>

    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="endpointBehavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <netTcpBinding>
        <binding name="netTcpBinding.NamespaceOfYourService" transferMode="Streamed"
                 closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" 
                 maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
                        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

        </binding>

      </netTcpBinding>
    </bindings>

  </system.serviceModel>
</configuration>