0

嗨,我在我的服务器上的 IIS7 上有一个 WCF 同步服务托管,我可以在浏览器中访问 URL,实际上我构建了 WCF 服务,后来我通过添加我的 wcf 服务参考在我的解决方案中添加了一个 wcf 服务网站。在 service.svc 文件中,我提到了特定的服务。wcf 站点中的 web.config 看起来像

<configuration>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="SimGuru_WCF.SimGuruDBCacheSyncService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
          contract="SimGuru_WCF.ISimGuruDBCacheSyncContract">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <!-- 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="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

当我尝试访问该服务时,它给了我“远程服务器返回错误:(404)未找到”但我仍然可以通过 URL 访问该服务并且 app.config 文件是

<configuration>

  <configSections>
  </configSections>
  <connectionStrings>
    <add name="SimGuru_WCF.Properties.Settings.ServerSimGuru_RetailConnectionString"
      connectionString="Data Source=SIMGURU\SQLEXPRESS;Initial Catalog=SimGuru_Retail;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
   <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ISimGuruDBCacheSyncContract" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="SimGuru_WCF.SimGuruDBCacheSyncServiceBehavior"
        name="SimGuru_WCF.SimGuruDBCacheSyncService">
        <endpoint address="" binding="basicHttpBinding" contract="SimGuru_WCF.ISimGuruDBCacheSyncContract">
          <identity>
            <dns value="10.0.1.42"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://10.0.1.42:8731/SimGuruDBCacheSyncService/" />
          </baseAddresses>
          <timeouts closeTimeout="00:01:10" openTimeout="00:09:00" />
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SimGuru_WCF.SimGuruDBCacheSyncServiceBehavior">
          <!-- 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="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <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>

有人可以帮我解决这个问题吗

提前致谢

4

1 回答 1

0

我明白了,使用跟踪我能够解决我的问题

<diagnostics>
                         <messageLogging maxMessagesToLog="30000" 
                                 logEntireMessage="true" 
                                 logMessagesAtServiceLevel="true" 
                                 logMalformedMessages="true" 
                                 logMessagesAtTransportLevel="true">
                         </messageLogging>
                 </diagnostics>
  </system.serviceModel>
<system.diagnostics>
                 <sources>
                         <source name="System.ServiceModel" 
                                 switchValue="Verbose, ActivityTracing" 
                                 propagateActivity="true" >
                                 <listeners>
                                         <add name="xml" />
                                 </listeners>
                         </source>
                         <source name="System.ServiceModel.MessageLogging" 
                                 switchValue="Verbose">
                                 <listeners>
                                         <add name="xml" />
                                 </listeners>
                         </source>
                 </sources>
                 <sharedListeners>
                         <add name="xml" 
                              type="System.Diagnostics.XmlWriterTraceListener" 
                              initializeData="e2eTraceTest.e2e" />
                 </sharedListeners>
                 <trace autoflush="true" />
         </system.diagnostics>

跟踪查看器向我解释了我做错的地方一件事是 sql server 的安全问题,而且我什至在我的 web.xml 中没有连接字符串属性。配置文件我在 wcf 服务上有一个,但在 wcf 网站上没有任何解决方法

谢谢大家的合作

于 2012-08-30T16:49:41.030 回答