Home » Visual StudioRSS

Problem with IBM WMQ Channel for WCF

Hi,
    I'm trying to use IBM WMQ as a transport in my WCF service application. The following is the service code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using IBM.XMS.WCF;

namespace DB.WCF
{
    [ServiceContract]
    public interface IBasicService
    {
        [OperationContract]
        String SayHello(String name);
    }
    public class BasicService : IBasicService
    {
        public string SayHello(string name)
        {
            return "Hello " + name;
        }
    }
}

The web.config looks like this :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
    <service name="DB.WCF.BasicService" behaviorConfiguration="basicServiceBehavior">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8000/basicservice/"/>
        </baseAddresses>
      </host>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
      </service>
      </services>
    <bindings>
      <customBinding>
        <binding name="CustomBinding_IBasicService">
          <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
              messageVersion="Default" writeEncoding="utf-8">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </textMessageEncoding>
          <IBM.XMS.WCF.SoapJmsIbmTransportChannel maxBufferPoolSize="524288" maxMessageSize="65536"
              clientConnectionMode="0" />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="jms:/queue?destination=SampleQ@QM1&amp;connectionFactory=connectQueueManager(QM1)&amp;initialContextFactory=com.ibm.mq.jms.Nojndi&amp;replyDestination=SampleReplyQ"
          binding="customBinding" bindingConfiguration="CustomBinding_IBasicService"
          contract="DB.WCF.BasicService" name="CustomBinding_IBasicService" />
    </client>
    <extensions>
      <bindingElementExtensions>
        <add name="IBM.XMS.WCF.SoapJmsIbmTransportChannel" type="IBM.XMS.WCF.SoapJmsIbmTransportBindingElementConfig, IBM.XMS.WCF, Version=7.0.1.0, Culture=neutral, PublicKeyToken=8c7c0be90afcd8ba" />
      </bindingElementExtensions>
    </extensions>
    <behaviors>
      <serviceBehaviors>
        <behavior name="basicServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

I'm facing two problems with the above setup.

1. I'm unable to hit the service using the baseaddress (http://localhost:8000/basicservice/) when using add service reference(ASR) in VS 2008. ie. I get "This page cannot displayed" error message in IE.
2. Now if I use the URL "http://localhost/basicservice/basicservice.svc " to hit the service in IE, I get the following error.

Service 'DB.WCF.BasicService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.Description:  An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details:  System.InvalidOperationException: Service 'DB.WCF.BasicService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[InvalidOperationException: Service 'DB.WCF.BasicService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.]
System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreNonMexEndpoints(ServiceDescription description) +279
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +64
System.ServiceModel.ServiceHostBase.InitializeRuntime() +37
System.ServiceModel.ServiceHostBase.OnBeginOpen() +27
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +49
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +121
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479

[ServiceActivationException: The service '/basicservice/basicservice.svc' cannot be activated due to an exception during compilation. The exception message is: Service 'DB.WCF.BasicService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element..]
System.ServiceModel.AsyncResult.End(IAsyncResult result) +11531006
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +278
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


Any idea why this happens? Please help.

Thanks
Dileep Krishnan
 

5 Answers Found

 

Answer 1

Hi Dileep,

Please have a look at how to specify the endpoints for WCF service  in this scenario. I would think that there are some errors about defining the endpoints.
http://msdn.microsoft.com/en-us/library/ms733821.aspx
 

Answer 2

Hi Dileep,

It seems you're using some IBM specific jms component to build a custom WCF message. Based on the error message, it indicate that the WCF hosting runtime cannot find an endpoint exposed with the configuration. And in the following configuration section(<services><service>....), I find that you only expose a mex (metadata) endpoint, where is the main endpoint of your service(which expose the main function logic)?
 <system.serviceModel>
    <services>
    <service name="DB.WCF.BasicService" behaviorConfiguration="basicServiceBehavior">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8000/basicservice/"/>
        </baseAddresses>
      </host>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
      </service>
      </services>

You should add  an additional endpoint which correspond to the "IBasicService" contract.
 

Answer 3

Dear Cheng,
                Thank you for your response. I'll definitely try it out and let you know the results.

Regards
Dileep Krishnan 
 

Answer 4

Hi Dileep,

I am having the same issue, however I did specify an endpoint that corresponds to my contract;
"ISomethingService". Did you have any further luck in figuring out this error or what was truly causing this issue to arise? Please let me know, thanks!

Adrian
 

Answer 5

What worked for me is programmatically adding the endpoint as specified in the IBM samples. Trying to do the same thing with baseAddress, mexEndpoint and actual MQ endpoint in the configuration file doesn't seem to work -atleast for me. If anyone made it work via configuration, I would like to know about it.

Also, I am interested in knowing how someone has hosting the services exposing MQ endpoints. You can reply to my post http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/6b278914-a526-4823-a94b-9adaaf9805a1/ regarding that.


Thanks, Lakshman
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter