我希望你能幫助我。我試圖連接到第三方web服務,這不幸是一個WSE 2.0服務。我正在嘗試使用WCF在C#.NET 4.0中編寫客戶端。我沒有找到任何信息。該服務需要用戶名和密碼的字符串。這裏是他們的樣本看起來像使用.NET 4.0 WCF連接到用戶/傳球的WSE 2.0 WebService
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的專家或新手。
在此先感謝
您是否具有WSDL的安全策略? – 2012-04-13 19:57:22