I use the following method to get something from a web service using HTTPWebRequest:
private void RetrieveSourceCode(Method method) { try { String url = "http://123.123.123.123:8080/"; CredentialCache myCache = new CredentialCache(); myCache.Add(new Uri(url), "Basic", new NetworkCredential("user", "pwd")); HttpWebRequest request =(HttpWebRequest)WebRequest.Create("http://abc.abc.ch:8080/famixParser/projects/argouml/org.argouml.uml.ui.behavior.common_behavior.ActionAddSendActionSignal.doIt(java.util.Collection)"); Console.WriteLine(request.RequestUri.ToString()); request.Credentials = myCache; request.Accept = "text/plain"; HttpWebResponse response; try { response = (HttpWebResponse)request.GetResponse(); } catch (Exception e) { Console.WriteLine("exception when sending query: "); throw e; } Stream resStream = response.GetResponseStream(); byte[] buf = new byte[8192]; StringBuilder sb = new StringBuilder(); string tempString = null; int count = 0; do {
Now I always get exception 401 - Access denied. I do not know why, because if I use the same URL in my web browser, it works. Maybe it's because of the brackets?
Please note: I changed the server address here, so it does not work here, but I had to do this for privacy reasons.
anon
source share