views:

367

answers:

2

I wanted to consume a WCF service with a silverlight application and a asp.net mvc application, and I'm having difficulties to configure the service to support both requests.

these are my endpoints for the WCF config file.

  <service behaviorConfiguration="behaviorAction" name="Uniarchitecture.ProdutoService.ServiceImplementations.ProdutoService">
    <endpoint binding="wsHttpBinding" bindingConfiguration="bindingAction" contract="Uniarchitecture.ProdutoService.ServiceContracts.IProdutoService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="" binding="basicHttpBinding" contract="Uniarchitecture.ProdutoService.ServiceContracts.IProdutoService"/>

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

I'm getting the following error: A binding instance has already been associated to listen URI 'net.tcp://localhost:10377/ProdutoService'. 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.

A: 

The problem is trying to use two endpoints with two bindings... You can use multiple endpoints on the same service here, but they need to use the same binding.

And since Silverlight only supports BasicHttpBinding you're kind of stuck with it.

<service behaviorConfiguration="behaviorAction" name="Uniarchitecture.ProdutoService.ServiceImplementations.ProdutoService">
    <endpoint binding="**basic**HttpBinding" bindingConfiguration="bindingAction" contract="Uniarchitecture.ProdutoService.ServiceContracts.IProdutoService"/>
    <endpoint address="" binding="basicHttpBinding" contract="Uniarchitecture.ProdutoService.ServiceContracts.IProdutoService"/>
</service>
Bobby
Just a note, Silverlight 3 supports a binary binding in addition to BasicHttpBinding. In fact, its the new default when you create a new Silverlight-enabled WCF service.
Dan Auclair
I just need then to use 1 endpoint for both? Or should I use the binary binding for both?
Diego Correa
I've made only one endpoit for basichttpbinding now I'm getting this error :Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it.
Diego Correa
A: 

In your config, the addresses of the two endpoints are the same. With HTTP bindings, you can have multiple endpoints for a service, but you need to specify different addresses for them. Change the address of the basicHttpBinding endpoint to fix this problem.

Will Rogers