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

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

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.