The request failed with HTTP status 404: Not Found

59,761

You got 404 response ,The 404 or Not Found error message is a HTTP standard response code indicating that the client was able to communicate with the server, but the server could not find what was requested.

Make sure that you have valid url, try to put your link in the browser and see if it is correct, if the url you requested have special headers There is a helpful extension on google chrome named PostMan that you can add the headers as you want and test the url

Share:
59,761
Admin
Author by

Admin

Updated on July 06, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to call the php soap web service from the .Net Client but I am getting the following error:

    System.Net.WebException was unhandled by user code
      Message="**The request failed with HTTP status 404: Not Found**."
      Source="System.Web.Services"
      StackTrace:
           at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
           at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
           at php_webservice_test_CS.WebReference.MyService.testServer() in c:\documents and settings\gdeshpande.parcdev.003\my documents\visual studio 2008\projects\php_webservice_test_cs\php_webservice_test_cs\web references\webreference\reference.cs:line 79
           at php_webservice_test_CS._Default.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\gdeshpande.PARCDEV.003\My Documents\Visual Studio 2008\Projects\php_webservice_test_CS\php_webservice_test_CS\Default.aspx.cs:line 23
           at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
           at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
           at System.Web.UI.Control.OnLoad(EventArgs e)
           at System.Web.UI.Control.LoadRecursive()
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      InnerException: 
    

    I am not able to get the issue is php Soap server side or the .Net client side. I am new to php.

    please help any one.

    Following is SOAP server code:

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

    following is SOAP .Net Client code:

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

    I would like to share my WSDL this is how it is...

    <wsdl:definitions xmlns:tns="http://10.20.1.161/api/soap/"
     targetNamespace="http://10.20.1.161/api/soap/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
     xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
     xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <wsdl:types>
      <s:schema targetNamespace="http://10.20.1.161/api/soap/">
    
       <s:complexType name="stringArray">
        <s:annotation>
         <s:documentation> A string array type </s:documentation>
        </s:annotation>
        <s:complexContent>
    
         <s:restriction base="soapenc:Array">
          <s:attribute ref="soapenc:arrayType" wsdl:arrayType="s:string[]"/>
         </s:restriction>
        </s:complexContent>
       </s:complexType>   
      </s:schema>
     </wsdl:types> 
    
     <wsdl:message name="reportRequest" />
    
     <wsdl:message name="reportResponse">
      <wsdl:part name="resParam" type="tns:stringArray"/>
    
     </wsdl:message> 
    
     <wsdl:portType name="MyPortType">
       <wsdl:operation name="testServer">
       <wsdl:documentation> Get a complex type object </wsdl:documentation>
        <wsdl:input message="tns:reportRequest"/>
        <wsdl:output message="tns:reportResponse"/>
      </wsdl:operation>
     </wsdl:portType>
    
    
     <wsdl:binding name="MyPortType" type="tns:MyPortType">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    
      <wsdl:operation name="testServer">
       <soap:operation soapAction="http://10.20.1.161/api/soap/testServer"/>
       <wsdl:input>
        <soap:body use="encoded" namespace="http://10.20.1.161/api/soap/"
         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
       </wsdl:input>
       <wsdl:output>
        <soap:body use="encoded" namespace="http://10.20.1.161/api/soap/"
         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    
       </wsdl:output>
      </wsdl:operation>
     </wsdl:binding>
    
     <wsdl:service name="MyService">
      <wsdl:port name="MyPortType" binding="tns:MyPortType">
       <soap:address location="http://10.20.1.161/api/soap/parc_web_servise.php"/>
      </wsdl:port>
     </wsdl:service>
    </wsdl:definitions>
    

    Please help..

    • Mike de Klerk
      Mike de Klerk over 11 years
      Can you actually view 10.20.1.161/api/soap/report.wsdl in your webbrowser? Is your php server running?
    • Pekka
      Pekka over 11 years
      404 not found is pretty clear, isn't it? Are you sure the URL is correct?
    • Rup
      Rup over 11 years
      Download the WSDL URL yourself in a browser. At the bottom will be the endpoint URL that your client will be trying to use. Can you see that URL - does it exist / work outside the SOAP request?
    • Admin
      Admin over 11 years
      hello Mike de Klerk, thanx for reply, -yes the url works fine in the web-browser, even while adding the refrence to the .net project no error is shown...when i make a call the error "http status 404' is displayed
    • Admin
      Admin over 11 years
      hi Rup, thanx for reply, how should I download the wsdl url, if it is using 10.20.1.161/api/soap/report.wsdl, then this is woking fine in the browser..
    • Rup
      Rup over 11 years
      Yes, that's what I meant: open 10.20.1.161/api/soap/report.wsdl in a browser and you should get an XML document. (You may have to 'view source'.) Look for an 'endpoint' element: this will be the URL that your .NET client is actually trying to use. Make sure that this URL looks correct and works. Alternatively you can probably find this in the web service client properties in your .NET project.
    • Admin
      Admin over 11 years
      hi Rup, thanx, as you said I browsed the wsdl url and viewd the source but I could not find the 'endpoint' element in the XML. Is there any thing missing out with the WSDL, please reply.
    • Admin
      Admin over 11 years
      hi Peeka, thanx for reply, '404 not found' as I googled says that server connectin is available but resource not found. but WSDL url works fine. Is there any thign missing out of the WSDL. please reply.
    • Rup
      Rup over 11 years
      Right - I meant the <soap:address> tag. (I thought it was called <soap:endpoint> sorry.) Does the URL there work? http://10.20.1.161/api/soap/parc_web_servise.php There's a spelling error there: it ought to be 'service' with a 'c', but as long as the server has the same spelling that's OK.
    • Admin
      Admin over 11 years
      hi Rup, Thanx for reply, it was good one that you pointed out the spelling mistake 'service' with a 'c' instead of 's' in it. Thanx a lot for the solution, rest is working fine. once again thank you Rup.
  • Admin
    Admin over 11 years
    hi Omar Freewan, Thanks for your reply, link in the browser is fine and have no special headers included...
  • Ankursonikajen
    Ankursonikajen about 6 years
    Restart your machine then.