I am currently developing a WCF publish subscribe service. Is it possible for the publisher to be a asp.net application connecting to the service ? As I cant seem to find any information online about vb code for WCF.
EDIT
More details.
As my subscriber is a winform app, it is to subscribe to the WCF service using C# code and I am fine with that. the WCF Service is also coded in C# and I also have no problems with that. Normally the tutorials out in the web provides the code for a publisher to connect to the service and then call the publish code in console app or something. However all those is meant to be done in C#.
In my case, if i were to program the publisher code in a asp.net application. would it be possible?
EDIT : Codes Added
I am now currently using a C# mock publisher to post the data and the code are as follows
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();
client.Close();
}
public void PostReceived(string postSampleData)
{
Console.WriteLine("PostChange(item {0})",postSampleData);
}
}
and for my asp.net webpage, I want all this to happen when I call this line of code
ElseIf Request.QueryString("action") = "postAlert" Then
How do I write the code as stated in above for vb? and do I just do as what I do in a C# project? adding the app.config file and the generatedProxy.cs?
You can do ASP.NET with VB.NET, so it’s not a case of VB vs C#.
You could very easily write an ASP.NET application and have it connect to the publish service. The ASP.NET app would connect to the publishing service the same way a console app would (i.e., creating a new proxy/client and making calls to the service).
Updated
As Jon P said, use SVCUTIL and set the language to Visual Basic, like this:
ServiceModel Metadata Utility Tool (Svcutil.exe)
You’ll want to add the
<serviceModel>section to your Web.config, and generate the proxy in VB (using the /language:vb switch above).Below is the VB version of the class you posted:
Your ASP.NET app is acting as the publisher, but it’s connecting to the publishing service (if I understand correctly), so all it’s really doing is making a call to the service to publish the post.
The service itself should handle the callback and “publish” the event on the callback channel(s) for the subscriber.
So (without all the code for the various components I might be missing something – if I am, please let me know so I can update accordingly), all your ASP.NET app needs to do is:
To reiterate (again, based on my understanding):
So for part 2, you might have something like:
The client(s) should then pick up the PostReceived “event” and do what their implementation of the callback interface specifies.