0

I created a restful/json web service that i can consume with my browser but not adding a service reference from a project: it fails with

EndpointNotFoundException: no endpoint listening on /.../GetDevicses, Inner exception: remote server not found (404).

One thing i think is important to notice is that in my browser i call uri .../Devices whereas EndpointNotFoundException seems to look for .../GetDevices.

My service exposes only one method:

[OperationContract]
[WebGet( RequestFormat = WebMessageFormat.Json, UriTemplate = "/Devices" )]
DeviceInfoRecord[] GetDevices();

Firewalls are disabled and since i can consume from browser i think service configuration is ok, but i'm not sure about client configuration.

Here is client configuration:

    <behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp defaultOutgoingResponseFormat="Json"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <client>
      <endpoint address="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary2/Service1/"
                name="Service1" binding="webHttpBinding"
                contract="ServiceReference1.IService" behaviorConfiguration="web" />
    </client>

  </system.serviceModel>

Here is server configuration:

<system.serviceModel>
    <services>

      <service name="WcfServiceLibrary2.Service1">
        <endpoint address="" binding="webHttpBinding" 
                  contract="WcfServiceLibrary2.IService" 
                  behaviorConfiguration="restfulBehavior">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="restfulBehavior">
          <webHttp defaultOutgoingResponseFormat="Json" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

I tried several suggested solutions with no luck so i hope some expert can help. Thanks.

6
  • Have you tried exposing meta endpoint to see if the service is up and running? Commented Dec 16, 2014 at 9:23
  • 1
    I think Restful service can not be consumed by adding service reference and using it. Commented Dec 16, 2014 at 9:24
  • I'm a newbie, not sure what you are talking about but i did remove 'mex' since i read metadata is not used in REST services. Anyway i'm sure the service is running since i can retrieve data through the browser Commented Dec 16, 2014 at 9:28
  • @JenishRabadiya can you please explain more? I think you spot the problem Commented Dec 16, 2014 at 9:34
  • 1
    REST services do not use proxies and you do not add a service reference to them. You use HttpClient or other similar HTTP oriented technologies to communicate with a REST service. SOAP services, on the other hand, do use proxies. Commented Dec 16, 2014 at 10:19

1 Answer 1

1

I am not sure about your requirement. But if you want to have proxy created for your service, then REST service will not provide what you want.

you must have to add endpoint something like "basicHttpBinding" to created proxy and use it in your code.

you can try adding end point and then try adding service serference

<endpoint address="" binding="basicHttpBinding" 
              contract="WcfServiceLibrary2.IService">

in this way your service can be exposed to two different endpoints. (Rest and Soap).

Sign up to request clarification or add additional context in comments.

2 Comments

OK, so there is not auto generated code for REST and i'm using code for basicHttpBinding. This is the problem. Is there any framework that can help?
@sam I don't have much Idea about that but I have heard about service stack but still not sure does that fulfill your requirement. You can have look here: servicestack.net/text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.