pallz

Can i have a contract with multiple endpoints

Conversely, can I have multiple contratcs listening to same Endpoint

After going thru the WCF TechnologySamples I tried few things...

My config looks like this...

<system.serviceModel>

<bindings>
<wsHttpBinding>
<binding name="mybind1">
<security mode="None" />
</binding>
<binding name="mybind2">
<security mode="None" />
</binding>
</wsHttpBinding>

<wsDualHttpBinding>
<binding name="mydual">
<security mode="None"/>
</binding>
</wsDualHttpBinding>
</bindings>

<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>

<services>
<service behaviorConfiguration="MyServ" name="MyTestService.MyService">
<clear />
<endpoint binding="wsHttpBinding"
name ="E1"
bindingConfiguration="mybind1"
contract="MyTestService.IAdd" />

<endpoint binding="basicHttpBinding"
name="E2"
contract="MyTestService.ISub"/>

<endpoint address="secure"
name="E3"
binding="wsHttpBinding"
bindingConfiguration="mybind2"
contract="MyTestService.ISub" />

<endpoint binding="wsDualHttpBinding"
bindingConfiguration="mydual"
name="E4"
contract="MyTestService.IMultiply" />

<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>

<behaviors>
<serviceBehaviors >
<behavior name="MyServ">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

I m hosting on IIS 7.0, I get following error

A binding instance has already been associated to listen URI 'http://localhost/WCF/service.svc'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.

My service contratcs are as follows

[ServiceContract()]
public interface IAdd
{
[OperationContract]
double Addition(double x, double y);
}

[ServiceContract()]
public interface ISub
{
[OperationContract]
double Subtraction(double x, double y);
}

[ServiceContract( SessionMode = SessionMode.Required ,CallbackContract = typeof(IMultiplyCallback))]
public interface IMultiply
{
[OperationContract(IsOneWay=true) ]
void Multiply(double x, double y);
}

public interface IMultiplyCallback
{
[OperationContract(IsOneWay=true )]
void MultiplyResult(double result);
}

Does this mean that I cannot have multiple contracts of which few are exposed to multiple end points in the same service (not considering business logic for the time-being)



Re: Windows Communication Foundation (Indigo) Multiple Contratcs/Multiple Endpoints

Brian McNamara - MSFT

pallz wrote:

Can i have a contract with multiple endpoints

Conversely, can I have multiple contratcs listening to same Endpoint

Yes and yes.

The first is very simple, just define multiple endpoints with different bindings and addresses that reference the same contract.

The second is possible with certain restrictions. You must use the same binding; as you found out from your error message - at most one channel stack can 'listen' at a particular address. Also, the contracts cannot 'overlap' with their message filters; see http://msdn2.microsoft.com/en-us/library/aa395210.aspx for more details.






Re: Windows Communication Foundation (Indigo) Multiple Contratcs/Multiple Endpoints

pallz

Hey Brian,

The above jus does not work...until I comment the Endpoint E1 and E4.

Additionally, i did chk the sample available on the link you posted....but then in my case...

cant I hv all the three contratcs IAdd, ISub and IMultiply exposed

This sample was for a demo to show multiple contratcs being exposed each with diff endpoint config...

is it not possible

Can u suggest changes





Re: Windows Communication Foundation (Indigo) Multiple Contratcs/Multiple Endpoints

Brian McNamara - MSFT

E1, E2, and E4 in your example all have the same address, but different bindings. As I said before, this is not allowed; only one binding/channel stack can listen at a single Uri.

(And so for the demo, change the address of each endpoint.)






Re: Windows Communication Foundation (Indigo) Multiple Contratcs/Multiple Endpoints

Vinod Sa

Thanks for solution,

I had same problem. Smile

Thanks,

Vinod Sa.





Re: Windows Communication Foundation (Indigo) Multiple Contratcs/Multiple Endpoints

Vinod Sa

Hi,

My scenario is same as explained above.

I have service contract exposed with 2 endpoints "wsHttpbinding" and "basicHttpBinding".

Question 1:

Now when I add reference to WCF service I get all(In this case two endpoints) the endpoints in client side,I want to avoid that for security reason and I want when client add service reference he gets only one endpoint instead of two(either "wsHttpbinding" or "basicHttpBinding".).How can I configure such setting