By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

HttpWebRequest webRequest error 404 java.io.FileNotFoundException

P: 1
Hello

I've been trying to consume webservice with the following code, but get error 404, I can access the wsdl from the browser, any help would be very important.


Expand|Select|Wrap|Line Numbers
  1. public class SendFiles
  2.     {
  3.         public string Execute(String envelope, String uri)
  4.         {
  5.             try
  6.             {
  7.  
  8.                 HttpWebRequest request = CreateWebRequest(uri);
  9.  
  10.                 XmlDocument soapEnvelopeXml = new XmlDocument();
  11.                 soapEnvelopeXml.LoadXml(envelope);
  12.                 using (Stream stream = request.GetRequestStream())
  13.                 {
  14.                     soapEnvelopeXml.Save(stream);
  15.                 }
  16.  
  17.                 using (WebResponse response = request.GetResponse())
  18.                 {
  19.                     using (StreamReader rd = new StreamReader(response.GetResponseStream()))
  20.                     {
  21.                         string soapResult = rd.ReadToEnd();
  22.                         return soapResult;
  23.                     }
  24.                 }
  25.             }
  26.             catch (WebException e)
  27.             {
  28.                 string pageContent = new StreamReader(e.Response.GetResponseStream()).ReadToEnd().ToString();
  29.                 return pageContent;
  30.             }
  31.         }
  32.         /// <summary>
  33.         /// Create a soap webrequest to [url]
  34.         /// </summary>
  35.         /// <returns></returns>
  36.         public HttpWebRequest CreateWebRequest( string _uri)
  37.         {
  38.             Uri uri = new Uri(_uri);
  39.             HttpWebRequest webRequest = (HttpWebRequest)WebRequest.CreateDefault(uri);
  40.             webRequest.Headers.Add(@"SOAPAction:");
  41.             //webRequest.Headers.Add(@"Host:192.168.9.81:9080");
  42.             webRequest.Accept = "gzip,deflate";//text/xml";
  43.             webRequest.ContentType = "text/xml;charset=utf-8";                        
  44.             webRequest.Method = "POST";
  45.             webRequest.KeepAlive = true;
  46.             webRequest.UserAgent = "Test Client";
  47.             //webRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36";
  48.             //webRequest.Timeout = 100000;
  49.  
  50.  
  51.             return webRequest;
  52.         }       
  53.  
  54.         static void Main(string[] args)
  55.         {
  56.             SendFiles s = new SendFiles();
  57.             Console.WriteLine(s.Execute("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://services.negocio.nexsys.com/'><soapenv:Header/><soapenv:Body><ser:solicitarToken><products><quantity>1</quantity><SKU>ABC-77777</SKU></products><clientInfo><address>PEDRO GILL 935 C/ YTORORO</address><city>Lambare</city><country>PARAGUAY</country><email>info@analitica.com.py</email><name>ANALITICA S.A.</name><nit>800459652</nit><phoneNumber>908555</phoneNumber><state>CENTRAL</state></clientInfo><resellerInfo><address>AVENIDA MARISCAL LOPEZ 3794</address><city>ASUNCION</city><country>PARAGUAY</country><email>ester@iss.com.py</email><name>INFORMATION SECURITY SERVICES S.A.</name><nit>80051400-9</nit><phoneNumber>6207768</phoneNumber><resellerId>80051400-9_null_Etail</resellerId><state>CENTRAL</state></resellerInfo><poNumber>PC-00008355</poNumber><storeID>00003</storeID><countryCode>PY</countryCode></ser:solicitarToken></soapenv:Body></soapenv:Envelope>",
  58.                 "http://192.168.9.181:9080/IntegracionNexsysCO/NexsysIntegrationServicesService/NexsysIntegrationServicesService?wsdl"));
  59.  
  60.             Console.ReadLine();
  61.         }
  62.     }
Nov 4 '16 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,031
You get a JAVA error.
This is probably from the server you send a request to.

This server complains about finding what is requested (java.io.FileNotFoundException )

There is not enough info here to know why/what is not found.
Dec 17 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.