WebService controls the name of the client proxy class

Source: Internet
Author: User

Maybe you will encounter a very tangled problem when you are doing WebService, but there is no solution for searching online for a long time. What I wrote today is a very tangled problem. When I solve this problem, I am very happy to share it with you immediately. I hope that people who encounter the same problems will be helpful to you.

I. Simple Example:

Ii. Browsing WebService

Then we can view the WSDL

You may see two node configuration sections for service access. What if we want to delete one? We need to add the following in the </system. Web> node of the web. config service:Code:

 
<WebServices> <protocols> <remove name ="Httpsoap"/> </Protocols> </WebServices>

Here, name specifies the name attribute in the port in the WSDL.

View the WSDL again after adding it. The configuration node you want to delete will no longer exist.

We add a service on the client.

Do you see a webservicesoapclien class? We want to control this name today. Why? This is the proxy class for service ing. It is used to call all service methods. In some special circumstances, we may need to control what kind of name it is. (Below are the key points)

Iii. Control proxy class name

Make the following changes in the service class:

For your convenience, paste the Code:

 Using  System;  Using  System. Collections. Generic;  Using  System. LINQ;  Using  System. Web;  Using  System. Web. Services;  Using System. Web. Services. Protocols;  Namespace  WebService. Service {  ///   <Summary>      ///  Summary Description for WebService  ///   </Summary> [WebService (namespace = "  Http://tempuri.org/  "  )] [Webservicebinding (name = " Dzjc_ws  "  )] [System. componentmodel. toolboxitem (  False  )]  //  To allow this web service to be called from script, using ASP. NET Ajax, uncomment the following line.  //  [System. Web. Script. Services. scriptservice]      Public   Class  WebService: system. Web. Services. WebService {[webmethod] [soapdocumentmethod (binding ="  Dzjc_ws  "  )]  Public   String  Helloworld (){  Return   "  Hello World  "  ;}}} 

Run and view the WSDL:

We can see that the name in the access configuration has become what we want.

Let's take a look at adding a service on the client:

Now we can see that the proxy class name of the client has changed!

Now, let's talk about this. If you have any errors or questions, please contact qq704629730. thank you!

 

Please respect everyone's Labor achievements. If the record is reprinted, please indicate the source of the original version. Thank you!

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.