0

I have a wcf service that I tried to add using both svcutil and by adding service reference to the client test project. In both cases a new config file was not created and subsequently the client test will not run due to it not seeing the endpoints. Why is this the case and here is my web.config file for the WCF service.

<?xml version="1.0"?>
<configuration>

<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
  <webHttpBinding>
    <binding name="webHttpBinding" crossDomainScriptAccessEnabled="true" />
  </webHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="webHttpBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
 <service behaviorConfiguration="webHttpBehavior" name="WcfInstanceRules2.Service1">
    <endpoint address="" 
    binding="webHttpBinding" bindingConfiguration="webHttpBinding"   
    contract="WcfInstanceRules2.IService1" 
    behaviorConfiguration="web"/>
  </service>
</services>

vbNewbie
  • 3,291
  • 15
  • 71
  • 155
  • Might be obvious, but do you have an existing config file in your client app? I'd also give your bindingConfiguration a different name than the binding name ex: bindingConfiguration="webHttpBindingConfiguration" – Mark B Aug 13 '12 at 16:49
  • yes there is an existing web.config file in the client. I will change the bindingconfi name – vbNewbie Aug 13 '12 at 16:58
  • Consuming your service shouldn't create a new config file though. It should just add a client node to your existing file. Again, that might be obvious, but your OP suggests you're looking for a file to be created upon consumption. – Mark B Aug 13 '12 at 19:42
  • i got this from the tutorial used to create a WCF that a new config file should be produced. however there is also no addition of a client node to the original config file. – vbNewbie Aug 14 '12 at 12:57

1 Answers1

1

If you're using the webHttpBinding then you're writing a RESTful service, right? REST services aren't "consumed" via Visual studio or via SvcUtil.exe like other SOAP based services (for example, that would use a SOAP based binding like basicHttpBinding, or wsHttpBinding etc). You would "consume" the service by calling it from something like jQuery:

$.getJSON("Service1.svc/uriTemplateNameHere", { param: myParameter },
            function (result) {
                // do something
            });

Can you post your WCF code?

Mark B
  • 1,166
  • 1
  • 19
  • 31
  • thanks for your response. So I understand that I need to change my config file to suit REST services and call this service through jQuery. – vbNewbie Aug 16 '12 at 16:37
  • Your config is already set for a RESTful service and it looks valid. Based on your config file, I'd have to assume the whole tutorial you're following is for creating a RESTful service. The key here is that you're not going to consume this service via Visual Studio (VS uses SvcUtil.exe internally) because it's not a SOAP based service. If your service is using HTTP GET and returning JSON, you can just browse to it and see the return values as a JSON string. – Mark B Aug 16 '12 at 19:40