tags:

views:

30

answers:

1

Hello, How do I use a ServiceHostFactory with multiple bindings??

This is what I've tried and I keep getting issues...one after another error... Please help me correct this..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Web.Services.Description;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;

namespace WcfService7
{
    public class clsMyOwnServiceHost:ServiceHostFactory
    {

               protected override ServiceHost CreateServiceHost( Type t, Uri[] baseAddresses )
               {
                                           NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
                   BasicHttpBinding basicbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
                   WSHttpBinding wsbinding = new WSHttpBinding(SecurityMode.None);
                   ServiceHost host = new ServiceHost(t, baseAddresses);
                   foreach(Uri uri in baseAddresses)
                   {



                       host.AddServiceEndpoint(typeof(IService1), basicbinding,  uri);
                       host.AddServiceEndpoint(typeof(IService1), wsbinding, uri);

                       host.AddServiceEndpoint(typeof(IService1), binding, uri);


                   }

                   return host;
               }

    }
}

Thanks

A: 

The uri needs to be different for each binding type.

TCP: net.tcp://{hostname}[:port]/{location}
Basic HTTP: http://{hostname}[:port]/{location}
WS HTTP: http://{hostname}:{port}/{location}

Noel Abrahams
thats right...but...what should it be? How should I change it?
Josh
tried that,but its not working....
Josh
@Josh, actually you are doing something else wrong here: for URI you just need to pass a relative address - not the base address.
Noel Abrahams
How do I correct it?
Josh
Assuming Uri[] baseAddresses are specified correctly (as in my answer, but without the {location}) then all you need is the {location} string.
Noel Abrahams