I have this web service:
using System.Web.Services;
namespace Contracts
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Second : System.Web.Services.WebService
{
[WebMethod]
public string GetContract()
{
return "Contract 1";
}
}
}
The following WPF application can display the HTML fine:
using System.Windows;
using System.Net;
using System;
namespace TestConsume2343
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
WebClient proxy = new WebClient();
proxy.DownloadStringCompleted += new DownloadStringCompletedEventHandler(proxy_DownloadStringCompleted);
proxy.DownloadStringAsync(new Uri("http://localhost:57379/Second.asmx?op=GetContract"));
Message.Text = "loading...";
}
void proxy_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Message.Text = e.Result.ToString();
}
}
}
but when I replace the above line with the actual web service:
proxy.DownloadStringAsync(new Uri("http://localhost:57379/Second.asmx/GetContract"));
it gives me the error message:
The remote server returned the error (500) Internal Server Error.
Although when I look at the same URL in my browser, I see the XML text fine:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">Contract 1</string>
Why is it giving me the 500 error?