The request failed with HTTP status 404: Not Found

The request failed with HTTP status 404: Not Found

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

The request failed with HTTP status 404: Not Found

When debugging SOAP integrations between PHP and .NET, a System.Net.WebException with an HTTP 404 status code is often the most misleading error you can encounter. It screams "resource not found," but in the context of a SOAP handshake, it almost never means your WSDL file is missing or your endpoint URL is typed incorrectly. Instead, it usually points to a fundamental mismatch in how the request is being routed versus how the server expects to handle it.

Looking at the PHP server code provided:

ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("http://10.20.1.161/api/soap/report.wsdl");
$server->addFunction("testServer");
$server->handle();

The logic here attempts to instantiate a SoapServer using a URL pointing directly to a .wsdl file (report.wsdl). However, the PHP SoapServer constructor does not automatically fetch and parse remote WSDL documents in the way you might expect. When you pass a URL string to the constructor without explicitly fetching the document content first, or if the server expects to serve the WSDL at that specific path but the request hits a different handler, the framework may respond with a 404 before it ever attempts to instantiate the testServer function.

The root cause here is likely how the PHP application is deployed. The URL passed to the constructor points to report.wsdl, but the WSDL definition itself declares the service endpoint (the actual PHP script handling the SOAP requests) at a different location: http://10.20.1.161/api/soap/parc_web_servise.php.

In a standard PHP environment, if you configure SoapServer with a URL that doesn't correspond to an existing file or a valid internal resource handler, the framework might fail to initialize properly or return an error. More critically, if the PHP script is configured to only handle .php requests and not serve static files like .wsdl from the same directory structure without specific configuration (like mod_rewrite rules in Apache), accessing that WSDL URL directly can result in a 404.

The correct approach for a remote WSDL is to ensure the PHP script explicitly fetches and parses the document, or better yet, define the WSDL content within the PHP file itself using SoapServer::setClass or by reading from an existing local .wsdl file if it's available on the server.

Furthermore, examine the binding configuration in the WSDL:

<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

This declares an RPC-style binding. While modern .NET clients often default to Document/Literal style with a different SOAP action handling mechanism, the client code shown relies on auto-generated proxies (MyService ms = new MyService()). These proxies are generated based on the WSDL. If the .wsdl file is not being served correctly (hence the 404), the proxy generation step likely failed or was configured with stale data, causing the runtime to fail when attempting to invoke testServer.

The specific error occurs in the .NET client's Page_Load event:

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        MyService ms = new MyService(); 
        Object ac = ms.testServer();
        // ...
    }
    catch (Exception ae)
    {
        Response.Write(ae);
    }
}

The line Object ac = ms.testServer(); is the invocation point. The .Net client attempts to send a request to the location defined in the WSDL (parc_web_servise.php). However, the stack trace indicates the failure happens during the initial read of the response or setup. If the PHP server is configured to only serve the application at /api/soap/ and does not have a route for /api/soap/report.wsdl, the request to load that WSDL fails with 404.

Recommendation:

  1. Serve the WSDL Locally or via Correct Routing: Ensure that http://10.20.1.161/api/soap/report.wsdl actually resolves to a valid file or a controller that serves the XML content. If you are using Laravel, for example, you would need to ensure routes are configured to serve static assets or specific API responses correctly.
  2. Fetch WSDL Content: Modify the PHP server code to read the WSDL from a local file and pass it as a string to SoapServer, rather than relying on a remote URL fetch that might be blocked or misrouted.
  3. Verify Endpoint Consistency: Ensure the soap:address in the WSDL matches exactly where your PHP script is deployed. The mismatch between the WSDL location (report.wsdl) and the service endpoint (parc_web_servise.php) suggests a routing configuration issue on the server side.

For more robust API development and modern SOAP handling, consider migrating to RESTful services using libraries like Laravel Sanctum or standard Laravel endpoints if your project allows it, as they offer clearer error responses and easier debugging compared to legacy SOAP implementations.

Our network