First, the new webservice
- New Project →asp.net Web Service Application
- or right-click the new Web service program ASMX in an existing project
- As long as the method inside the WebService class is labeled "WebMethod", it becomes the method that others can adjust. Two, WebService call
After the reference, you can directly use the method inside the namespace class name Client=new class; Method ()
Common errors
① failed to load the endpoint configuration portion of the contract as "Servicereference1.interfacesoap" because multiple endpoint configurations for the contract were found. Please indicate preferred by name
If the above error is due to the first reference to the WebService in the Webconfig has generated the <endpoint> configuration node, the first run time again added a configuration node repeat, You need to manually delete a node because the Add external reference is referenced more than once in the Web. config file
<client> <endpoint address="Http://218.90.168.115:8000/PJSDFacade/PJSD/Interface.asmx"binding="BasicHttpBinding"bindingconfiguration="Interfacesoap"Contract="Servicereference1.interfacesoap"Name="Interfacesoap"/>
<!--the node below is removed--<endpoint address="Http://218.90.168.115:8000/PJSDFacade/PJSD/Interface.asmx"binding="custombinding"bindingconfiguration="INTERFACESOAP12"Contract="Servicereference1.interfacesoap"Name="INTERFACESOAP12"/> </client>
So delete a node can be (if the reference is Webservicesoap, delete the WebServiceSoap1 of the relevant node, and vice versa ~new webservicesoapclient (" Interfacesoap");
C # using WebService