I'm in a delicate situation: As the title suggests, I can't seem to connect to a WCF service I wrapped up in a Windows Service. I followed the tutorial http://msdn.microsoft.com/en-us/library/ms733069%28v=vs.110%29.aspx every step and got it to work multiple times in this exact way, just not for one particular project. I really don't know what it is, I have a very simple interface with just one method as contract, my service is installed just fine and also starts just fine. Once I try to add a service reference in another project I get an error 400, Bad Request, and a metadata problem.
I even rewrote the prototype project (it's basically the same project with less code in the implementation of the contract; but we're talking still below 300 lines of code) which ran perfectly fine, and came to the same error. I didn't change any of the app.config
code when I did that, and I could connect before, but bad request afterwards.
What adds to the problem is that I can't post any code here (I'm working on a VM at work where I don't have internet access, plus the internet access I actually do have on the physical machine is so restricted I can't open any kind of board/forum/blog/whatever, so I can't post exact errors). Since all my minimal examples do work, my "minimal not working example" would be the total code anyway.
I'm at a total loss here. I dug through all the other topics of the bad request error and have some more checking to do tomorrow, but I thought I'd rather just post here and maybe get some advice on what/how to further test my project for errors.
Just in case it helps, the app.config
is the same as the following except for the service and contract names:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel> <services>
<!-- This section is optional with the new configuration model
introduced in .NET Framework 4. -->
<service name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/ServiceModelSamples/service"/>
</baseAddresses>
</host>
<!-- this endpoint is exposed at the base address provided by host: http://localhost:8000/ServiceModelSamples/service -->
<endpoint address=""
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<!-- the mex endpoint is exposed at http://localhost:8000/ServiceModelSamples/service/mex -->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
What could possibly make three attempts from scratch work, but the 4th not work again where the only difference is the size of the files and 2 added helper classes which are not doing anything else? I mean, the service has to be there, otherwise I'd get a 404 Not Found error instead, but something's wrong with the metadata although I'm using the exact(!) same app.config
in another try and there it works.
Any suggestions/hints are greatly appreciated. I'll surely try increasing the buffer sizes in the binding tomorrow, I heard that helped some people, but I don't know about me there since I'm not really sending anything yet, am I? I'm just trying to add the service reference, I don't know if the size matters there. I also already tried TCP and basicHTTP bindings to the same result.
Thanks in advance and sorry for the wall of text; I got very frustrated at work today, with not even being able to research the error properly due to those stupid work conditions, and that frustration came up again writing this... ;)
See Question&Answers more detail:
os