views:

151

answers:

1

I have a service exposed as WCF via NServiceBus. Ultimately, I'd like to call to this service from silverlight. My WCF Service Interface looks like this:

[ServiceContract]
public interface ISettingsService
{
    [OperationContract(Action = "http://tempuri.org/IWcfServiceOf_RequestSettingsMessage_SettingsResponseMessage/Process", ReplyAction = "http://tempuri.org/IWcfServiceOf_RequestSettingsMessage_SettingsResponseMessage/ProcessResponse") ]
    SettingsResponseMessage FetchSettings(RequestSettingsMessage request);
}

My NSB WCF service is defined as:

public class CoreService : WcfService<RequestSettingsMessage, SettingsResponseMessage>
{
}

When I invoke the FetchSettings method on the service, I get an exception:

System.TypeInitializationException: The type initializer for 'NServiceBus.WcfSer vice`2' threw an exception. ----> System.InvalidOperationException: Centerlink.Services.Core.Msg.Settings.SettingsResponseMessage must be an enum representing error codes returned by the server.

It seems that the WcfService<> class is restricting the return type of a WCF method to be an enum. How can I have my service return something other than an enum? Do I need to create a custom implementation of NServiceBus.WcfService<>?

+1  A: 

You need to create your own wcf service for that scenario.

More details here:

http://tech.groups.yahoo.com/group/nservicebus/message/6295

Andreas
I see that this restriction is used to prevent NSB from being used inappropriately. Is it recommended that NSB never be used to query data?
Todd Stout
Short answer: YesLong answer: http://andreasohlund.blogspot.com/2010/04/messaging-shouldn-be-used-for-queries.html
Andreas