HTTP Bad Request error when requesting a WCF service contract

前端 未结 5 1097
攒了一身酷
攒了一身酷 2020-12-10 04:01

I have a WCF service with the following configuration:


    
        
            

        
5条回答
  •  醉梦人生
    2020-12-10 04:33

    I think I found out what the problem is.

    If I browse to the URL:

    http://localhost/myservice/contract

    with the WcfTestClient application I can successfully retrieve the service metadata.
    So the error really only occurs when I request the URL through a web browser.

    The HTTP Bad Request error comes from the fact that the browser issues an HTTP GET request where the contents of the message are in the HTTP headers, and the body is empty.
    This is exactly what the WCF mexHttpBinding is complaining about!

    In order to get to the service contract via a web browser you will have to explicitly enable it in the service behavior:

    
        
            
        
    
    

    The URL to request becomes then:

    http://localhost/myservice?wsdl

    So, it turns out I was a little too quick in posting this question. However, I'll keep it anyway just for the record.

提交回复
热议问题