将用户信息传递给wcf [英] pass user info to wcf

查看:176
本文介绍了将用户信息传递给wcf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨〜
我遇到问题,我想将客户端信息传递给wcf,通过调用method可以很容易地做到这一点

客户端程序为:wcfserviceInstance.setclientInfo(name,ip,age,sex)

但是问题是,我在wcf服务中有60个方法,我不希望每个方法都像这样:
wcfserviceInstance.methodA(name,ip,age,sex,methodA_param)
wcfserviceInstance.methodB(name,ip,age,sex,methodB_param)
......

有什么解决方案可以做到吗(wcfserviceInstance.methodB(methodB_param))吗?

我可以设置一些东西,每种方法都可以在wcf服务端通过它自己的方法读取客户端信息.

Hi~
i get a problem, i want to pass client info to wcf , it''s easy to do by calling method to do that

client program as : wcfserviceInstance.setclientInfo(name,ip,age,sex)

but the problem is , i have 60 methods in wcf service , and i don''t want every method look like this :
wcfserviceInstance.methodA(name,ip,age,sex,methodA_param)
wcfserviceInstance.methodB(name,ip,age,sex,methodB_param)
......

is there any solution can do it (wcfserviceInstance.methodB(methodB_param)) ?

can i just setting something , and every method can read client info by it''s own in wcf service side.

推荐答案

您好,
您可以将WCF服务绑定设置为接受客户端凭据.从这里:
http://msdn.microsoft.com/en-us/library/ms789011.aspx [ ^ ]

检查:
Hi,
you can set up your WCF service binding to accept client credentials. From here:
http://msdn.microsoft.com/en-us/library/ms789011.aspx[^]

check:
<wsHttpBinding>
<binding name="WsHttpBinding_ICalculator">
        <security mode="TransportWithMessageCredential" >
           <message clientCredentialType="UserName" />
        </security>
</binding>
</wsHttpBinding>



当您生成客户端服务代理时,客户端对象将具有ClientCredentials属性,而该属性又具有UserName.UserName和UserName.Password.您可以一次初始化这些属性,然后根据需要调用尽可能多的代理方法.代理将为每个呼叫将凭据添加到消息中,以将消息添加到服务.

您应该能够使用诸如"WCF客户端凭据"之类的关键字找到许多示例.

我希望这会有所帮助,

Francesc



When you generate your client side service proxy, the client object will have a ClientCredentials property, which in turn, has a UserName.UserName and UserName.Password. You can initialize these properties once and call as many methods of the proxy as you want. The proxy will add the credentials to the message to the service for every call.

You should be able to find many examples using keywords like "WCF client credentials"

I hope this helps,

Francesc


我找到了,但是我不知道它是否可以在WCF中使用.


客户
CallContext.SetData

服务器
CallContext.getData
I found this , but i don''t know if it works in WCF.


Client
CallContext.SetData

Server
CallContext.getData


这篇关于将用户信息传递给wcf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆