views:

145

answers:

2

I have a simple console application which runs as a WCF service host. bsicHttpBinding is used. When I try to get the service reference in my client ( another console app) I get this error

"There was an error downloading http:// localhost:9999/TS. The request failed with HTTP status 400: Bad Request. Metadata contains a reference that cannot be resolved: 'http:// localhost:9999/TS'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:9999/TS. The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. If the service is defined in the current solution, try building the solution and adding the service reference again."

Please provide any pointers.

App.config:

<configuration>
    <system.serviceModel>
        <services>
            <service
                name="TimeServiceLibrary.TimeService"
                behaviorConfiguration="TSConfig">
                <endpoint address="localhost:9999/TS"
                    binding="basicHttpBinding"
                    contract="TimeServiceLibrary.ITime">
                </endpoint>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="TSConfig">
                    <serviceMetadata httpGetEnabled="True"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>
A: 

The error seems to suggest that it is attempting to use SOAP 1.2 over a wsHttpBinding instead, but I'm not certain why yet (must be a lack of coffee). It might help if you posted the relevant parts of your config file, or upload it somewhere if it's too large

When you browse to http://localhost:9999/TS/?WSDL, what do you get?

Do you have a mex endpoint (metadata exchange) configured? See here for an example configuration.

Thorarin
I get the same HTTP status 400 error on my browser.Not able to view my service metadata.
This is how my app.config looks like:<configuration> <system.serviceModel> <services> <service name="TimeServiceLibrary.TimeService" behaviorConfiguration="TSConfig"> <endpoint address="http://localhost:9999/TS" binding="basicHttpBinding" contract="TimeServiceLibrary.ITime"> </endpoint> </service> </services> <behaviors> <serviceBehaviors> <behavior name="TSConfig"> <serviceMetadata httpGetEnabled="True"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel></configuration>
So, no mex endpoint yet? I've added the config to your question for readability.
Thorarin
A: 

Well, the Basic HTTP binding uses SOAP 1.1 under the hood, which in turn uses a content-type of text/xml. The newer WS-HTTP binding uses SOAP 1.2, which uses a application/soap+xml content-type. WCF is complaining because it seems that your service is set up to use a Basic HTTP binding with a application/soap+xml content-type, which isn't going to work.

Maybe you could try adding http:// before localhost in the address, or just use TS for the address, and specify http://localhost:9999 in a Base Address element, e.g. inside the <service> element:

<baseAddress>
   <add baseAddress="http://localhost:9999/" />
</baseAddress>
Graham Clark