ASMX Service Client Debugging

Rob Gaudet
Rob Gaudet used Ask the Experts™
on
I am testing a client who's supposed to connect to my .asmx web service with a single method called PostData.

The client code being used is also used for other web services, however, it does not reference any methods.
So I'm assuming the other services this client publishes too are web services that don't expose any methods.

QUESTION 1) Is is possible to create web services that don't expose methods?

I had them send me an example of the code to test out myself, I've copied it below. When I try running this... I get a "The remote server returned an error: (500) Internal Server Error.".

I would like to debug this inside of the web service, however I am not sure how to since it doesn't ever load up the exposed method.

QUESTION 2) ANY IDEAS?


string returnString;
			var request = System.Net.WebRequest.Create("https://-------/Services/DataPushService.asmx") as System.Net.HttpWebRequest;
			var messageString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><XML xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">DATA HERE</XML>";
			request.Method = "POST";
			request.ContentType = "text/xml";

			request.Accept = "Accept"; // options.Communications.HttpAcceptHeader; 
			request.KeepAlive = false;
			request.ServicePoint.Expect100Continue = false;

			request.Headers["Authorization"] = "Basic WebServiceTest:miller69";

			using (var requestStream = request.GetRequestStream())
			{
				using (var requestWriter = new System.IO.StreamWriter(requestStream, Encoding.UTF8))
				{
					requestWriter.Write(messageString);
				}
			}

			using (var response = request.GetResponse())
			{
				using (var responseStream = response.GetResponseStream())
				{
					if (responseStream != null)
					{
						using (var responseReader = new System.IO.StreamReader(responseStream, Encoding.UTF8))
						{
							returnString = responseReader.ReadToEnd();
						}
					}
				}
			}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Software Engineer
Top Expert 2009
Commented:
Q1. NO. NO methods means no way to talk to web server.
Q2. Tell them to provide the appropriate way to talk to their services. COMPLETE Sample code  with the correct URL and a valid user, the method may have permissions rules that you need to satisfy in order to use it.
Also you can only debug services that you have the source code.
ǩa̹̼͍̓̂ͪͤͭ̓u͈̳̟͕̬ͩ͂̌͌̾̀ͪf̭̤͉̅̋͛͂̓͛̈m̩̘̱̃e͙̳͊̑̂ͦ̌ͯ̚d͋̋ͧ̑ͯ͛̉Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015
Commented:
That username and password string in your Authorization line needs to be base-64 encoded. (The "Basic" bit doesn't; just the username and password.) Also, your Accept header doesn't look correct. It should be something like "application/xml" or maybe "application/json", depending on what kind of data you wish to get back. If you're not getting any data back, then you can leave the Accept out altogether.

Author

Commented:
The client is driving the boat here... they don't want to base-64 encode the auth. info and I don't want to rock it. As for the Accept header, I'll make that adjustment and see how it goes.

Author

Commented:
Yeah, changed the Accept header to the proper text but still getting this error --> "The remote server returned an error: (500) Internal Server Error.".
Miguel OzSenior Software Engineer
Top Expert 2009

Commented:
You need to have a look at the server logs to determine the correct error (typically include error details and hopefully ad stack trace that cold guide you to find out what the problem is)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial