Search code examples
c#wcf

wcf service c# .net framework 4.5.1


I hosted a wcf service on winform, it worked well while I call the service in local (same server), but the client differrent IP (same domain) it throwed an exception : The message could not be processed. This is most likely because the action 'http://tempuri.org/ICenterService/SaveCoursesIntoAllDevices' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.

Please help me thanks


Solution

  • According to the configuration file you provided, I found that you did not apply WSHttpBinding_ICenterService to the endpoint.This may be the cause of the error, because if you use wsHttpBinding and the client and server are not on the same computer, you need to set security mode="None".

    <services>
                <service behaviorConfiguration="CenterServer.Services.CenterServiceBehavior" name="Ecotek.Communication.HostWebService.CenterService">
                    <host>
                        <baseAddresses>
                            <add baseAddress="http://192.168.1.129:6085/SyncServices" />
                        </baseAddresses>
                    </host>
                    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
                    <endpoint address="" binding="wsHttpBinding" contract="Ecotek.Communication.HostWebService.ICenterService" bindingConfiguration="WSHttpBinding_ICenterService">
                        <identity>
                            <dns value="localhost" />
                        </identity>
                    </endpoint>
                </service>
            </services>
    

    You need to apply the binding configuration to the endpoint.