I'm trying to write a simple/small Windows Communication Foundation service application in Visual Basic (but I am very novice in VB) and all the good examples I've found on the net are written in C#. So far I've gotten my WCF service application working but now I'm trying to add callback functionality and the program has gotten more complicated. In the C# example code I understand how everything works but I am having trouble translating into VB the portion of code that uses a delegate. Can someone please show the VB equivalent?
Here is the C# code sample I'm using for reference:
namespace WCFCallbacks
{
using System;
using System.ServiceModel;
[ServiceContract(CallbackContract = typeof(IMessageCallback))]
public interface IMessage
{
[OperationContract]
void AddMessage(string message);
[OperationContract]
bool Subscribe();
[OperationContract]
bool Unsubscribe();
}
interface IMessageCallback
{
[OperationContract(IsOneWay = true)]
void OnMessageAdded(string message, DateTime timestamp);
}
}
namespace WCFCallbacks
{
using System;
using System.Collections.Generic;
using System.ServiceModel;
public class MessageService : IMessage
{
private static readonly List<IMessageCallback> subscribers = new List<IMessageCallback>();
//The code in this AddMessage method is what I'd like to see re-written in VB...
public void AddMessage(string message)
{
subscribers.ForEach(delegate(IMessageCallback callback)
{
if (((ICommunicationObject)callback).State == CommunicationState.Opened)
{
callback.OnMessageAdded(message, DateTime.Now);
}
else
{
subscribers.Remove(callback);
}
});
}
public bool Subscribe()
{
try
{
IMessageCallback callback = OperationContext.Current.GetCallbackChannel<IMessageCallback>();
if (!subscribers.Contains(callback))
subscribers.Add(callback);
return true;
}
catch
{
return false;
}
}
public bool Unsubscribe()
{
try
{
IMessageCallback callback = OperationContext.Current.GetCallbackChannel<IMessageCallback>();
if (!subscribers.Contains(callback))
subscribers.Remove(callback);
return true;
}
catch
{
return false;
}
}
}
}
I was thinking I could do something like this but I don't know how to pass the message string from AddMessage to DoSomething...
Dim subscribers As New List(Of IMessageCallback)
Public Sub AddMessage(ByVal message As String) Implements IMessage.AddMessage
Dim action As Action(Of IMessageCallback)
action = AddressOf DoSomething
subscribers.ForEach(action)
'Or this instead of the above three lines:
'subscribers.ForEach(AddressOf DoSomething)
End Sub
Public Sub DoSomething(ByVal callback As IMessageCallback)
'I am also confused by:
'((ICommunicationObject)callback).State
'Is that casting the callback object as type ICommunicationObject?
'How is that done in VB?
End Sub
I would like to install an Apache server into a folder like c:\anything\???\anything2\ under windows.
When I try to start the service it sais that:
httpd: Syntax error on line xx of C:/anything/\xe6\x80\x98\xe6\x80\x99\e6\80\9a/anything2/apache/conf/httpd.conf: ServerRoot must be a valid directory
Does anyone have a solution?
I have a strings like \uXXXX (representation) and I need to convert it into unicode.
I recieve it from 3rd party service so python interpreter don't convert it and I need convertion in my code.
How do I do it in Python?
>>> s
u'\\u0e4f\\u032f\\u0361\\u0e4f'
Hello gurus,
I have a desktop application sending/receiving messages (not files) to/from a WCF service.
How do I intercept the total size of the message to be transferred and receive feedback (number of bytes transferred) during the transmission so a progress bar maybe displayed to the desktop app user?
How many approaches are there? What is the best one given my application scenario?
Any comments or suggestions will be greatly appreciated,
Cullen
I would like to create a function in C# that takes a specific webpage and coverts it to a JPG image from within ASP.NET. I don't want to do this via a third party or thumbnail service as I need the full image. I assume I would need to somehow leverage the webbrowser control from within ASP.NET but I just can't see where to get started. Does anyone have examples?
In an Activity, I need to call a web service every 30 seconds or so, and use the data to update the UI.
Is there a recommended approach on how to schedule a repetitive task?
Thanks
I recently discovered the GDB in Xcode which makes up for some functionality which IMHO seems to be lacking in Xcode.
So I can do the following in GDB:
(gdb) po [LoginManager sharedSession].loginToken
20D52FE9-3573-437E-9A65-846572B63726
However, I have another Service class, which is currently not loaded so I get the following error:
(gdb) po [SessionService displaySessionInfoForToken:@"XXX"]
No symbol "SessionService" in current context.
I don't understand why the LoginManager can be loaded but not the SessionService.
Thought about RESTAPI, but seems OfBiz does not support it out of the box. Hate accessing domain objects directly (although may be enough for our needs, however, would intercept on Service/ECA level).
Any ideas?
Hey,
I have a Handler object that functions kind of like a service. It has a public init method defined in the Implementation but not the Interface. This Handler is also being autowired via Spring. How does the init method get invoked? Is it via Spring or does Tomcat call this?
We are currently discussing the Best Practice for placing the @Transactional annotations in our code.
Do you place the @Transactional in the DAO classes and/or their methods or is it better to annotate the Service classed which are calling using the DAO objects? Or does it make sense to annotate both "layers"?
Experience says that using WSDL-SOAP based webservice for internal consumption is an overkill. There are too many service-based POJO classes that when let into the system complicates it way too much. One option would be use adapter pattern, map the request/response objects to internal domain classes and . But is it even required? Is there a better approach? What are your suggestions?
When I attempt to connect to SQL server using enterprise manager I get the strange message:
"SQL Server is not known to be running. Are you sure you want to connect?"
What is it trying to tell me?
Is there some special caution required in trying to connect to a server that is not known to be running? If so, how do I find out if a server is running before trying to connect to it, and why doesn't enterprise manager provide this service?
Is it possible in my RegisterRoutes method in global.asax, to map some routes to an asmx?
Ideally I would like to do something like:
routes.MapPageRoute("ServiceSearchCats", "services/search/cats", "~/Services/Search.asmx/Cats");
(and therefore my endpoint for the service becomes "http://mydomain.com/services/search/cats", instead of the ugly "http://mydomain.com/Services/Search.asmx/Cats" url)
I have used exception sheilding feature of application block, to map System.Exception with class that is marked as DataContract. It works very well. But When I have mapped the System.Exception with FaultException, I got the below error message.
"An error has occurred while consuming this service. Please contact your administrator for more information. Error ID: fe2d28b5-8d26-430e-baf4-fe4b39da853c"
Please let me know whether I can map the System.Exception with FaultException
Hi,
as in the title, i have:
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet(UriTemplate="abc")]
Stream GetResponse(Stream in);
}
public class Service : IService
{
public Stream GetResponse(Stream in)
{
some_function()
}
}
is it possible to pass a request context to some other function that will respond to the request?
I've written a subscription based web app that I want to charge (by credit card) a monthly fee. There are 3 different plans and once they sign up, they should be billed that amount, automatically, every month until they cancel. Is there an easy way to set this up (some sort of online service maybe?).
Hi All,
I want to modify File/List MetaData of Sharepoint.
For that i am using List.UpdateList method.
But it is Throwing exception:
"Microsoft.Sharepoint.SoapServerException"
I am using Admin account.And using List web Service.
Can i get some good examples of Modifying Metadata of Sharepoint Document using c#(Web Services).
I want to have a form on our main member page that they can submit on, and then I want to pass the username and password to the service which will be embedded in an iframe on our site to allow a seamless login.
I'm using the windows search 4.0 service (wssql) to find some files, it works fine on my computer but on our server which has two drives C: and D: always returns 0 rows when searching D:
Also i'm not sure if it's related but cd d: goes back to c: in the command prompt.
Is there a built in mechanism for server push on Android?
What I want to achieve is to start an application based on a server request (without involving SMS, only data connection).
Is this possible without having a service always running?
Thanks
Flaviu
For an internal customer service application, I want to create a web page that displays name and address along with some other details.
Assume we have 2 printers, PLASER and PLABEL.
Is it possible using CSS, or other methods, to send the entire page to the printer when printer PLASER is selected, and only the name & address, when printer PLABEL is selected?
Hi all,
When I am trying to setup VisualSVN Server in my server. I get error. I can not find solution
Error:
service VisualSVN Server failed to start. Please check VisualSVN Server log in Event Viewer for more details.
Thanks for help.