473,410 Members | 1,937 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,410 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 16002
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.