Question

I have created a new IIS hosts WCF service using the webHttpBinding which is currently running on on IIS Express on my development machine and when I try to "Add Service Reference" the service is correctly built and the Reference.cs file looks fine but the web.config or app.config files are not being updated.

No warnings or error messages are received.

Both the service and the client are targeting .Net 4.5.

Service config

  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webInteropSecureBinding" allowCookies="false" maxBufferPoolSize="2097152" maxBufferSize="2097152" maxReceivedMessageSize="2097152">
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    <services>
      <service name="PsmDataProvider.PsmProvider" behaviorConfiguration="SecureRest">
        <clear />
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="webInteropSecureBinding" name="PsmProvider" contract="PsmDataProvider.IPsmProvider" listenUriMode="Explicit" behaviorConfiguration="webHttpBehavior" />
        <endpoint address="mex" binding="mexHttpsBinding" name="mex" contract="IMetadataExchange" listenUriMode="Explicit" />
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:44300/PsmProvider/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SecureRest">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webHttpBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

Client Config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
</configuration>

Client Service Reference

enter image description here

Following some investigation I found these StackOverflow questions

Question 1

Question 2

Question 3

And this post

Blog post

Each of the above refer to the same problem of unticking the "Reuse types in references assemblies" flag which I have done.

enter image description here

The problem is it did not fix the issue. I have tried updating and deleting and recreating the service reference but it never updates the config file.

Question

Is this a problem with the server side configuration? Or is this an issue with the client side? How to I change either so that the proxy generation works as expected?

Was it helpful?

Solution

OK, looks like there are issues in adding a service reference to services that implement the WebHttpBinding WCF binding.

This is discussed in Carlos Figueira Blog Post

OTHER TIPS

Remove maxBufferPoolSize="2097152" maxBufferSize="2097152" from your web.config file. Then try to update your service. Make sure your Bindings are correctly mentioned.

I had the same problem again today with VS2012.

I have a set of Test, PreProduction and Production web.config configurations, I could use "Preview transformation", and see that VS2012 was patching my "web.config" with the relevant settings..

Preview

...but... when I deployed, well, it just seemed to include the default "web.config" file without any changes.

The cause was that VS2012 seemed to have messed up its configurations, and in the Publish dialog, suddenly my PreProduction configuration was associated with Debug. Huh ?

Publish

Changing this from "Debug" to "PreProduction" fixed the issue for me.

Or, at least, it nudged me a step forward, but I'm still having an issues with VS2012 messing up my configuration names when it tries to deploy.

Deploy

(Depressed sigh.)

Currently downloading VS2013. Hopefully, this release will be less buggy.

In my case, it was caused by I set a binding parameter wrong on the web service side.

binding.ReliableSession.InactivityTimeout = TimeSpan.Maximum;

After set this to System.TimeSpan(0, 10, 0); the binding configuration is generated in web.config file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top