我是开发Web服务和客户端服务器应用程序的新手,我在理解如何从c#web服务生成WSDL文件时遇到麻烦。 我需要WSDL文件才能生成代理类并将其引用到通信客户端。如何从Remoting服务器生成WSDL文件?
class my_server
{
private static HttpChannel channel;
private static int port = 3000;
private static string serverUri = "myservice";
static void Main(string[] args)
{
Console.WriteLine("Sample server");
StartSoapServer(port);
Console.ReadLine();
StopSoapServer();
}
private static bool Start(int p)
{
try
{
port = p;
channel = new HttpChannel(port);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
RemotingConfiguration.RegisterWellKnownServiceType(typeof(server), serverUri, WellKnownObjectMode.Singleton);
IServerChannelSink sinkChain = channel.ChannelSinkChain;
Console.WriteLine("server created");
}
catch (Exception e)
{
return false;
}
return true;
}
private static void Stop()
{
string[] urls = channel.GetUrlsForUri(serverUri);
if (urls.Length > 0)
{
string objectUrl = urls[0];
string objectUri;
string channelUri = channel.Parse(objectUrl, out objectUri);
ChannelServices.UnregisterChannel(channel);
Console.WriteLine("Server stopped");
}
}
public class server : MarshalByRefObject
{
public server()
{
}
public override object InitializeLifetimeService()
{
return null;
}
public bool initialise()
{
Console.WriteLine("initialise()");
return true;
}
public bool ping()
{
Console.WriteLine("ping");
return true;
}
}
}
显然,服务器的创建,直到它停止岿然不动......然而,随着风暴(http://storm.codeplex.com/)进行测试时,它:通过添加http://localhost:3000/myserviceuri
失败......怎么回事我可以检查服务的工作原理,没有实施客户?我怎样才能从这个服务器生成WSDL文件? 我试图使用http://wsdlgenerator.codeplex.com/,但显然它只适用于WCF服务...
服务是否是.asmx Web服务? –
@Alex Mendez它应该是一个远程API ..使用System.Remoting .. – agatha
所以你不能期望得到一个WSDL,如果它不是一个Web服务。 – Seb