Problem with WCF netMessagingBinding


  • Hi All!

    I have problem with netMessagingBinding and can't setup it.

    I have WCF service in worker role and client code that used it.

    This is how I start my service host:

                Uri uri = ServiceBusEnvironment.CreateServiceUri("sb", "#NAMESPACE#", "#PATH#");
                ServiceHost host = new ServiceHost(typeof(AnswerOneWay), uri);
                ContractDescription contractDescription = ContractDescription.GetContract(typeof(IAnswerContractOneWay), typeof(AnswerOneWay));
                ServiceEndpoint endpoint = new ServiceEndpoint(contractDescription)
                    Address = new EndpointAddress(uri),
                    Binding = new NetMessagingBinding
                        SendTimeout = TimeSpan.FromMinutes(3),
                        ReceiveTimeout = TimeSpan.FromMinutes(3),
                        OpenTimeout = TimeSpan.FromMinutes(3),
                        CloseTimeout = TimeSpan.FromMinutes(3),
                        TransportSettings = new NetMessagingTransportSettings { BatchFlushInterval = TimeSpan.FromSeconds(1) },
                endpoint.Behaviors.Add(new TransportClientEndpointBehavior
                    TokenProvider = TokenProvider.CreateSharedSecretTokenProvider("owner", "#KEY#")
                if (host.Description.Behaviors != null)
                    foreach (ServiceDebugBehavior behavior in host.Description.Behaviors.OfType<ServiceDebugBehavior>())
                        (behavior).IncludeExceptionDetailInFaults = true;       

    Here is my system.serviceModel section

            <add name="netMessagingTransport" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingTransportExtensionElement, Microsoft.ServiceBus, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            <add name="netMessagingBinding" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingBindingCollectionElement, Microsoft.ServiceBus, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            <add name="transportClientEndpointBehavior" type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <behavior name="securityBehavior">
                  <sharedSecret issuerName="owner" issuerSecret="#KEY#" />
            <binding name="messagingBinding" sendTimeout="00:03:00" receiveTimeout="00:03:00" openTimeout="00:03:00" closeTimeout="00:03:00">
              <transportSettings batchFlushInterval="00:00:01" />
          <endpoint name="QuestionsService.Answers.MSMQ"
              contract="QuestionsServiceOneWay.Contracts.IAnswerContractOneWay" />

    Here is my error whe I try use it:

    EXCEPTION:   Message: A user callback threw an exception.  Check the exception stack and inner exception to determine the callback that failed.    Method:  Void OnFaulted()    Source:  System.ServiceModel    Exception type: System.Runtime.CallbackException    Stack trace:       at System.ServiceModel.Channels.CommunicationObject.OnFaulted()     at System.ServiceModel.Channels.CommunicationObject.Fault()     at System.ServiceModel.Channels.ServiceChannel.OnInnerChannelFaulted(Object sender, EventArgs e)     at System.ServiceModel.Channels.CommunicationObject.OnFaulted()     at System.ServiceModel.Channels.CommunicationObject.Fault()     at Microsoft.ServiceBus.Messaging.Channels.ServiceBusOutputChannel.Send(Message message, TimeSpan timeout)     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)     at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)     at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)     at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)     at QuestionsServiceOneWay.Contracts.IAnswerContractOneWay.SaveComment(Int64 senderID, Int64 answerID, CommentType type)     at Questions.App.Web.Controllers.AnswerCommentController.OnProcess(HttpContext context) in D:\Max\Work\Projects\Applications\Web\Questions.App\Web\Controllers\AnswerCommentController.cs:line 40     at Questions.App.Web.Controllers.BaseController.Process(HttpContext context) in D:\Max\Work\Projects\Applications\Web\Questions.App\Web\Controllers\BaseController.cs:line 41     at Questions.App.Web.WCFHttpHandler.ProcessRequest(HttpContext context) in D:\Max\Work\Projects\Applications\Web\Questions.App\Web\WCFHttpHandler.cs:line 85     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)        

    Sunday, April 15, 2012 9:10 PM


All replies

  • Hello, Would you like provide WCF Trace about this exception?  The Stack messge just shows callback exception in OnFaulted() method, open WCF trace, and find more about inner exception.


    Monday, April 16, 2012 5:08 AM
  • Thank you, service bus is not available on emulator as I understand, so I need trace this not in emulator. In link that you send me describes how to enable WCF trace to file. But in the cloud I do not have such an opportunity, only DB?
    Monday, April 16, 2012 7:01 AM
  • Hi,

    1. Does it work if you host the service in a Console application?

    2. When does the exception thrown? Am I right that it happens when client call service and the client is a ASP.NET application? Does it work if you use Console to test?

    If it still doesn't work please send me a repro (Console service + Console client): allenc

    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 16, 2012 10:02 AM
  • Hi, Allen!

    My answers.

    1. I try to host it in Console Application. I am right that I need create Windows Console Application project, and create it as worker role?

    2. Yes you a rigth this exception is thrown when client is call service. Client is ASP.NET application

    Monday, April 16, 2012 10:39 AM
  • Hi,

    >I try to host it in Console Application. I am right that I need create Windows Console Application project, and create it as worker role?

    No you don't need worker role to test. It is recommended to use a Windows Console application to test. If it works you can use worker role to see whether it works. In this way some potential issues involved by worker role and local simulator can be excluded in testing.

    Also you can refer to below sample about netMessagingBinding:

    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 17, 2012 9:39 AM
  • Problem solved. Reason is than I need create queue in management portal for my namespace. Thank you
    • Marked as answer by Max951 Thursday, April 19, 2012 10:02 PM
    Thursday, April 19, 2012 10:02 PM