Can't Activate WCF service

后端 未结 7 1624
甜味超标
甜味超标 2020-12-16 10:05

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, \'htt

相关标签:
7条回答
  • 2020-12-16 10:37

    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.

    0 讨论(0)
  • 2020-12-16 10:46

    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 讨论(0)
  • 2020-12-16 10:48

    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>

    0 讨论(0)
  • 2020-12-16 10:51

    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.

    0 讨论(0)
  • 2020-12-16 10:57

    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.

    0 讨论(0)
  • 2020-12-16 10:57

    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

    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

    0 讨论(0)
提交回复
热议问题