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</auth>"
+ "</GenerateSessionKey>"
+ "</soap:Body>"
+ "</soap:Envelope>";

HttpWebRequest req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(@http://domaineName.com:8888/));
req.ContentType =
"text/xml; charset=UTF-8";
req.Method =
"POST";
req.Accept =
"text/xml";
req.Headers.Add(
"SOAPAction", @http://www.artwork-systems.com/webway/sessions#GenerateSessionKey);

StreamWriter stm = new StreamWriter(req.GetRequestStream(), Encoding.UTF8);
stm.Write(strSoapMessage);
stm.Flush();
stm.Close();

HttpWebResponse wr = (HttpWebResponse)req.GetResponse();
StreamReader srd = new StreamReader(wr.GetResponseStream());
Response.Write( srd.ReadToEnd());

--------------------------------------------------------------------------------------------

But I have this message :

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

at the line : HttpWebResponse wr = (HttpWebResponse)req.GetResponse();

Have you got an idea,

Thanks


my blog : michel degremont
0
wesleymichel
3/23/2006 9:05:58 AM
asp.net.xml-web-services 7071 articles. 0 followers. Follow

3 Replies
1168 Views

Similar Articles

[PageSpeed] 56

Why do you not want to use "Add Web Reference"?

Also have you verified the web service works correctly in another tool, like something Web Service Studio?

 


If an answer has been provided to you question please mark it as an answer.
0
Mlogan
3/23/2006 12:48:18 PM

It's Ok, I found It.

Why I don't user "add web reference" ? Because wsdl definition isnt't good.

The document at the url http://domaineName.org/webway/wsdl/webway.wsdl was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'DISCO Document' is 'Discovery document at the URL
http://domaineName.org/webway/wsdl/webway.wsdl could not be found.'.
  - The document format is not recognized (the content type is 'text/plain').
- Report from 'WSDL Document' is 'There is an error in XML document (33, 10).'.
  - Namespace prefix 'wsdlns' is not defined.
- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be <schema> and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'.

 

But it's  not a problem, it is not serious. I fixed this error :

------------------------------------------------------------------------------------------
Start code
------------------------------------------------------------------------------------------

string strSoapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:tns=\"http://www.artwork-systems.com/webway/sessions\" xmlns:types=\"http://www.artwork-systems.com/webway/sessions/encodedTypes\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"
+ " <soap:Body soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+ " <tns:GenerateSessionKey>"
+ " <login xsi:type=\"xsd:string\">admin</login>"
+ " <auth xsi:type=\"xsd:string\">webway</auth>"
+ " </tns:GenerateSessionKey>"
+ " </soap:Body>"
+ "</soap:Envelope>";

HttpWebRequest req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(@"http://domaineName.org:8888/"));

req.ContentType = "text/xml; charset=UTF-8";
req.Method =
"POST";
req.Accept =
"text/xml";
req.Headers.Add(
"SOAPAction", @http://www.artwork-systems.com/webway/sessions#GenerateSessionKey);
req.ProtocolVersion =
HttpVersion.Version11;
req.Credentials =
CredentialCache.DefaultCredentials;

StreamWriter stm = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
stm.Write(strSoapMessage);
stm.Flush();
stm.Close();

HttpWebResponse wr = (HttpWebResponse)req.GetResponse();
StreamReader srd = new StreamReader(wr.GetResponseStream());
string resulXmlFromWebService = srd.ReadToEnd();

------------------------------------------------------------------------------------------
End code
------------------------------------------------------------------------------------------

I set Encoding.ASCII because If I use Encoding.UTF8, I had a very strange character "" after XML flux : 

<?xml version=\"1.0 ... 


 


my blog : michel degremont
0
wesleymichel
3/23/2006 3:30:56 PM

Hi Friends,

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

My Web Configuration

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

  How to Solve this Problem,

 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 9:09:48 AM
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() ...

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()        {      ...

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 ...

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 - he 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 ...

Baby sloth, rescued from captivity and to be returned to the wild - Flickr - Photo Sharing!
Paradise Garden, Boquete, Panama See where this picture was taken. [?]

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. ...

Nearly 600 vehicles impounded by UAE authorities returned
The vehicles were returned last month after the impoundment period ended and all associated fines were paid.

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. ...

Trombone stolen from Sydney Opera House returned to owner
An Edwards bass trombone stolen from the Sydney Opera House will soon be reunited with its owner, Colin Burrows.

Mining tax embarrassment as Rio funds returned
Rio Tinto has paid no mining tax to the government during the first year of the controversial impost, after pre-payments made in April were refunded ...

Family of sisters returned to Italy complains of police actions
THE family of four sisters, who were returned this week by Australia to Italy, say they will file a complaint to the Commonwealth Ombudsman over ...

Resources last updated: 1/20/2016 8:29:28 AM