Maybe I'm just not getting it, but I have a service that is deployed to an IIS 6 machine. That machine has a LAN address and a Public internet address.
How on earth am I supposed to be able publish this service with both accessible?
At first I thought: No big deal, 2 endpoints. So I have
<endpoint
address="Address 1"
binding="wsHttpBinding"
bindingConfiguration="DefaultBindingConfiguration"
name="RemoteEndpoint" />
<endpoint
address="Address 2"
binding="wsHttpBinding"
bindingConfiguration="DefaultBindingConfiguration"
name="LocalEndpoint" />
The client code then looks like:
public void createServiceProxy()
{
if (Util.IsOperatingLocally())
this.proxy = new ProxyClient("LocalEndpoint");
else
this.proxy = new ProxyClient("RemoteEndpoint");
}
No dice. Can't add the service reference.
No protocol binding matches the given address 'Address 1'. Protocol bindings are configured at the Site level in IIS or WAS configuration.
Then I thought: Maybe the host tag and its dns tag will help. Nope, that's for authentication.
Then I thought: I'll use net.tcp for the local endpoint. Oops... IIS 6 doesn't support net.tcp.
Then I thought: I know, the ProxyClient constructor takes a remoteAddress string as its second parameter. Now it'll look like:
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration="DefaultBindingConfiguration"
name="MyEndpointName" />
public void createServiceProxy()
{
if (Util.IsOperatingLocally())
this.proxy = new ProxyClient("MyEndpointName", "Address 1");
else
this.proxy = new ProxyClient("MyEndpointName", "Address 2");
}
Apparently not. When trying to instantiate the ProxyClient...
Could not find endpoint element with name 'MyEndpointName' and contract MyService.IService' in the ServiceModel client configuration section.
Which leads me to the app.config whose generated client section looks like this:
<client>
<endpoint address="http://localhost:3471/Service.svc" binding="customBinding"
bindingConfiguration="MyEndpointName" contract="MyService.IService"
name="MyEndpointName">
<identity>
<userPrincipalName value="DevMachine\UserNa,e" />
</identity>
</endpoint>
</client>
Which sure doesn't look right to me.
My next thought is not a healthy one. Please help.
The service configuration has been modified to define two endpoints that support the ICalculator contract, but each at a different address using a different binding.
As demonstrated in the Multiple Endpoints sample, a service can host multiple endpoints, each with different addresses and possibly also different bindings. This sample shows that it is possible to host multiple endpoints at the same address.
Each ServiceEndpoint contains an Address, a Binding, and a Contract. The contract specifies which operations are available. The binding specifies how to communicate with the service, and the address specifies where to find the service. Every endpoint must have a unique address.
Endpoints provide clients access to the functionality offered by a WCF service. Each endpoint consists of four properties: An address that indicates where the endpoint can be found. A binding that specifies how a client can communicate with the endpoint. A contract that identifies the operations available.
Here's what I do:
PortClient client = new PortClient(); // from the service reference
EndpointAddress endpointAddress;
if (local)
endpointAddress = new EndpointAddress("http://local/Service.svc");
else
endpointAddress = new EndpointAddress("http://remote/Service.svc");
client.ChannelFactory.CreateChannel(endpointAddress);
client.RemoteMethod();
etc.
Were you actually putting the strings "Address 1" and "Address 2" in the configuration file?
The framework always parses the address to know what transport to use. eg "http://myurl" will use http, "net.pipe://localhost/MyNamedPipeExample" will use IPC.
The error was caused because there was no prefix in the string "Address 1".
I believe this would have worked, without needing to hardcode the addresses:
<endpoint
address="http://serverName/ServiceName/Service.svc"
binding="wsHttpBinding"
bindingConfiguration="DefaultBindingConfiguration"
name="RemoteEndpoint" />
<endpoint
address="http://www.companyName.com/ServiceName/Service.svc"
binding="wsHttpBinding"
bindingConfiguration="DefaultBindingConfiguration"
name="LocalEndpoint" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With