简体   繁体   English

在Visual Studio 2010中使用“添加Web引用”添加服务时,如何访问服务方法?

[英]How to Access the Service method when service is added using “Add Web Reference” in Visual Studio 2010?

I am trying to access the webservice methods hosted on my machine. 我正在尝试访问计算机上托管的Web服务方法。 I added the reference using "Add Web Refernce". 我使用“添加Web引用”添加了引用。 When i try to create the object of the service but visual studio dont let me do so.....here`s the settings in he web.config 当我尝试创建服务对象但Visual Studio不允许我这样做时.....这里是web.config中的设置

<applicationSettings>
    <Refernce.Properties.Settings>
        <setting name="Refernce_Hippa_HipaaService" serializeAs="String">
            <value>http://localhost/MDHipaaWS/HipaaService.asmx</value>
        </setting>
    </Refernce.Properties.Settings>
</applicationSettings>

i have imported the refernce in code behind but it still don`t let me create the object.. 我已经在后面的代码中导入了引用,但是仍然不允许我创建对象。

Right click References within your project structure. 右键单击项目结构中的“引用”。 Click "Add Service Reference". 单击“添加服务参考”。 In the address field input your url, and click "Go". 在地址字段中输入您的网址,然后单击“开始”。 Inspect services in the listbox, then click OK when finished. 检查列表框中的服务,完成后单击“确定”。

VIsual studio will then create a set of classes which you can use to communicate with your web service. 然后,VIsual Studio将创建一组类,您可以使用这些类与Web服务进行通信。

I would recommend using Service reference. 我建议使用服务参考。 See link below. 请参阅下面的链接。

Check out this answer . 看看这个答案

您也可以使用SvcUtil.exe生成服务的代理类。

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

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