开发者

Question on how to create WCF silverlight 3 endpoints

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 al开发者_高级运维ready 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.


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>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜