Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to publish and call C # WebService

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "how to publish and call C # WebService". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to publish and call C # WebService".

Web Service is an operable distributed application. It uses SOAP as the basic communication protocol and uses HTTP and XML to communicate freely through the firewall.

Error prompt:

* failed to access IIS Metabase

* iis cannot display XML

Solve: start-> programs-> Microsoft Visual Studio 2005-> Visual StudioTools open the command line, enter the command: aspnet_regiis-I so you will re-register .net

You also need to open the properties dialog box on the virtual directory and click the ASP.NET property page to select the corresponding Asp.net version (1.1 or 2.0) in the "Asp.net version" item.

* the question of unauthorized limits

Because we are now using hard drives in NTFS format, select Everyone users or check allow anonymous access in IIS.

* uncheck the Window system integration users

1. First, add a new item-Web service-* .asmx

At the same time, a * .cs file is added to the App_Code folder.

WebMethod] public string [] GetHotSearchByKeywords (string keyword) {return SearchKeywordManager.GetHotSearchByKeywords (keyword);} [WebMethod] is a feature provided by Web Service. It indicates that the following method is a Web method, which allows Web to use SOAP to call this method. There can be multiple [WebMethod] in a Web Service file, and one [WebMethod] can only be valid for the following methods.

After you have finished writing, you can directly open this file for testing. After success, you can release it.

2.C# webService release

C # webService publishing website-create virtual directory-browse WebService page-test WebService method

There may be a small problem during the release, and the above is the situation of error.

Open the URL of WebService, which is the URL of WebService to be released.

3.C# WebService call

Add Web reference-instantiate WebService class-execute WebService method

WebService may be called in this project, other than this project, or even off-site

* add WebService reference

* fill in the published WebService URL at URL, click go, and you will see our published WebService method.

* you can change the reference name of WebService

C # WebService calls this method

Quote name. Class name s=new reference name. Class name ()

* after adding the reference, you will also see the related files in the App_WebReferences folder where WebService has been added.

* .disco

* .discomap

* .wsdl

The above is all the contents of the article "how to publish and invoke C # WebService". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report