如何使用基本身份验证使用Web服务? [英] How do I consume a web service with basic authentication?

查看:87
本文介绍了如何使用基本身份验证使用Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了很多关于此的网页,但没有任何工作。



我正在使用VS2012并使用'添加创建了一个代理类服务参考'这个Web服务已经过测试和工作,但现在已经在Web服务中添加了一个id和密码,当我尝试使用它时它失败了。





系统Web服务Protocols.SoapException发生

发现处理wsse:Security标头的错误

系统Web服务





这应该很简单。我缺少什么?



I've been through loads of web pages about this and nothing has worked.

I'm using VS2012 and have created a proxy class using the 'add service reference' This web service was tested and worked but now an id and password have been added to the web service and it fails when I try to consume it.


System Web Services Protocols.SoapException occurred
An error was discovered processing the wsse:Security header
System Web Services


This should be so simple. What am I missing?

MyCompanyGetCases objWebService_MyCompanyGetCases = new MyCompanyGetCases();

System.Net.CredentialCache myCredentials = new System.Net.CredentialCache();
NetworkCredential netCred = new NetworkCredential(strServiceHostWebServiceId, strServiceHostWebServicePassword);

myCredentials.Add(new Uri(objWebService_MyCompanyGetCases.Url), "Basic", netCred);
objWebService_MyCompanyGetCases.Credentials = myCredentials;
objWebService_MyCompanyGetCases.UseDefaultCredentials = false;

MyCompany_getcasesRequest objMyCompany_getcasesRequest = new MyCompany_getcasesRequest(); // The receiver object
MyCompany_getcasesResponse objMyCompany_getcasesResponse = objWebService_MyCompanyGetCases.GetCases(objMyCompany_getcasesRequest);

推荐答案

看一下这个链接:



Web服务身份验证(使用SOAP标头)



致电需要从wcf客户端进行基本http身份验证的Web服务


这篇关于如何使用基本身份验证使用Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆