27
votes

I'm working over WCF and it worked fine on localhost. After I placed it on the production server, it thows an exception

The requested service, 'http://global-kazway.kz/Service1.svc' could not be activated. See the server's diagnostic trace logs for more information

I'm new in Services and have been trying to solve this problem for almost 3 hours.

Here is the App.config of the client;

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections></configSections>
  <connectionStrings>
    <add name="TestProject.Properties.Settings.DBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\1\Documents\visual studio 2010\Projects\TestProject\TestProject\AppData\DB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /><add name="DBEntities" connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=C:\Users\1\Documents\visual studio 2010\Projects\TestProject\TestProject\AppData\DB.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /><add name="DBEntities1" connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\AppData\DB.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" 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>
    <client>
      <endpoint address="http://global-kazway.kz/Service1.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IService1" contract="kazwayServiceReference.IService1"
        name="BasicHttpBinding_IService1" />
    </client>
  </system.serviceModel>
</configuration>
7
provide also service's config, please.TarasB

7 Answers

73
votes

First step in troubleshooting a WCF application is to bring up a browser and type in the service URI. So based on the client: you'd navigate to http://global-kazway.kz/Service1.svc

Now see what kind of results you get. Exception? The service screen? Usually you can get your best information from this screen! Sometimes it points out what your issue is such as missing a behavior.

Compare your web.config with the deployed web.config entries. You may find something there as well. Finally you may just have to manage security on your folder. But the browser display could spell everything out for you very clearly.

8
votes

I'm working on a project and I faced the same problem. When I checked the Event Viewer to trace the error, I found where the problem was.

Event Viewer message:

Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/7540993
 Exception: System.ServiceModel.ServiceActivationException: The service '/CODWebService/Service1.svc' cannot be activated due to an exception during compilation.  The exception message is: Memory gates checking failed because the free memory (164065280 bytes) is less than 5% of total memory.  As a result, the service will not be available for incoming requests.  To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.. ---> System.InsufficientMemoryException: Memory gates checking failed because the free memory (164065280 bytes) is less than 5% of total memory.  As a result, the service will not be available for incoming requests.  To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.

Then I added the below code to my service's web.config file.

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="1" />

This element should be placed in <system.serviceModel>

6
votes

i'm working over WCF and it worked fine on localhost.After i placed it to the production server, it thows me an exception "The requested service, 'http://global-kazway.kz/Service1.svc' could not be activated. See the server's diagnostic trace logs for more information"

This MSDN article describes how to configure tracing on the server. Once you've done that you can look at the server's diagnostic trace logs, and will likely find the problem.

2
votes

I was able to resolve the issue by following below steps using Visual Studio 2013:

  1. Go to your project folder where you have your *.svc file
  2. Right Click *.svc file --> View in browser
  3. Validate if you are able to browse the service

enter image description here

  1. Go to your project folder where you have your app.config file or where you want to consume the service.
  2. Right click project-->Add-->Service Reference
  3. Click Discover-->Under Services Select Service-->Give desired name to your service reference-->Click OK
  4. It will create "ServiceReference1" under the folder "Service References" & automatically create/update app.config file

enter image description here

2
votes

First thing take the service url address(e.g. http://youservice:808/Area.Service/Service.svc) and put it into browser url field to check whether the service is running.

In my case it wasn't running.

The remote server had a process running that used a lot or CPU and RAM (sql process)

This was blocking the service.

By closing/stopping some processes in Task Manager on remote server recovered the service.

2
votes

To have a more detailed description of the error please insert this code in your web.config file of the service:-

  <serviceBehaviors>
    <behavior name="MyServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>

Then use this service behavior in your service like this :-

<service name="MyService" behaviorConfiguration="MyServiceBehavior" >
        <endpoint address="" binding="basicHttpBinding"  xxxx="" xxxxx="" xxxxx="" xxxx="" xxxx="" />
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
        <host>
          <baseAddresses>
            <add baseAddress="http://ServerAddress:AnyPortIfspecified/VirtualDirname"/>
          </baseAddresses>
        </host>
      </service>

This will give you a detailed description of the error.

The second thing that you may try is check this:-

<host>
        <baseAddresses>
          <add baseAddress="http://ServerAddress:AnyPortIf specified/VirtualDir name"/>
        </baseAddresses>
      </host>

make sure your base address is not localhost. TC

0
votes

In addition to the accepted answer, I visited the exact URL where the Service.svc mapped in URL.

From there you can see the detailed issue, on my case this is the error:

enter image description here

Looking at the issue, I have the correct configuration on my web.config file, but I noticed that it is looking for the assembly, from there, I figured out that I haven't reference the Service Contract project including Service Implementation and Data Access Layer assembly.