在MVC3中使用安全Web服务(Consume Secure Web Service in MVC3)

编程入门 行业动态 更新时间:2024-10-26 13:34:17
在MVC3中使用安全Web服务(Consume Secure Web Service in MVC3)

我之前使用过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".

更多推荐

本文发布于:2023-07-04 10:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023056.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Web   Consume   Service   Secure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!