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!