[英]Need a “SOAP Client with WSSE authentication” … does Visual Studio fit this need?
我需要連接的Web服務具有上述要求。 我可以在VS 2008中使用此Web服務但不能使用它,因為我不知道如何進行身份驗證。 我需要指定credentails,但是沒有公開“header”方法。 我嘗試過以下內容:
UltraDNSWebReference.UltraWebServiceService clientProxy =
new UltraDNSWebReference.UltraWebServiceService();
clientProxy.Credentials = new System.Net.NetworkCredential(
"MyUserName", "MYPassword");
但我仍然收到身份驗證錯誤。 我可以使用SOAPUI測試平台成功連接,因此我知道它不是不正確的憑據或阻止的IP。
此WebService API指出:
Neustar Ultra Services API使用SOAP標頭中的WSSE UserName標記對用戶和請求進行身份驗證。
我是否可以在Visual Studio中使用此Web服務???
我嘗試過添加服務參考。 我可以成功使用WSDL並創建一個對象,但不知道如何提供身份驗證。 例如,我嘗試過以下方法:
//Create client object
ServiceReference1.UltraDNSClient client = new ServiceReference1.UltraDNSClient();
client.ClientCredentials.UserName.UserName = "myUserName";
client.ClientCredentials.UserName.Password = "myPassword";
所以,上面我有我的客戶端對象,這個對象可以訪問API中的所有方法。 但是,我不能使用任何方法,因為我沒有正確驗證。 API不提供任何類型的“header()”類型方法。 例如,對於我使用的另一個Web服務(是的,這使用了Add Web Reference,但概念保持不變):
//Use the Web Reference to create the header object
StockLogoWebService.Header headerObject = new StockLogoWebService.Header();
//Assign the username (Username is all Xignite requires for authentication)
headerObject.Username = "janedoe@yahoo.com";
//Assign this header to the proxy object
xLogogsTest.HeaderValue = headerObject;
//Use any exposed methods
xLogosTest.anyMethod()
上面我使用了header()方法來指定我的憑據。 如果WSDL沒有提供頭方法,並且只是聲明必須在SOAP頭中提供憑據,那么在Visual Studio中如何實現呢?
WSDL可以在以下位置找到:
您可以在Web / app配置中將WSSE安全標頭添加到服務端點:
<system.serviceModel>
<bindings>
<customBinding>
<! -- your binding details -->
</customBinding>
</bindings>
<client>
<endpoint <your endpoint details>>
<headers>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" mustUnderstand="1">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-1">
<wsse:Username></wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"></wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</headers>
</endpoint>
</client>
</system.serviceModel>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.