简体   繁体   English

如何使用Webservice而不是localhost

[英]How to consume webservice not as localhost

I was asked to generate a consumer class of a webservice c# code(which was given to me), my consumer c# code must call all its functions, i followed c-sharpcorner link and successfully done it. 我被要求生成一个Web服务C#代码的使用者类(已提供给我),我的使用者C#代码必须调用其所有函数,我遵循了c-sharpcorner链接并成功完成了它。

But here in this url place i added the url http://prntscr.com/9t8ihi which i obtained on running the visual studio c# web-service code at browser pop-UP. 但是,在此URL位置,我添加了URL http://prntscr.com/9t8ihi ,该URL是在浏览器弹出窗口上运行Visual Studio C#Web服务代码时获得的。

It works fine for me and i sent it. 它对我来说很好,我发送了它。

My mentor asked me replied that "there is a pb with the give code because the web service will not be localhosts". 我的导师问我说: "there is a pb with the give code because the web service will not be localhosts".

EDIT On further research i found that i need to publish web service on IIS, If i am right ? 编辑在进一步研究中,我发现我需要在IIS上发布Web服务,如果我是对的? For that i done following steps: 为此,我完成了以下步骤:

(1) Put the webservice project in C:\\inetpub\\wwwroot\\WS_TNT (1)将Web服务项目放在C:\\inetpub\\wwwroot\\WS_TNT

(2) Now open IIS manager and Add application by click right and give path of webserice and "Default Pool". (2)现在打开IIS管理器,然后单击右键添加应用程序,并提供webserice和“默认池”的路径。

(3) When i publish it i get this error http://prntscr.com/9t8v4p , My webservice code is written in visual studio .net 4.5 version where i have done this (3)当我发布它时,我收到此错误http://prntscr.com/9t8v4p ,我的Web服务代码是在Visual Studio .net 4.5版本中编写的,我在其中执行了此操作

C:\Users\ACER>%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i  

Whats wrong i do ? 我怎么了?

When you added a reference to the web service, url is added as LocalHost:/some port in your web.config file. 当您添加对Web服务的引用时,URL将作为LocalHost:/ some端口添加到web.config文件中。
Look for a section "Settings" where you will find the url as localhost. 查找“设置”部分,您将在其中找到url为localhost。 because you referenced it from there. 因为您从那里引用了它。

Host the web service somewhere In IIS. 将Web服务托管在IIS中的某个位置。 Get the URL & Replace in your web.config file. 在您的web.config文件中获取URL并替换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM