ms-help://MS.NETFrameworkSDK.chs/cptools/html/cpgrfsoapsudsutilitysoapsudsexe.htm示例
以下命令从 URL 下载一个架构并将该架构保存到 XML 文件中。soapsuds -url:http://localhost/Service/MyService.soap?wsdl
-os:MyService.xml
以下命令从 URL 下载一个架构并生成代码。soapsuds -url:http://localhost/Service/MyService.soap?wsdl -gc
以下命令从 URL 下载一个架构,将该架构保存到文件中,并生成代码。soapsuds -url:http://localhost/Service/MyService.soap?wsdl
-os:StockQuote.xml -gc
以下命令从 URL 下载一个架构,生成代码,然后编译并生成一个程序集。soapsuds -url:http://localhost/Service/MyService.soap?wsdl
-oa:StockQuote.dll
以下命令将一个类型转换为一个架构,并将该架构保存到文件中。soapsuds -types:MyClass.MyMethod,Service.dll -os:StockQuote.xml
以下命令将一个类型转换为一个架构并生成代码。soapsuds -types:MyClass.MyMethod,Service.dll -gc
以下命令将一个类型转换为一个架构,将该架构保存到文件中,并生成代码。soapsuds -types:MyClass.MyMethod,Service.dll -os:MyService.xml -gc
以下命令从 URL 下载一个架构并将该架构保存到 XML 文件中。soapsuds -url:http://localhost/Service/MyService.soap?wsdl
-os:MyService.xml
以下命令从 URL 下载一个架构并生成代码。soapsuds -url:http://localhost/Service/MyService.soap?wsdl -gc
以下命令从 URL 下载一个架构,将该架构保存到文件中,并生成代码。soapsuds -url:http://localhost/Service/MyService.soap?wsdl
-os:StockQuote.xml -gc
以下命令从 URL 下载一个架构,生成代码,然后编译并生成一个程序集。soapsuds -url:http://localhost/Service/MyService.soap?wsdl
-oa:StockQuote.dll
以下命令将一个类型转换为一个架构,并将该架构保存到文件中。soapsuds -types:MyClass.MyMethod,Service.dll -os:StockQuote.xml
以下命令将一个类型转换为一个架构并生成代码。soapsuds -types:MyClass.MyMethod,Service.dll -gc
以下命令将一个类型转换为一个架构,将该架构保存到文件中,并生成代码。soapsuds -types:MyClass.MyMethod,Service.dll -os:MyService.xml -gc
using System.Runtime.Remoting;
namespace Distribution_Framework
{
//定义广播事件的参数类
[Serializable]
public class BroadcastEventArgs : EventArgs
{
private string msg = null;
public BroadcastEventArgs(string message)
{ msg = message; }
public string Message
{
get { return msg; }
}
}
public delegate void BroadcastEventHandler(object sender, BroadcastEventArgs submitArgs);
public class InfoCenter : MarshalByRefObject
{
public InfoCenter()
{
Console.WriteLine("InfoCenter created.");
}
public override object InitializeLifetimeService()
{ return null; }
public event BroadcastEventHandler Broadcaster;
public void Broadcasting(string message)
{
BroadcastEventArgs e = new BroadcastEventArgs(message);
if (Broadcaster != null)
{
Broadcaster(this, e);//发出事件
Console.WriteLine("Broadcast:" + e.Message);
}
}
}
}//////////////////////////////////////////////////////////////////
//服务程序(Announcer.cs)清单
using System;
using System.Timers;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;namespace Distribution_Framework
{
class Announcer
{
public static void Main(string[] Args)
{
RemotingConfiguration.Configure("../../Announcer.exe.config");
Announcer announcer = new Announcer();
Console.WriteLine("The announcer has been started.");
Console.ReadLine();
}
}
}/////////////////////////////////////////////////////////////////////
//服务程序配置文件(Announcer.exe.config)清单
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="Distribution_Framework.InfoCenter, InfoCenter"
objectUri="Broadcast"
/>
</service>
<channels>
<channel
ref="http"
port="8080"
/>
</channels>
</application>
</system.runtime.remoting>
</configuration>/////////////////////////////////////////////////////////////////////////
//客户程序(Receiver.cs)清单
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;namespace Distribution_Framework
{
class Receiver : MarshalByRefObject
{
InfoCenter infoCenter;
public Receiver()
{ }
public override object InitializeLifetimeService()
{ return null; }
public void Run()
{
RemotingConfiguration.Configure("../../Receiver.exe.config");
infoCenter = new InfoCenter();
//订阅信息
infoCenter.Broadcaster += new BroadcastEventHandler(this.BroadcastReceiver);
Console.WriteLine("Ready to Recieve Message...");
string msg = "The Time is: " + DateTime.Now.ToString();
Console.WriteLine("Send Message:" + msg);
infoCenter.Broadcasting(msg); //
Console.ReadLine();
//取消订阅
infoCenter.Broadcaster -= new BroadcastEventHandler(this.BroadcastReceiver);
} public void BroadcastReceiver(object sender, BroadcastEventArgs args)
{
Console.WriteLine("Received:" + args.Message);//打印接收信息
} public static void Main()
{
Receiver receiver = new Receiver();
receiver.Run();
}
}
}/////////////////////////////////////////////////////////////////////////////////////
//客户程序配置文件(Receiver.exe.config)清单
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown
type="Distribution_Framework.InfoCenter, InfoCenter"
url="http://localhost:8080/Broadcast"
/>
</client>
<channels>
<channel
ref="http"
port="0"
/>
</channels>
</application>
</system.runtime.remoting>
</configuration>