OK, so the most important things are:
and then some additional stuff thrown in.
1) Address:
Get this from here:
WebServiceHost host = new WebServiceHost(
typeof(MyService), new Uri("http://localhost:80/"));
host.AddServiceEndpoint(typeof(MyService), new WebHttpBinding(), "");
and here:
ServiceEndpoint sbEndpoint = host.AddServiceEndpoint(
typeof(MyService), new WebHttpRelayBinding(), "http://azureURL");
so you'll need something like:
<endpoint address=""
<endpoint address="http://azureURL"
<endpoint address=""http://someURL"
in your service.
2) Binding:
The first endpoint is a webHttpBinding, the second one uses a custom binding ("MyBinding") - so you have:
<endpoint address=""
binding="webHttpBinding"
<endpoint address="http://azureURL"
binding="webRelayHttpBinding"
<endpoint address=""http://someURL"
binding="myBinding"
and you'll need to define your custom binding:
<bindings>
<customBinding>
<binding name="MyBinding">
.. define the parameters of your binding here
</binding>
</customBinding>
</bindings>
or create a <extensions>
section for your binding stored in code in a separate assembly.
3) Contracts
I don't clearly see a contract anywhere - you only ever use the typeof(MyService), but usually, this is the concrete service instance, not the service contract which should be an interface (something like IMyService
). Why don't you have an explicit service contract?
Anyway, if your service implementation is the contract, too, at the same time (not best practice! but possible), then you have your two endpoints like this:
<endpoint address=""
binding="webHttpBinding"
contract="MyService" />
<endpoint address="http://azureURL"
binding="webHttpRelayBinding"
contract="MyService" />
<endpoint address="http://someURL"
binding="myBinding"
contract="MyService" />
You then need to add a few sprinkles here and there (define the "base address" of the service, give the service a name and so on), and should end up with something like:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="MyBinding">
.. define the parameters of your binding here
</binding>
</customBinding>
</bindings>
<services>
<service name="YourNameSpace.MyService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:80/" />
</baseAddresses>
</host>
<endpoint address=""
binding="webHttpBinding"
contract="MyService" />
<endpoint address="http://azureURL"
binding="webHttpRelayBinding"
contract="MyService" />
<endpoint address="http://someURL"
binding="myBinding"
contract="MyService" />
</service>
</services>
</system.serviceModel>
Now all you're missing is the behavior defined - I'll leave that as an exercise for the poster :-)
Does that help anything?
As for references - hmmm..... hard to say.... I guess the usual books ("Learning WCF" by M.L.Bustamante for beginner/intermediate, "Programming WCF" by Juval Lowy for intermediate/advanced) are my best bet, and lots of experience, really. I don't know of any source that explicitly shows and teaches how to convert between settings in code and config - the two books mentioned usually show both ways, and from this, you can figure it out yourself.
Marc