WCF通过Web浏览器使用服务

时间:2012-08-29 19:08:06

标签: json wcf service web

我正在尝试使用网络浏览器来测试我所做的新服务,但没有运气。每当我点击URL时,它就会显示为空白。这是我的配置,任何人都可以看到我有任何错误?

<?xml version="1.0"?>
<configuration>

  <connectionStrings>
    <add name="APerson"
         connectionString="data source=|DataDirectory|Database.sdf"
         providerName="System.Data.SqlServerCe.4.0"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="HighTech_API_Service" behaviorConfiguration="ServiceDebug">
        <endpoint
              behaviorConfiguration="web"
              address="http://localhost:54107/jsonservice"
              binding="webHttpBinding"
              contract="Some_API_Service.IJsonService" />
        <endpoint
           address="mex"
           binding="mexHttpBinding"
           contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceDebug">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

使用WCF测试客户端可以正常运行我的服务,但我需要通过URL来完成。

1 个答案:

答案 0 :(得分:0)

为了实现这一点,我只需设置IIS来托管服务......