IIS hosted WCF Service return HTTP 400 Bad Request

前端 未结 4 437
醉酒成梦
醉酒成梦 2021-01-02 00:58

I have been searching for hours, but I could not find the solution. I will explain briefly.

I am learning WCF Services. I have just created a service and browse it.

相关标签:
4条回答
  • 2021-01-02 01:31

    According my searches I should not provide an address.

    msdn.microsoft.com/en-us/library/aa751792(v=vs.110).aspx

    You must always use relative endpoint addresses for IIS-hosted service endpoints. Supplying a fully-qualified endpoint address (for example, localhost/MyService.svc) can lead to errors in the deployment of the service if the endpoint address does not point to the IIS-application that hosts the service exposing the endpoint. Using relative endpoint addresses for hosted services avoids these potential conflicts.

    0 讨论(0)
  • 2021-01-02 01:33

    I think this will solve your problem:

    Add this endpoint to your service:

    <endpoint address="mex" binding="mexHttpBinding" 
        bindingConfiguration="" contract="IMetadataExchange" />
    

    And change the name attribute of the service to your service class's full name:

    <service behaviorConfiguration="EmployeeServiceBehaviour" 
        name="Namespace.EmployeeConfigurationClass">
    

    Hope that is enough

    0 讨论(0)
  • 2021-01-02 01:47

    You can try fiddler and also try the svcTracer which may give you lot of debugging information on the top of it you can also use includeExceptionDetailInFaults=true flag on the server but its important to flag that its not always right to send this information to the client specially if client is an external entity. With this warning following is the hint how to use it.

    <serviceBehaviors>
        <behavior name="ServiceBehavior">
        ....
            <serviceDebug includeExceptionDetailInFaults="true" />
        ....
        </behavior>
    </serviceBehaviors>
    

    Happy debugging :)

    0 讨论(0)
  • 2021-01-02 01:53

    This may be of help. ive just spent over 2 hours trying to get this working. i use FF and its set as the default browser.

    in FF it was adding a / on the end of my URL

    http://services.tester.dev/VehicleFeedService.svc/
    

    which returned a NetworkError: 400 Bad Request

    however in IE or chrome, it doesnt put the / on the end and it works fine.

    one thing to note.. even in FF which was giving me a 400 bad request, the ?wdsl did work

    http://services.tester.dev/VehicleFeedService.svc?wsdl
    

    it appears that the / was causing the issue

    0 讨论(0)
提交回复
热议问题