1

I have a .NET 4.0 WCF web service running on a Windows 2008 R2 server. I'm not in IT, but I know the server is behind both a firewall/router, and has some manner of URL rewriting rules in place.

From within the local network I can communicate with this web service fine. It works both when the web service url points directly to the server as well as when the url points to the router's address. I'm also able to generate a service reference using either of these ways.

From outside the local network, you can browse to the .scv in a web browser and you get the standard wcf service info page. But if I try to create a service reference using this url I get the error

There was an error downloading '[Web Service URL]/_vti_bin/ListData.svc/$metadata'. The request failed with HTTP status 400: Bad Request. Metadata contains a reference that cannot be resolved: '[Web Service URL]'. Content Type application/soap+xml; charset=utf-8 was not supported by service [Web Service URL]. 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.

Google tells me that content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8' often means the client and server bindings don't match, but it doesn't look like that's the problem, especially if it's not a consistent problem.

If I try to use the web service I get the generic error

The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error

Unfortunately, this issue only seems to happen on the production server, which limits my ability to play around with diagnostic tools.

What could cause a WCF basic http web service to be visible in a browser, but not work otherwise? Also, what would cause it to think it has mismatched bindings when reached through a different endpoint (URL rewriting?)

cost
  • 4,420
  • 8
  • 48
  • 80
  • are your server load balanced? what does your binding look like? can you paste it? and have you tried just using wcf test client to generate wsdl? – Bravo11 Feb 13 '15 at 21:43
  • @Bravo11 Which binding, client or server? – cost Feb 13 '15 at 21:53
  • @Bravo11 I don't have a defined server binding, it uses the default of basichttpbinding. I'm looking into defining it and seeing if that makes any difference – cost Feb 13 '15 at 22:58
  • ya you will need to add bindings, and please add mex binding that will help you expose your meta data – Bravo11 Feb 13 '15 at 23:02
  • @Bravo11 I have HttpGetEnabled set to true though, if I'm just generating a wsdl would I need a mex binding? – cost Feb 13 '15 at 23:20
  • yes, otherwise your metadata won't be exposed, which means you wont be able to create the proxy have a look here (http://stackoverflow.com/questions/2106637/what-is-mexhttpbinding) – Bravo11 Feb 14 '15 at 02:59
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/70892/discussion-between-bravo11-and-cost). – Bravo11 Feb 14 '15 at 03:01

1 Answers1

0

Add mex bindings as it will allow you to expose metadata and build proxy on client side

Have a look at this why you need mex bindings (What is "mexHttpBinding"?)

Community
  • 1
  • 1
Bravo11
  • 898
  • 2
  • 11
  • 24