Anyone got IIS working reliably as a WCF client

空扰寡人 提交于 2019-12-04 22:00:43

We are using IIS 7 hosting about 20 services with the net.tcp and net.pipe bindings and it's working fine.

Your problem with the pipe looks like a misconfiguration to me. If it helps, this is how we have them configured:

Server:

 <endpoint address ="" binding="fooBinding" 
           contract="Bla.IBlaAPI" 
           bindingConfiguration="BlaAPI.BindingConfig">

Binding config:

<binding name="BlaAPI.BindingConfig"
                 receiveTimeout = "10:50:00"
                 sendTimeout = "10:50:00"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 transactionFlow="false">
          <readerQuotas maxDepth="32"
                       maxStringContentLength="2147483647"
                       maxArrayLength="2147483647"
                       maxBytesPerRead="8192"
                       maxNameTableCharCount="2147483647" />
          <security mode="None"/>
</binding>

Note that we are using long timeouts and have really high quotas for message size and etc. because we are passing some big chunks of data through this service. You can adjust for your own needs. We have the security set to "none" because the service is only being contacted from the local machine which is secured. Again, your mileage may vary.

Client:

<endpoint name="Bla.Bindings.BlaAPI" address="net.pipe://localhost/bla/IBlaAPI.svc"
                behaviorConfiguration="BlaAPI.ServiceBehavior"
                binding="netNamedPipeBinding" bindingConfiguration="BlaAPI.BindingConfig"
                contract="Bla.IBlaAPI" />

About the Faulted state problem, please note that if an unhandled exception occurs during execution of the service code, the service instance will remain in Faulted state until it is closed properly. To avoid this, either handle exceptions at service top-level or use, for example, Enterprise Library Excexption Handling blocks.

Re NetNamedPipeBinding and "There was no endpoint listening at net.pipe://localhost/mypipename"

Is your web application impersonating its users? The above error is what you get if you try to access a WCF service via the named pipe binding, in a security context whose logon token has membership of NETWORK USERS. The WCF client-side channel stack doesn't distinguish between access denied errors and "not found" errors, when it attempts to read the shared memory object created by the service to publish the name of the pipe in use. (See http://blogs.charteris.com/blogs/chrisdi/archive/2008/05.aspx etc)

Impersonation tokens in an IIS application will always have NETWORK USERS membership.

Can you show me the code you use to dispose of the wcf client proxy?

Never use 'using' on a wcf proxy, as it will not dispose correctly every time. This can possibly lead to the faulted state.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!