我目前正在開發一個WCF發佈訂閱服務。發佈者將是一個asp.net,訂閱者將是一個winform應用程序。如何爲我的asp.net翻譯下面的代碼來閱讀並執行連接到我的服務的方式?如何爲我的asp.net翻譯下面的代碼?
class Program : IPostingContractCallback
{
static void Main(string[] args)
{
InstanceContext site = new InstanceContext(new Program());
PostingContractClient client = new PostingContractClient(site);
client.PublishPost("testing");
Console.WriteLine();
Console.WriteLine("Press ENTER to shut down data source");
Console.ReadLine();
//Closing the client gracefully closes the connection and cleans up resources
client.Close();
}
public void PostReceived(string postSampleData)
{
Console.WriteLine("PostChange(item {0})",postSampleData);
}
在WCF中發佈/訂閱得不到很好的支持。你想要做什麼? –
上述代碼適用於C#應用程序,它在運行時充當發佈到服務的發佈者。我想要做的是將其轉換爲asp.net代碼,因爲我的發佈者是一個asp.net網頁。 – Thomas