remote server returned an error: (500) Internal Server Error.

Hi Frnds, I have Using HTTP Post Method ,Already create Webconfig fine

(  <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
    </webServices>

)

But i got  remote server returned an error: (500) Internal Server Error. i am not using SOAP..

 public void Post()
        {
            Uri serverUrl = new Uri(_targetURL);

            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(serverUrl); //"http://localhost:1445/eProcurement.NET.Web/OrderConf.text.aspx"

            webRequest.Method = "POST";

            UTF8Encoding encoding = new UTF8Encoding();

            //ASCIIEncoding

            if ((_value != null) || (_postMessage != null))
            {

                byte[] postBytes = null;
                Stream postStream = null;
                HttpWebResponse webResponse = null;
                Stream responseStream = null;


                string xmlBuffer = "";
                byte[] stringBuffer = new byte[50 * 1024];
                byte[] buffer = new byte[1024];
                int stringSize = 0;
                int count = 0;

                if (_value != null)
                {
                    webRequest.ContentType = _contentType;

                    postBytes = encoding.GetBytes(_value);

                    webRequest.ContentLength = postBytes.Length;

                    //webRequest.ContentLength = postBytes.Length;

                    try
                    {
                        postStream = webRequest.GetRequestStream();

                        postStream.Write(postBytes, 0, postBytes.Length);
                        Console.WriteLine("postBytes.Length " + postBytes.Length);
                        postStream.Close();

                        webResponse = (HttpWebResponse)webRequest.GetResponse();
                        Console.WriteLine("webResponse = (HttpWebResponse)webRequest.GetResponse();" + postBytes.Length);
                        responseStream = webResponse.GetResponseStream();
                        Console.WriteLine("responseStream = webResponse.GetResponseStream();" + postBytes.Length);

                        xmlBuffer = "";

                        stringSize = 0;

                        count = 0;


                        while ((count = responseStream.Read(buffer, 0, 1024)) > 0)
                        {
                            Array.Copy(buffer, 0, stringBuffer, stringSize, count);
                            stringSize += count;
                        }
                        xmlBuffer = System.Text.UTF8Encoding.UTF8.GetString(stringBuffer, 0, stringSize);

                        responseStream.Close();

                        webResponse.Close();

                        _response = xmlBuffer;

                    }
                    catch (WebException wex)
                    {
                        if (wex.Response != null)
                        {
                            using (HttpWebResponse errorResponse = (HttpWebResponse)wex.Response)
                            {
                                Console.WriteLine("The server returned '{0}' with the status code {1} ({2:d}).", errorResponse.StatusDescription, errorResponse.StatusCode, errorResponse.StatusCode);
                            }
                        }

                    }

                    //catch (WebException ex)
                    //{
                    //    Console.WriteLine(ex.Message);
                    //    //throw new Exception(ex.Message);
                    //}

                    //catch (Exception ex)
                    //{
                    //    Console.WriteLine(ex.Message);
                    //    //throw new Exception(ex.Message);
                    //}
                }
                else
                {
                    webRequest.ContentType = "text";

                    postBytes = encoding.GetBytes(_postMessage);

                    webRequest.ContentLength = postBytes.Length;

                    try
                    {
                        postStream = webRequest.GetRequestStream();

                        postStream.Write(postBytes, 0, postBytes.Length);

                        postStream.Close();

                        webResponse = (HttpWebResponse)webRequest.GetResponse();

                        responseStream = webResponse.GetResponseStream();


                        xmlBuffer = "";

                        stringSize = 0;

                        count = 0;


                        while ((count = responseStream.Read(buffer, 0, 1024)) > 0)
                        {
                            Array.Copy(buffer, 0, stringBuffer, stringSize, count);
                            stringSize += count;
                        }
                        xmlBuffer = System.Text.UTF8Encoding.UTF8.GetString(stringBuffer, 0, stringSize);

                        responseStream.Close();

                        webResponse.Close();

                        _response = xmlBuffer;

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        //throw new Exception(ex.Message);
                    }
                }
            }
            else
            {
                //webResponse.Close();
            
            }



            /*        String Buffer="";
                    PrintWriter pw = null;

                        URL ServerURL = new URL(targetURL);

                        //Create new URLConnection object from the URL
                        HttpURLConnection URLCon = (HttpURLConnection)ServerURL.openConnection();

                        URLCon.setDoInput(true);
                        URLCon.setUseCaches(false);

                        if(postValueList != null || postMessage != null)
                        {
                        URLCon.setDoOutput(true);
                        URLCon.setRequestMethod("POST");

                            pw = new PrintWriter(URLCon.getOutputStream());

                            if(postValueList != null)
                            {

                                for(int i=0; i< postValueList.size() ; i++)
                                {
                                    if(i > 0)
                                        pw.print("&");

                                PostValue CurPostValue=(PostValue)(postValueList.elementAt(i));
                                pw.print(CurPostValue.parm + "=" + URLEncoder.encode(CurPostValue.value) );

                                }

                            }
                            else
                            {
                                pw.print(postMessage);
                            }

                            pw.close();

                    }
                    else
                    {
                        URLCon.setDoOutput(false);
                    }

            //            System.out.println(URLCon.getContentType());

                        BufferedReader in = new BufferedReader(
                                    new InputStreamReader(
                                    URLCon.getInputStream()));

                        String inputLine;

                        while ((inputLine = in.readLine()) != null)
                            Buffer += inputLine + "\n";

                        in.close();

                        response=Buffer;

            */
        }

0
alagesh17
9/20/2008 8:47:53 AM
asp.net.xml-web-services 7071 articles. 0 followers. Follow

1 Replies
834 Views

Similar Articles

[PageSpeed] 34

What do you expect anyone to do with this mess? Do you expect someone to do your job for you?

Part of your job is to narrow down problems. You should either narrow them down sufficiently for you to solve them yourself, or at least enough that someone else can help you. This means, in part, that you must remove aspects of your code that do not contribute to the problem. This can be as easy as deleting code until the problem goes away, then adding code until the problem returns.

At the very least, it means not just copying and pasting all of your code. You could at least have removed the parts that are commented out! Angry

You could also have posted the complete exception that you receive. To catch and display an exception:

 

try
{
    // Failing code here
}
catch (Exception ex)
{
    string exceptionString = ex.ToString();
    // Display it with Console.WriteLine(exceptionString) or something else
    throw;   // Never eat exceptions unless you mean it
}

  

Help us help you - don't just expect us to do all the work.


John Saunders | MVP – Connected System Developer
0
johnwsaunders3
9/20/2008 12:37:16 PM
Reply:

Similar Artilces:

Web Service Error : The remote server returned an error: (500) Internal Server Error
Hi i am getting an error when trying a simple web service. if i run both the web service and the client .aspx page on the same server it works fine, But when i put it on a different server it doesnt work at all and gives me this error"System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.GetResponse() at HttpUtils.HttpPost(String URI, String Parameters) in e:\Websites\C#\Live\CMS\Trunk\App_Code\siteFunctions\HttpUtils.cs:line 35"UserApi.asmx  [WebMethod] public string HelloName(string name) { ...

System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
I have written a web service and tested it and it works fine from the .asmx test page. However, when I attempt to call it with a post I get this error:  The remote server returned an error: (500) Internal Server Error. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.Source Error: Line 164: myStream.Close() ...

The remote server returned an error: (500) Internal Server Error
Hi  String strUrl = "http://catalogues.cataloguecentral.com.au/global/search/search.aspx?";              // Create a request using a URL that can receive a post.         WebRequest request = WebRequest.Create(strUrl);        // Set the Method property of the request to POST.        request.Method = "POST";        // Create POST data and convert it to a byte array. &...

The remote server returned an error: (500) Internal Server Error.
 System.Net.WebException: The remote server returned an error: (500) Internal Server Error.     i implemented the search functionality in the website searchdotnet some application i got ,i inegrated it ,it works fine localhost but on server i created some problemMark As Answer If my reply helped you. It means that an exception occured , you can specify in the web.config to show the exact exception to remote hosts.what is the <customErrors> configuration in your web.config ?   J.W.Please click "Mark as Answer" on this post if it helps you...

The remote server returned an error: (500) Internal Server Error
I have a VB.Net application where I am posting to an HTTP server that has a classic asp page and I am getting the following exception (it's throwing the exception on line 13).  Does anyone know how to troubleshoot this?  thanks  : <EXCEPTION> The remote server returned an error: (500) Internal Server Error </EXCEPTION> 1                            PostData = "externalID=" ID2 Dim strPath As ...

he remote server returned an error: (500) Internal Server Error.
Hi, I would like to connect a webservice. But I don't want to use "add web reference" -------------------------------------------------------------------------------------------- string strSoapMessage = "<?xml version='1.0' encoding='UTF-8'?>" + "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+ "<soap:Body>"+ "<GenerateSessionKey xmlns='http://www.artwork-systems.com/webway/sessions'>"+ "<login>test</login>"+ "<auth>test<...

The remote server returned an error: (500) Internal Server Error.
When I remote access in website by application on window to extract data I have error : The remote server returned an error: (500) Internal Server Error. This is my code : Dim PostData As String = _ "__VIEWSTATE=" & tmpvs & _ "&txtUserName=" & UserID & _ "&txtPassword=" & PWord & _ "&chkPersistant=1" & _ "&btnSignIn=SignIn" '& _ Dim Data() As Byte = encoding.GetBytes(PostData) Dim LoginReq As Net.HttpWebRequest = Net.WebRequest.Create(loginURL) With LoginReq .KeepAlive = Fals...

The remote server returned an error: (500) Internal Server Error. #2
I am testing a utility program that loops through my localhost and pulls out all of the meta tag information and page titles.   After I do a recursive directory search and have all of the pages i convert the directory path's to urls and call the pages using the following code WebClient wc = new WebClient(uri); string page = wc.DownloadString(uri); This seems to work fine for the first few sites, however at a certain point i start getting (The remote server returned an error: (500) Internal Server Error.).  Nothing is wrong with the URI however it just seems to st...

The remote server returned an error: (500) Internal Server Error. #3
I am trying to access a web site using below snippet HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse webResponse = (HttpWebResponse)httpWebRequest.GetResponse(); This is occuring for particular web site and rest of the web site working fine.  Error:  The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.GetResponse() -532459699...  Also, i tried with below options 1. Adding Credential likeNetworkCredential networkCredential = new NetworkCredential("user name", "pwd", &qu...

The remote server returned an error: (500) Internal Server Error #2
Hello, I'm trying to send the request from site A to site B in localhost but get an error "The remote server returned an error: (500) Internal Server Error" in programatically.  The code below used to work for me and all of a certain it fails to send the request to site B (order site). The order site by itself is still up and running but when I try to send the request to this site in the code, it fails because of (500) Internal Server Error.  I also tried to restart the IIS but still doesn't work.  Does anyone knows why?  mReqUrl =...

Message="The remote server returned an error: (500) Internal Server Error."
 HI,when I try to call a simple web method with parameters using HTTP Post I am getting this error "Message="The remote server returned an error: (500) Internal Server Error.""  This My Web Method [WebMethod]        public string getDataWithParm1(string aaa)        {            string ss= "yytry";            ss =ss + " asdfg" ;            r...

How to solve:"The remote server returned an error: (500) Internal Server Error. "
 I am working On asp.net2.0(c#) In creating rss i used a user control by writing xml dynamically. It is working well in my personal server but in my client server it is producing error such that.. Server Error in '/GetReception' Application. The remote server returned an error: (500) Internal Server Error. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.WebException: The remote server return...

Server Error: HTTP Error 500.19
I got the following error while trying to make a test WCF project on VistaServer Error HTTP Error 500.19 - Internal Server ErrorDescription: The requested page cannot be accessed because the related configuration data for the page is invalid. Error Code: 0x80070005 Notification: BeginRequest Module: IIS Web Core Requested URL: http://localhost:80/ProductsService/ProductsService.svc Physical Path: C:\Test\ProductsService\ProductsService\ProductsService.svc Logon User: Not yet determined Logon Method: Not yet determined Handler: Not yet determined Config Error: Cannot read configura...

Axis call to .Net web Service internal server error 500
 Hi, Desperately need advise as I'm not able to call a .Net web service. Problem is, the .Net web service works well when it's call via SoapUI. Could it be any .Net configuration being overlooked? Thanks in advance. After performing a network trace.. here are the details.. Call from Axis..POST /WebService/CPServices.asmx?wsdl HTTP/1.1Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_84B12E522B4E0E31C41234969838674; type="application/xop+xml"; start="<0.urn:uuid:84B12E522B4E0E31C41234969838675@apache.org>"; start-info="ap...

Web resources about - remote server returned an error: (500) Internal Server Error. - asp.net.xml-web-services

Energy returned on energy invested - Wikipedia, the free encyclopedia
The natural or original sources of energy are not usually included in the calculation of energy invested, only the human-applied sources. For ...

How Facebook Returned A/B Testing To Mobile Apps
When Facebook rewrote its mobile applications and converted them from custom Web stacks to native development stacks, it lost the ability to ...

Facebook temporarily reveals ‘returned value’ metric for ads
Some Facebook advertisers temporarily saw a new metric called “returned value” in their Ads Manager dashboard. Facebook says the metric was accidentally ...

The Night Steve Jobs returned to Apple, Dec 20, 1996 - a set on Flickr
Working late on a Friday on December 20th at Apple Computer as Mac OS Evangelist, my manager came rushing past my office door saying to come ...

Batista reveals why he returned to WWE - YouTube
The Animal talks about overcoming a broken back, his immersion in Jiu-Jitsu training, and his desire to capture the WWE World Heavyweight Championship. ...

Fugitive US businessman Zack Shahin returned to UAE, says spokesman
... a taser following his release. A fugitive American businessman who is facing multi-million dirham corruption charges in Dubai has been returned ...

Bender is back! Belair’s favourite robot returned - AdelaideNow Search Search
GOOD news, everyone! Bender the robot — possibly the coolest letterbox in the Adelaide Hills — has been returned just days after being stolen. ...

'We were all sick': returned asylum seekers tell of lifeboat ordeal to Java
The orange lifeboat wallowing in the shallows off the coast of Central Java is proving to be a highly effective weapon in Australia's military ...

Money returned but Slavich holds onto hope
Money returned but Slavich holds onto hope

Perth student’s camera returned after five years on bottom of Prague river
IT took a Beatles lyric, an aquatics instructor and social media to return Chloe Hutson’s long-lost holiday photographs five years after her ...

Resources last updated: 12/11/2015 11:04:42 PM