2017-03-07 51 views
0

我試圖從SOAP Web服務中獲取數據。我能夠從測試服務中獲取數據。簡單如下:將安全頭添加到Xamarin.Forms中的SOAP Webservice中

var service = new CurrencyConvertor(); 
var f = service.ConversionRate(Currency.EUR, Currency.USD); 

我在Droid-Project中添加了'Web Reference'服務 - 與代理類一起使用它。

現在我堅持使用新的Web服務。問題是:我需要提供一個安全標題,我真的無法使它與Xamarin合作。已經嘗試在PCL中使用,但我不能添加標題。

web服務報頭:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
     <s:Header> 
     <Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
      <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
      <wsse:Username>UserName</wsse:Username> 
      <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password> 
      </wsse:UsernameToken> 
     </Security> 
     </s:Header> 
    ... 

該請求在了SoapUI工作。

回答

0

通過創建第二個wcf服務解決了這個問題,該服務使用了上面的一個。在新版本中,我使用了代碼驗證,然後使用安全頭來調用它。只有解決方案,爲我工作。