2012-04-13 84 views
0

我希望你能幫助我。我試圖連接到第三方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的專家或新手。

在此先感謝

+0

您是否具有WSDL的安全策略? – 2012-04-13 19:57:22

回答

1

從理論上講,你也許可以建立正確的擴展和行爲來獲得WCF生產&消費WSE 2.0肥皂,但你對你自己在這裏。 WSE 3.0和WCF之間存在一些互操作性,如blog post.所述。您可以將其用作嘗試使用WSE 2.0服務的起點。

你可能會更好,直接與原WSE 2.0組件工作,如果你能找到的Visual Studio 2003的副本,我依稀記得WSE 2.0有3個服務包,向後兼容,所以你應該確保你匹配正確的服務包。 祝你好運&祝願! :)

0

我不建議您使用WSE2。在最糟糕的情況下--Wcf無法與此服務進行互操作 - 您最好自己創建用戶名頭,這並不難。但要確定最佳方式,請發佈一個完整的工作肥皂樣本(供應商應該提供一個)

相關問題