473,322 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Error consuming web service "Remote Server returned an error: (500

Hi,

Im testing a web service from my windows app in C#. I create a soap body and
pass to the HttpWebRequest and then get the response as below.

private void TestService()
{
string quotes = "\"";

// Set the uri to send the request to
string requestUri =
"http://localhost/TestServices/TestService.asmx/RetrieveTest";

string SoapEnv;
SoapEnv = "<soap:Envelope xmlns:xsi=" + quotes
+ "http://www.w3.org/2001/XMLSchema-instance" + quotes +
" xmlns:xsd=" + quotes +
"http://www.w3.org/2001/XMLSchema" + quotes +
" xmlns:soap=" + quotes +
"http://schemas.xmlsoap.org/soap/envelope/" + quotes
+ ">" +
" <soap:Body>" +
"<RetrieveTest xmlns=" + quotes +
"http://localhost/TestServices" + quotes + ">" +
"<TestID>string</TestxID>" +
" </RetrieveTest>" +
" </soap:Body>" +
" </soap:Envelope>";

HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create(requestUri);

if (myRequest != null)
{
myRequest.Method = "POST";
myRequest.ContentLength = SoapEnv.Length;
myRequest.ContentType = "text/xml; charset=utf-8";
}

StreamWriter myWriter = new StreamWriter(myRequest.GetRequestStream());
myWriter.Write(SoapEnv);
myWriter.Close();

//I get the response here
try
{
//Get an error in GetResponse() here
HttpWebResponse myHttpWebResponse = (HttpWebResponse)
myRequest.GetResponse();
StreamReader myStreamReader = new StreamReader
(myHttpWebResponse.GetResponseStream());
string strResponse = myStreamReader.ReadToEnd();
myStreamReader.Close();

}
catch (WebException exc)
{
//Get an exception here i.e.
"The remote server returned an error: (500) Internal Server Error"
The Status shows "ProtocolError"
}
}

The catch is done when GetResponse() is called. Will appreciate any
suggestions/help on the above.

Thanks.

Aug 15 '06 #1
4 15994
Im testing a web service from my windows app in C#. I create a soap body
and
pass to the HttpWebRequest and then get the response as below.
By any chance you have enabled authentication in IIS (Disabled anonymous
authentication)?
I would suggest enabling tracing on the server side for all requests and
responses. You'll need to have WSE to do that.

For ASP.Net 1.1 (WSE 2.0):

Add a section:
<section name="microsoft.web.services2"
type="Microsoft.Web.Services2.Configuration.WebSer vicesConfiguration,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />

And then:
<microsoft.web.services2>
<diagnostics>
<detailedErrors enabled="true" />
<trace enabled="true" input="InputTrace.webinfo.xml"
output="OutputTrace.webinfo.xml" />
</diagnostics>
</microsoft.web.services2>

For ASP.Net 2.0 (WSE 3.0):
Replace services2 with services3 everywhere.

Look into the file InputTrace.webinfo.xml. You should be able to see the
input request (envelope) that you sent along with other information.
--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.org
http://www.edujini.in | http://webservices.edujini.in
-------------------
Aug 15 '06 #2
Thanks for the reply. I went further and got the error message from the
response which is as follows:

Status Description : Internal Server Error
A first chance exception of type 'System.Net.WebException' occurred in
System.dll
System.InvalidOperationException: Request format is invalid: text/xml;
charset=utf-8.
at System.Web.Services.Protocols.HttpServerProtocol.R eadParameters()
at System.Web.Services.Protocols.WebServiceHandler.Co reProcessRequest()

Any help will be greatly appreciated.

Thanks
"Gaurav Vaish (www.EduJini.IN)" wrote:
Im testing a web service from my windows app in C#. I create a soap body
and
pass to the HttpWebRequest and then get the response as below.

By any chance you have enabled authentication in IIS (Disabled anonymous
authentication)?
I would suggest enabling tracing on the server side for all requests and
responses. You'll need to have WSE to do that.

For ASP.Net 1.1 (WSE 2.0):

Add a section:
<section name="microsoft.web.services2"
type="Microsoft.Web.Services2.Configuration.WebSer vicesConfiguration,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />

And then:
<microsoft.web.services2>
<diagnostics>
<detailedErrors enabled="true" />
<trace enabled="true" input="InputTrace.webinfo.xml"
output="OutputTrace.webinfo.xml" />
</diagnostics>
</microsoft.web.services2>

For ASP.Net 2.0 (WSE 3.0):
Replace services2 with services3 everywhere.

Look into the file InputTrace.webinfo.xml. You should be able to see the
input request (envelope) that you sent along with other information.
--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.org
http://www.edujini.in | http://webservices.edujini.in
-------------------
Aug 15 '06 #3
Hi Gaurav,

I tried to save the trace info to the file, but Im not able to see the file.
I searched for it and it does not exist anywhere(I used WSE to set the path
to the trace file). Any suggestions why?

Thanks
"Haxan" wrote:
Hi,

Im testing a web service from my windows app in C#. I create a soap body and
pass to the HttpWebRequest and then get the response as below.

private void TestService()
{
string quotes = "\"";

// Set the uri to send the request to
string requestUri =
"http://localhost/TestServices/TestService.asmx/RetrieveTest";

string SoapEnv;
SoapEnv = "<soap:Envelope xmlns:xsi=" + quotes
+ "http://www.w3.org/2001/XMLSchema-instance" + quotes +
" xmlns:xsd=" + quotes +
"http://www.w3.org/2001/XMLSchema" + quotes +
" xmlns:soap=" + quotes +
"http://schemas.xmlsoap.org/soap/envelope/" + quotes
+ ">" +
" <soap:Body>" +
"<RetrieveTest xmlns=" + quotes +
"http://localhost/TestServices" + quotes + ">" +
"<TestID>string</TestxID>" +
" </RetrieveTest>" +
" </soap:Body>" +
" </soap:Envelope>";

HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create(requestUri);

if (myRequest != null)
{
myRequest.Method = "POST";
myRequest.ContentLength = SoapEnv.Length;
myRequest.ContentType = "text/xml; charset=utf-8";
}

StreamWriter myWriter = new StreamWriter(myRequest.GetRequestStream());
myWriter.Write(SoapEnv);
myWriter.Close();

//I get the response here
try
{
//Get an error in GetResponse() here
HttpWebResponse myHttpWebResponse = (HttpWebResponse)
myRequest.GetResponse();
StreamReader myStreamReader = new StreamReader
(myHttpWebResponse.GetResponseStream());
string strResponse = myStreamReader.ReadToEnd();
myStreamReader.Close();

}
catch (WebException exc)
{
//Get an exception here i.e.
"The remote server returned an error: (500) Internal Server Error"
The Status shows "ProtocolError"
}
}

The catch is done when GetResponse() is called. Will appreciate any
suggestions/help on the above.

Thanks.
Aug 15 '06 #4
Did you provide the absolute path or the relative path?

If it's relative, then, IIRC, '.' (period) corresponds to 'C:\WINDOWS'
directory...

Or you may just want to write a simple IHttpModule that will log all
request...

--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujini.in | http://articles.edujini.in/webservices
-------------------
"Haxan" <Ha***@discussions.microsoft.comwrote in message
news:E7**********************************@microsof t.com...
Hi Gaurav,

I tried to save the trace info to the file, but Im not able to see the
file.
I searched for it and it does not exist anywhere(I used WSE to set the
path
to the trace file). Any suggestions why?

Thanks

Aug 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: N. Graves | last post by:
Hello, I don't understand this error message." Error accessing File. Network Connection may have been lost." I'm not using any network connection for the database. In the VBA editor is goes...
0
by: INGSOC | last post by:
Using remote debugging, I can attach to a windows service and run it in debug mode in VS.Net 2003. The problem is this service uses two supporting dlls. On the remote service, the dlls have...
6
by: Picho | last post by:
Hi all. I have a webservice and a windows app. both of them reference the same class library called WebServiceTest.Core that defines a class called Class1. the webservice exposes a method...
7
by: Jorgen Haukland, Norway | last post by:
Hi, I have created a Java webservice which runs in IBM WebSphere appserver. I take the WSDL-file and create a VS.NET WinForm application and calls the service running on my PC and everything...
5
by: B.J. | last post by:
Hi, Where I can change Web service server side timeout ? Because my service time out and I set WebClientProtocol.Timeout to infinite. (According to...
0
by: George | last post by:
my web service works fine on my laptop but when i moved it to the server i get "Server Application Unavailable." i checked the event application log and it shows "aspnet_wp.exe could not be...
4
by: soren625 | last post by:
What I am trying to do is grab a little snippet of data from a remote page based on user input in a form. Take a look at this page: http://www.qrz.com/kb2gsd What I want to do is: when a user...
1
by: Tito Meinrath | last post by:
Hi, I'm really going mad about this! Currently I'm designing a student course on web services. Because I want them to understand what's really going on when web services correspond with each...
2
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a server 2008 IIS 7.0 with indexing service installed. I have created the catalog and have a test page using these posts:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.