0

Hej,

I feel like a complete idiot but I don't seem to find an answer.

I'm selfhosting a WCF service in a console application. This is working like a charm, I've done it a million times :)

Consuming this service from another console application or by using wcftestclient is no problem at all.

But when trying to browse to the service I get "strange" behavior.

The service is hosted at http://localhost:50666/MyService.Foo/BarServiceHttp (with base-address http://localhost:50666/MyService.Foo).

So when browsing to http://localhost:50666/MyService.Foo/BarServiceHttp does return a HTTP 400 error in the browser.

Browsing to the base-address gives the output that I expected at the full address.

What's going on? (The space after the http was inserted to bypass the warning concerning localhost...)

Here is the server config:

<service name="FooService" behaviorConfiguration="FooBarServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:50666/MyService.Foo" />
      </baseAddresses>
    </host>

    <endpoint address="BarServiceHttp"
              binding="basicHttpBinding"
              bindingConfiguration="basicHttpBindingConfiguration"
              contract="IBarService" />
    <endpoint address="BarServiceHttp/mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange" />
</service>



<behavior name="FooBarServiceBehavior">
  <!-- Enable MEX http get for this service. -->
  <serviceMetadata httpGetEnabled="true"/>
  <serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • @CodeCaster That setting is not available on the binding configuration. It is set on my service behavior config though, I've excluded it, will adjust server config in question. – Dwight Matthys Oct 04 '12 at 14:02

1 Answers1

0

You are getting an HTTP 400 error because you are trying to access an endpoint directly. The endpoint expects SOAP request, but instead browser sends HTTP GET request, which can't be handled by the endpoint. You should use base address when browsing the service, since the metadata and the help page, that you see in the browser, live here:

http://localhost:50666/MyService.Foo
Yuriy
  • 388
  • 1
  • 3
  • 8