(Transfer) Dynamically add reference to Web Service

zhaozj2021-02-16  90

When we add a web service reference in vs.net, we generate a web references folder that displays all files in this folder, we will find the reference.cs file, open this file, define a from System. Web.Services.Protocols.soaphttpclientProtocol inherited class, in its constructor, there is such an initialization statement:

THIS

.Url = "http://localhost/services/simpleblogservice.asmx"; we only need to add a constructor with parameters, the parameter is the URL of the Web Service we want to reference, you can realize a reference to Web Service. The sample code is as follows:

public

Class sbssimpleblogservice: system.web.services.protocols.soaphttpClientProtocol

{

///

Public SBSSIMpleBlogService () {

THIS.URL = "http://localhost/services/simpleblogservice.asmx";

}

Public SBSSIMpleBlogService (String URL)

{

this.url = URL;

}

}

Reference article: http://www.codeproject.com/cs/webservices/callxmlwebservices.asp

转载请注明原文地址:https://www.9cbs.com/read-14356.html

New Post(0)