The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
For me the issue was caused by config file automatically genearted by importing the WSDL. I updated the binding to from basicHttpBinding to customBinding. Adding additional exception handling did not help pointing this out.
Before
<basicHttpBinding>
<binding name="ServiceName">
<security mode="Transport" />
</binding>
</basicHttpBinding>`
After
<customBinding>
<binding name="ServiceName">
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport />
</binding>
</customBinding>`
I know this is an older post but one thing to watch out for when you cannot change the security is to make sure that your username and password are set.
I had a service with authenticationMode as UserNameOverTransport, when the username and password were not set for the service client I would get this error.
As a matter of fact, if unsuccessful after following suggestions by marc_s, please keep in mind that a <security> element in server binding configuration (or lack thereof) in web.config on the server may cause this exception. For instance the server is expecting Message
-level security and client is configured to None
(or, if the server is not part of an Active Directory domain but the remote client host is).
Tip: In such cases the client app will most likely invoke the web service fine when executed directly on the server machine under administrative account in RDP session.
If you see this message in Debug from Visual Studio and solution contains WCF project. Then open this WCF project settings -> go to "WCF Options" tab -> off "Start WCF Service Host when debugging..." option
I had the same problem while trying to consume net.tcp wcf service endpoint in a http asmx service.
As I saw no one wrote specific answer WHY is this problem occurring, but only how to be handled properly.
I've been struggling with it several days in a row and finally I found out where the problem comes from in my case.
Initially I thought that when you make a reference to a service the config file will be configured regarding security tag the same way as it's in the source, but that was not the case and I should take care of it manually. In my case I had only
<netTcpBinding>
<binding name="NetTcpBinding_IAuthenticationLoggerService"
</binding>
</netTcpBinding>`
Later I saw that the security part is missing and it should looks like this
<netTcpBinding>
<binding name="NetTcpBinding_IAuthenticationLoggerService" transferMode="Buffered">
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</netTcpBinding>
The second problem in my case was that I was using transferMode="Streamed"
on my source WCF service and in the client I had nothing specific about it, which was bad, because the default transferMode
is Buffered
and it's important on both places source and client to be configured in the same way.
I had another problem, that I don't think have been mentioned in the other answers.
I have to service endpoints on the same tcp address and port. In the app.config, I had forgotten to add both endpoints, so the service was running on the correct port, but with the wrong service interface.