2017-03-07 95 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服务解决了这个问题,该服务使用了上面的一个。在新版本中,我使用了代码验证,然后使用安全头来调用它。只有解决方案,为我工作。