我之前使用过Web服务(添加引用>高级> Web引用)。 但是,由于我需要先进行身份验证,因此这个问题很难实现。
我有我的wsdl文件的地址,我们的IS部门的某个人可以使用。 根据他的指示,我需要使用我的网络用户名/密码进行身份验证才能使用它。
所以,使用小词;),任何人都可以帮助我理解如何添加这个Web服务来打电话吗?
我正在使用VS 10 MVC3(剃须刀)。 通过http访问wsdl - https不可用。
我感谢所有的帮助!
更新
基于@ john-saunders的帖子,我获取了WSDL的本地副本并引用它(不作为Web引用)。 我现在看到添加到我的web.config并且它似乎采用用户名/密码...但是再一次,我是新来的。 我非常感谢任何帮助推动我(我希望)最后的驼峰!
更新#2
我已经输入以下代码了。 但intellisense没有显示方法,我知道有搜索功能,我可以传递一个值(emplID)并获取其他值(名称,出生日期)。 如何调用这些/测试我的身份验证?
using (var hrData = new CHMC_HRTECH_RES()) { //CHMC_HRTECH_RES hrData = new CHMC_HRTECH_RES(); CredentialCache cache = new CredentialCache(); cache.Add(new Uri(hrData.Url), "Negotiate", new NetworkCredential("myuser", "mypass")); hrData.Credentials = cache; }I've consumed web services before (add reference > advanced > web reference). However, this one is proving difficult as I need to authenticate first.
I have the address to my wsdl file that someone in our IS department made available. I need to authenticate with my network username/pass to use it, according to his instructions.
So, using small words ;), can anyone help me understand how I might add this webservice to make calls?
I am using VS 10 MVC3 (razor). The wsdl is accessed over http - https is not available.
I appreciate all help!
Update
Based on @john-saunders post I took a local copy of the WSDL and referenced it (not as a web reference). I now see the added to my web.config and it would seem to take username/password... but again, I'm new here. I really appreciate any help in pushing me over this (I hope) final hump!
Update #2
I've put in the following code. But intellisense doesn't show methods, I know there is search capability where I can pass one value (emplID) and get back other values (name, birth date). How do I call these/test my authentication?
using (var hrData = new CHMC_HRTECH_RES()) { //CHMC_HRTECH_RES hrData = new CHMC_HRTECH_RES(); CredentialCache cache = new CredentialCache(); cache.Add(new Uri(hrData.Url), "Negotiate", new NetworkCredential("myuser", "mypass")); hrData.Credentials = cache; }最满意答案
如果您无法通过URL访问WSDL,请要求服务的所有者通过电子邮件向您发送WSDL及其包含的任何其他文件。 将它们保存到磁盘并将文件路径传递给“添加服务引用”。
If you can't access the WSDL by URL, then ask the owners of the service to email you the WSDL and any other files it includes. Save those to disk and pass the file path to "Add Service Reference".
更多推荐
发布评论