C # analysis on the release and call of WebService

Source: Internet
Author: User

Web Service is an operable distributed application. It uses soap as the basic communication protocol and uses HTTP and XML for free communication through the firewall.

Error message:

* An error occurred while accessing the IIS metadatabase.

* IIS cannot display XML

Solution: Start-> Program-> Microsoft Visual Studio 2005-> visual studiotools, open the command line, and enter the command: aspnet_regiis-I. Then, the. NET registration will be re-registered.

In addition, you need to open the Properties dialog box on the virtual directory, click ASP. NET properties page, and select the corresponding Asp.net version (1.1 or 2.0) from the "Asp.net version" item)

* No Permissions

Because we currently use NTFS hard disks, select everyone or enable Anonymous Access in IIS.

* Remove the Window System Integration user and select

1. First Add a new project --- Web Service --- *. asmx

A *. CS file is added to the app_code folder.

 
 
  1. Webmethod]
  2. PublicString [] gethotsearchbykeywords
  3. (String keyword)
  4. {
  5. ReturnSearchkeywordmanager. gethotsearchbykeywords
  6. (Keyword );
  7. }
  8. [Webmethod] is a feature provided by web service,
  9. It indicates that the following method is a web method, which allows the Web to call this method using soap.
  10. A Web service file can contain multiple [webmethods],
  11. A [webmethod] can only be used for the following methods:

After writing the file, you can open the file directly for testing. After the file is successfully opened, it can be published.

2. C # WebService released

C # WebService publish website --- create virtual directory --- browse WebService page --- test WebService Method

A small problem may occur during the release. The above error occurs.

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

3. C # WebService call

Add web reference --- instantiate WebService class --- execute WebService Method

WebService may be called in this project, not this project, or even in a remote location.

* Add a WebService reference

* Enter the published WebService URL in the URL and click "go". The published WebService method is displayed.

* You can change the WebService reference name.

C # WebService calls this method

Reference name. Class Name S = new reference name. Class Name ();

* After adding a reference, you will also see the files related to WebService added to the app_webreferences folder.

*. Disco

*. Discomap

*. WSDL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.