首页 新闻 赞助 找找看

wcf wsHttpBinding 从另一方收到未进行安全处理或安全处理不正确的错误??

0
悬赏园豆:15 [已解决问题] 解决于 2012-08-09 17:28

client web.config如下

  

View Code

server web.config

View Code
一开始访问还不为报错,等停个几分钟再访问就报错了。到底什么原因呢?  
 <system.serviceModel>
      <bindings>
        <wsHttpBinding>
          <binding name="WSHttpBinding_OMSService" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00"
            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"
            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="20000000"
              maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <reliableSession ordered="true" inactivityTimeout="00:20:00" />
            <security mode="Message">
            </security>
          </binding>
        </wsHttpBinding>
      </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="metadataBehavior">
                  <serviceMetadata httpGetEnabled="true" httpGetUrl="http://127.0.0.1:1888/OMSService/Metadata" />
                  <serviceThrottling maxConcurrentCalls="1000" maxConcurrentInstances="1000" maxConcurrentSessions="1000"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service name="OMS.Server.Services.OMSService" behaviorConfiguration="metadataBehavior">
                <endpoint bindingConfiguration="WSHttpBinding_OMSService" address="http://127.0.0.1:1888/OMSService" binding="wsHttpBinding" contract="OMS.Server.Contracts.IOMSService">
                </endpoint>
            </service>
        </services>
    </system.serviceModel>
koi的主页 koi | 初学一级 | 园豆:4
提问于:2012-08-07 14:46
< >
分享
最佳答案
0

FaultException的具体内容是啥?

客户端和服务器的安全设置要保证一致。

<reliableSession ordered="true" inactivityTimeout="00:20:00"
            enabled
="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm
="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite
="Default" />
          </security>

 

是不是报错后,关闭通道后再访问就又好了?

收获园豆:15
Launcher | 高人七级 |园豆:45045 | 2012-08-07 15:42

哦 我再去看一下。 顺便问一下 客户端是网页的wcf应用是不是服务端一定是不能回调客户端的方法的?

koi | 园豆:4 (初学一级) | 2012-08-07 15:45

报错后,我重新登录网站就还可以,等几分钟就又报错

koi | 园豆:4 (初学一级) | 2012-08-07 15:48

@koi: 从目前看来是这样的,因为要实现回调的话,一是使用tcp,那么网页就必须在浏览器端保持一个tcp的连接存活。而是用http,那么网页就必须在浏览器端启动一个端口监听。所以只能用长轮询的模式来实现服务器推,最近有个websocket的技术,没研究过,你也可以试试。wcf 5.0也支持web socket了。

Launcher | 园豆:45045 (高人七级) | 2012-08-07 15:48

@程序猿.码农: 一般来说,是因为服务器已关闭此安全会话通道,而客户端仍然在使用造成的。

Launcher | 园豆:45045 (高人七级) | 2012-08-07 15:53

@程序猿.码农: 出了session时间的限制 还有没别的什么时间限制会影响通道?

koi | 园豆:4 (初学一级) | 2012-08-07 16:00

@koi: 目前暂时没有。

Launcher | 园豆:45045 (高人七级) | 2012-08-07 16:10

@程序猿.码农: 那下面的 userCallback 没用的吗(如果不可以调用客户端的方法)? 

IService:

[OperationContract(AsyncPattern = true)]
IAsyncResult BeginAsy(string fileName, AsyncCallback userCallback, object stateObject);
string EndAsy(IAsyncResult asynResult);

koi | 园豆:4 (初学一级) | 2012-08-07 17:38

@koi: 你说的是服务器端异步,因为你说回调客户端,我就以为你说的是回调契约。服务器端异步是支持的,但是这个 userCallback 不是调用客户端的方法,该 userCallback 是服务器端异步操作完成后的通知操作,用于对异步调用完成后的结果作一些同步处理.

 

userCallback 的一切都只会发生在服务器端,同时也不会跟客户端有任何关系。

Launcher | 园豆:45045 (高人七级) | 2012-08-07 17:47

@程序猿.码农: 

服务端Service(实现上面的Iservice):那在BeginAsy里要返回一个实现了IAsyncResult接口的类的对象,在asp.net里是保持长连接是AsyncCallback 对象不调用的话连接就不返回,而现在wcf服务端有EndXXX方法(这个例子里是EndAsy,调用完这个方法就返回了吧,这个方法是一定会调用),怎么保持这个链接?

koi | 园豆:4 (初学一级) | 2012-08-07 22:50

@koi: 在服务器端,保持连接的方式就是不调用 userCallback.

Launcher | 园豆:45045 (高人七级) | 2012-08-08 10:16

@程序猿.码农: 但是调用了EndAsy方法后就算没有调用userCallback结果也是返回了(这个时候连接还没返回的吗?)

koi | 园豆:4 (初学一级) | 2012-08-08 12:19

@koi: EndAsy是被WCF调用的,触发 WCF 调用 EndAsy 的是你在 BeginAsy 中返回的 IAsyncResult .因此在你实现 IAsyncResult 的时候,你可以控制什么时候由IAsyncResult.AsyncWaitHandle 发出完成指令。

Launcher | 园豆:45045 (高人七级) | 2012-08-08 13:16

@程序猿.码农: 哦 谢了

koi | 园豆:4 (初学一级) | 2012-08-09 17:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册