我希望你能帮帮我。我正在尝试连接到第三方WSE服务,不幸的是,这是一个WSE 2.0服务。我正在尝试使用WCF在C# .NET 4.0中编写客户端。我找不到任何关于这方面的信息。该服务需要用户名和密码的字符串。下面是他们的样例
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专家或新手。
提前感谢
发布于 2012-04-14 04:06:55
从理论上讲,您可能可以创建正确的扩展和行为来让WCF生产和使用WSE2.0SOAP,但在这里只能靠您自己了。在WSE3.0和WCF之间有一些互操作,如本blog post.中所述,您可以将其作为尝试使用WSE2.0服务的起点。
如果您可以找到Visual Studio2003的副本,那么直接使用原始的WSE2.0组件可能会更好。我依稀记得WSE2.0有3个不能向后兼容的服务包,所以您应该确保匹配正确的服务包。祝你好运,祝你好运!!:)
发布于 2012-04-14 05:23:31
我不建议您使用WSE2。在最糟糕的情况下- Wcf不能与此服务互操作-您最好自己创建用户名标头,这并不太难。但为了确定最佳方式,请发布完整的工作soap示例(供应商应提供一个)
https://stackoverflow.com/questions/10146869
复制相似问题