CompanyDroneFromSector7G
CompanyDroneFromSector7G

Reputation: 4517

WCF Configuration error

There are several similar posts out there on the web, but none of them seem to work for me!

I have a WCF webservice which I can't consume with my C# project, as it gives me this error:

There was an error downloading 'http://localhost:1940/MyService.svc/_vti_bin/Listdata.svc/$metadata' the request failed with HTTP status 404: Not Found. Metadata contains a reference that cannot be resolved: 'http://localhost:1940/MyService.svc'. The remote server returned an error: (405) Method Not Allowed.

I have already added the service reference but when I try to update I get this error.

Calling either of the URLs in the error gives me a 404.

The code is working fine on a server but doesn't work locally. However I need to add a function.

The config from the server seems the same except it uses the full namespaced contract and class names, however this doesn't work for me when I try it in my local project.

The ServiceModel part of the config looks like this:

<system.serviceModel>
    <services>
      <service name="MyService">
        <endpoint address="" binding="basicHttpBinding" contract="IMyService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Are there any glaring errors here? This targets .NET 3.5

I have tried different variations of the service name, with the full namespace and without, with the interface name and the classname, or both (as shown here).

All the suggestions I have found so far are different, and none seem to work.

Would be grateful for any help!

[Edit]

There is no obvious reason I can see why this doesn't work.

I'm going to sleep all weekend and come back to it on Monday!

Have a good one all.

[/Edit]

Upvotes: 0

Views: 944

Answers (3)

Lakmal
Lakmal

Reputation: 918

comment the <remove name="Documentation"/> or key's inside <webServices> in your web.config file

<webServices>
      <protocols>
        <!--<remove name="Documentation"/>-->
      </protocols>
    </webServices>

Upvotes: 1

CompanyDroneFromSector7G
CompanyDroneFromSector7G

Reputation: 4517

I started a new project, pasted in the code from the old one, all worked fine.

Same config as the first.

If I had time I would love to work out what the differences between the 2 are, but for now I'm just glad it works!

Upvotes: 0

peinearydevelopment
peinearydevelopment

Reputation: 11474

Its hard to tell based on what you have posted. But it looks like you are missing binding information:

<bindings>
            <basicHttpBinding>
                <binding name="basicHttpDefaultBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
                    <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxDepth="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <security mode="None">
                        <transport clientCredentialType="None" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>

and then update

<endpoint address="" binding="basicHttpBinding" contract="IMyService" />

to this

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpDefaultBinding" contract="IMyService" />

Upvotes: 0

Related Questions