.NET 4 WCF SOAP Service Http POST returns 404 NOT Found

I have a WCF-supported SOAP service that I can hit from a browser, as well as from my SOAP client when making HTTP GET requests, however, when making any HTTP POST requests, the response is 404 Not Found.

My Web.config looks like this:

<system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" /> <bindings> <wsHttpBinding> <binding> <security mode="Transport"> <transport clientCredentialType="Certificate" /> </security> <readerQuotas maxDepth="15" maxStringContentLength="524288" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </binding> </wsHttpBinding> <basicHttpBinding> <binding> <readerQuotas maxDepth="15" maxStringContentLength="524288" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </binding> </basicHttpBinding> </bindings> </system.serviceModel> 

My service is defined in markup using a .svc file as:

 <%@ ServiceHost Language="C#" Debug="true" Service="Boca.WebServices.Billing.QBService" CodeBehind="QBService.svc.cs" %> 

Again, I can use my service using a browser and a SOAP client, as follows, using HTTP GET, but not with HTTP POST:

What am I doing wrong? Should I use .svc markup and just define my service in Web.config?

UPDATE:

When I "start debugging" my WCF project from VS 2010 using IIS Express on the localhost port: 8181, HTTP POSTS for the service to work. This is only when the service is hosted through IIS, the HTTP POST for the service is rejected or not found.

+6
source share
2 answers

I solved the problem. After all, this is not an IIS problem, but a problem with the fact that I did not configure <basicHttpBinding> on the <security> node. I did not read about bindings and how they work, so I thought that adding <wsHttpBinding> along with <basicHttpBinding> would add SSL support for WCF.

Doing this and setting up the default <wsHttpBinding> using the <security> node definitely allowed me to safely obtain SOAP metadata, although internally they still used <basicHttpBinding> , but POST was not supported.

I updated my configuration so that the transport clientCredentialType set to None and this fixes the problem:

 <bindings> <basicHttpBinding> <binding name="QBService_BasicHttpBinding"> <security mode="Transport"> <transport clientCredentialType="None" /> </security> <readerQuotas maxDepth="15" maxStringContentLength="524288" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </binding> </basicHttpBinding> </bindings> 
+7
source

Assuming you are using .NET 4, your service will listen on one or more endpoints using basicHttpBinding - this is the default if you do not specify an endpoint when using HTTP

If you have only one service contract, your service will listen for HTTP POST at the address ending with .svc. If you have more than one service contract, it places each contract at an address, for example <path to .svc>/<serviceContractname>

The service is waiting for a SOAP request, so you will need a POST XML document that conforms to SOAP 1.1 (by default, this is the base HTTPBinding). The easiest way to achieve this is to create a proxy server using the Add Service Reference in the client project and make calls through the generated proxy class - WCF plumbing will generate the corresponding message and send it to the service

+2
source

Source: https://habr.com/ru/post/892444/


All Articles