简体   繁体   English

如何使用我的asp.net应用程序引用Web服务

[英]How to reference web service with my asp.net application

I have my own web service application with more then one .asmx file. 我有自己的Web服务应用程序,其中不止一个.asmx文件。 Now i am not getting how can i reference web service with my web application as "Add Web Reference". 现在我不知道如何使用我的Web应用程序将Web服务引用为“添加Web引用”。

I want to connect with both asmx files at once. 我想一次连接两个asmx文件。 Means once i connect web service as add web reference and i can call both .asmx file from my code behind page. 意味着一旦我连接Web服务作为添加Web引用,就可以从页面后面的代码中调用这两个.asmx文件。

Doesn't work that way. 不能那样工作。 You have to reference each web service or consolidate them. 您必须引用每个Web服务或对其进行合并。

You could do this: 您可以这样做:

Invoking Web Service dynamically using HttpWebRequest 使用HttpWebRequest动态调用Web服务

When you add a web reference to your application, Visual Studio creates a proxy class that you use to connect to the web service. 当您向应用程序添加Web引用时,Visual Studio将创建用于连接到Web服务的代理类。 You will not connect to the web service directly. 您将不会直接连接到Web服务。 The proxy class name is set when you add the reference. 添加引用时,将设置代理类名称。 It suggests a name for you that you can change. 它为您建议一个可以更改的名称。

As long as you are using the proxy classes that are generated, you should be able to connect to as many web services as you desire. 只要您使用生成的代理类,就应该能够连接到所需的任意多个Web服务。

I hope that helps. 希望对您有所帮助。

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

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