I had this problem that the asmx files did display fine in the browser, but when I called a function, it would always return a red Zero.

To get to the bottom of this problem, I created a web.config file with this content:

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
    <compilation debug="true" />
</configuration>

Best to use a clean directory without a bin subdirectory, for testing.
Use the MathService sample asmx file from http://www.mono-project.com/Writing_a_WebService:

<%@ WebService Language="C#" Class="MathService.MathService" %>
 
using System;
using System.Web.Services;
 
namespace MathService
{
	[WebService (Namespace = "http://tempuri.org/NumberService")]
	public class MathService : WebService
	{
		[WebMethod]
		public int AddNumbers (int number1, int number2)
		{
			return number1 + number2;
		}
 
		[WebMethod]
		public int SubtractNumbers (int number1, int number2)
		{
			return number1 - number2;
		}
	}
}

Starting the xsp server for testing purposes:

. /opt/mono/env.sh
cd /var/www/openpetra
MONO_OPTIONS=--debug xsp4 --port 80 --verbose

When you now call the asmx file in your browser, you see the output on the console.

In my case there was an error about sqlite3.dll in the bin directory, which is a windows dll, and this caused trouble for the server.

But it still did only show a red zero. Finally I looked at the html source of the asmx file in the webbrowser, and I realised that the ports got mixed up, since I was using port forwarding into a virtual machine. So the port defined in the webbrowser was different than the port that xsp was running on.

The url in the browser is: http://myhost:8090, but this is the url in the source code:

getXML ("GET", "http://myhost/test.asmx/SubtractNumbers", "number1=asf&number2=asdf");

To solve this: make sure that in your /etc/lighttpd/vhosts.d/openpetra9000.conf, you have a server.name set with a value that the server is reachable from the client.
It seems the document path is also part of server.name. You can put the port into another variable called server.port, but then the port will be attached to the server.name, after the document path.

In the end, I am now only using the default port.

Debugging Mono Web Services
Markiert in: