我正在尝试使用 jQuery 来使用我的 Web 服务,并且基本上只需要 Web 服务来调用函数就可以了。
我在 .NET 中使用的代码是这样的:
[ServiceContract(Namespace = "http://Sinvise.Service/")]
public interface ISinvise
{
[OperationContract]
void Output(string value);
}
class SinviseService : ISinvise
{
second sec = new second();
public void Output(string value)
{
sec.message(value);
}
}
+
Uri baseAddr = new Uri("http://localhost:60185/Sinvise");
ServiceHost localHost = new ServiceHost(typeof(SinviseService), baseAddr);
try
{
Process.Start(baseAddr.AbsoluteUri);
localHost.AddServiceEndpoint(typeof(ISinvise), new WSHttpBinding(), "CalculatorService");
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
localHost.Description.Behaviors.Add(smb);
localHost.Open();
Console.WriteLine("Service initialized.");
Console.WriteLine("Press the ENTER key to terminate service.");
Console.ReadLine();
localHost.Close();
}
catch (CommunicationException ex)
{
Console.WriteLine("Oops! Exception: {0}", ex.Message);
localHost.Abort();
}
我如何能够简单地调用Output
Web 服务?
谢谢