首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过user/pass使用.NET 4.0WCF连接到WSE2.0 WebService

通过user/pass使用.NET 4.0WCF连接到WSE2.0 WebService
EN

Stack Overflow用户
提问于 2012-04-14 03:08:29
回答 2查看 1.8K关注 0票数 0

我希望你能帮帮我。我正在尝试连接到第三方WSE服务,不幸的是,这是一个WSE 2.0服务。我正在尝试使用WCF在C# .NET 4.0中编写客户端。我找不到任何关于这方面的信息。该服务需要用户名和密码的字符串。下面是他们的样例

代码语言:javascript
复制
Using webServiceObject As Microsoft.Web.Services2.WebServicesClientProtocol = New WSOData.Webservices.TransactionWebService()
https = ConcatenateWebserviceAddress(request.Server.Https, request.Service.Extension)
epr = New EndpointReference(New Uri(https))
webServiceObject.Destination = epr

Dim WebserviceContext As SoapContext = webServiceObject.RequestSoapContext

''''' Set the security settings
 ' Set the timeout value for how long issued SecurityContextToken security tokens are valid
WebserviceContext.Security.Timestamp.TtlInSeconds = -1

'Instantiate a new UsernameToken object.
Dim userNameToken As New UsernameToken(userName, password, PasswordOption.SendHashed)

'Add the token to the SoapContext.
WebserviceContext.Security.Tokens.Add(userNameToken)

'Generate a signature using the username token, and add the signature to the SoapContext.
 WebserviceContext.Security.Elements.Clear()
 WebserviceContext.Security.Elements.Add(New MessageSignature(userNameToken))

有没有办法在.NET 4.0中使用WCF来实现这一点呢?如果可以的话,我真的不想求助于使用WSE 2.0。我也无法控制我们要连接的服务。任何帮助都将不胜感激,我决不是WCF专家或新手。

提前感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-04-14 04:06:55

从理论上讲,您可能可以创建正确的扩展和行为来让WCF生产和使用WSE2.0SOAP,但在这里只能靠您自己了。在WSE3.0和WCF之间有一些互操作,如本blog post.中所述,您可以将其作为尝试使用WSE2.0服务的起点。

如果您可以找到Visual Studio2003的副本,那么直接使用原始的WSE2.0组件可能会更好。我依稀记得WSE2.0有3个不能向后兼容的服务包,所以您应该确保匹配正确的服务包。祝你好运,祝你好运!!:)

票数 1
EN

Stack Overflow用户

发布于 2012-04-14 05:23:31

我不建议您使用WSE2。在最糟糕的情况下- Wcf不能与此服务互操作-您最好自己创建用户名标头,这并不太难。但为了确定最佳方式,请发布完整的工作soap示例(供应商应提供一个)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10146869

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档