none
“The resource you are looking for (or one of its dependencies)” error WCF REST RRS feed

  • Question

  • I have a RESTful service that doesn't work, despite I verify all the code: web.config, the Iservic and the implementation: IServiceImport:

     namespace SysLap.Services.Web.ImportAutoLiasse
    {
     [ServiceContract]
    public interface IServiceImportAutoLiasse
    {
        [OperationContract]
        [WebGet]
        string GetData(int value);   
    }
    }


    ServiceImport.svc.cs:

    namespace SysLap.Services.Web.ImportAutoLiasse
     {
       public class ServiceImportAutoLiasse: IServiceImportAutoLiasse
       {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
       }
     }

    Web.config:

    <services>
      <!--SOAP-->
      <service behaviorConfiguration="ServBehavior" name="SysLap.Services.Web.ImportAutoLiasse.ServiceImportAutoLiasse">
        <endpoint address="soap" binding="basicHttpBinding" bindingConfiguration=""
          contract="SysLap.Services.Web.ImportAutoLiasse.IServiceImportAutoLiasse" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
    
        <!--REST-->
        <endpoint address="rest" behaviorConfiguration="restBehavior"
          binding="webHttpBinding" bindingConfiguration="" contract="SysLap.Services.Web.ImportAutoLiasse.IServiceImportAutoLiasse" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="restBehavior">
          <webHttp helpEnabled="true" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="ServBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    When I test SOAP, it works well, but if I test the wcf REST, I have this error :

    HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, 
     had its name changed, or is temporarily unavailable.  Please review the following URL and make sure 
     that it is spelled correctly.


    How can I fix it ? Thanks,


    Friday, December 13, 2019 8:45 AM

Answers

  • Hi,
    Rest style service only works over HTTP protocol, instead of HTTPS. Thereby, the URL in the browser bar should be HTTP form

    http://localhost:44355/ServiceImportAutoLiasse.svc/rest/GetData?value=19


    In order to work over HTTPS, we need to configure an extra service endpoint over HTTPS.

    <services>
          <service name="WcfService1.Service1" behaviorConfiguration="myb">
            <endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IService1"></endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
            <endpoint address="rest" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="restbeh"></endpoint>
          <endpoint address="rest" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="restbeh" bindingConfiguration="httpsbinding"></endpoint>
          </service>
        </services>
        <bindings>
          <webHttpBinding>
            <binding name="httpsbinding">
              <security mode="Transport">
                <transport clientCredentialType="None"></transport>
              </security>
            </binding>
          </webHttpBinding>
    </bindings>


    Feel free to let me know if the problem still exists.

    Best Regards

    Abraham

    • Marked as answer by Thabetidris Tuesday, December 17, 2019 1:54 PM
    Monday, December 16, 2019 1:54 AM
    Moderator

All replies

  • Hi,
    It seems to me there is no problem in your code. On my side, I try to reproduce your issue, but it works properly, here is my example, wish it is useful to you. 
    IService1.cs

    namespace WcfService1
    {
        [ServiceContract]
        public interface IService1
        {
            [OperationContract]
            [WebGet]
            string GetData(string value);
    }}


    Serivce1.svc

            public string GetData(string value)
            {
                return $"Hello, {value}";
    
            }


    Webconfig

    <system.serviceModel>
        <services>
          <service name="WcfService1.Service1" behaviorConfiguration="myb">
            <endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IService1"></endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
            <endpoint address="rest" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="rest"></endpoint>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="myb">
              <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior name="rest">
              <webHttp helpEnabled="true"/>
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>


    Restful call.
    https://i.stack.imgur.com/A8Fn8.png
    SOAP call.

    https://i.stack.imgur.com/Ep7oU.png

    Code

    ServiceReference1.Service1Client client = new Service1Client();
                Console.WriteLine(client.GetData("34"));
    

       

    App.config.

    <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_IService1" />
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://10.157.13.69:8864/Service1.svc/soap"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
                    contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
            </client>
    </system.serviceModel>


    Feel free to let me know if there is anything I can help with.
    Best Regards
    Abraham

                
    Friday, December 13, 2019 10:49 AM
    Moderator
  • Thanks for your reply,

    it's very weird! I re test it , always it works with SOAP :

    but with the restful call I get error:

    Friday, December 13, 2019 10:58 AM
  • I get also these information for the error when I use POSTMAN:

    [EndpointNotFoundException]: There was no channel actively listening at &#39;https://localhost:44355/ServiceImportAutoLiasse.svc/rest/GetData?value=19&#39;. This is often caused by an incorrect address URI. Ensure that the address to which the message is sent matches an address on which a service is listening.
        at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
        at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
        at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
    [HttpException]: There was no channel actively listening at &#39;https://localhost:44355/ServiceImportAutoLiasse.svc/rest/GetData?value=19&#39;. This is often caused by an incorrect address URI. Ensure that the address to which the message is sent matches an address on which a service is listening.
        at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
        at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
        at System.ServiceModel.Activation.ServiceHttpHandlerFactory.ServiceHttpHandler.EndProcessRequest(IAsyncResult result)
        at System.Web.HttpApplication.CallHandlerExecutionStep.InvokeEndHandler(IAsyncResult ar)
        at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)

    Friday, December 13, 2019 1:28 PM
  • Hi,
    Rest style service only works over HTTP protocol, instead of HTTPS. Thereby, the URL in the browser bar should be HTTP form

    http://localhost:44355/ServiceImportAutoLiasse.svc/rest/GetData?value=19


    In order to work over HTTPS, we need to configure an extra service endpoint over HTTPS.

    <services>
          <service name="WcfService1.Service1" behaviorConfiguration="myb">
            <endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IService1"></endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
            <endpoint address="rest" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="restbeh"></endpoint>
          <endpoint address="rest" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="restbeh" bindingConfiguration="httpsbinding"></endpoint>
          </service>
        </services>
        <bindings>
          <webHttpBinding>
            <binding name="httpsbinding">
              <security mode="Transport">
                <transport clientCredentialType="None"></transport>
              </security>
            </binding>
          </webHttpBinding>
    </bindings>


    Feel free to let me know if the problem still exists.

    Best Regards

    Abraham

    • Marked as answer by Thabetidris Tuesday, December 17, 2019 1:54 PM
    Monday, December 16, 2019 1:54 AM
    Moderator