I use wshttpbinding in my service Config and message security. My app works fine but after 10 or 20 min when client calls any method of service, an exception throws because my security token will be expired, and connection can't work.
One solution is to recreate the connection to make a new token (but I can't use this because my service contains datacontext and if I recreate the service, the datacontext will be new).
Other solution is to change the security type from message to transport (I tried this solution but nothi开发者_Go百科ng changed because another exception was thrown).
I am assuming that when you say datacontext you mean Enitity Framework datacontext.
Your solution appears to depend on the datacontext being available when the client returns. This is a very brittle approach. Even if you increased all the relevant timeouts, you would still get errors if for example the server restarted.
Take a look at WCF Data Services http://msdn.microsoft.com/en-us/data/bb931106.aspx
Best Solution is Make re-create your connection in each calling service method. But in my position I cant use that because our Framework provide Special problem. Even with my Special problem I use that solution With Special Trick.;)
I made a method return true.and I call It 10 min after last call.This make Service Token never Expired until Application closed. And for last use Try-Catch and handle Exception throw by Service.
With Special Thank from "Shiraz Bhaiji"
精彩评论