Error reported when Web Service is called in SharePoint webpart
An error is reported when Web Service is called in SharePoint webpart.
Error message: In servicemodel
In the client configuration section, the default endpoint element of the reference protocol "pmadmwebservice. pmadmwebservicesoap" cannot be found. This may be because the application configuration file is not found, or because the client element cannot find the endpoint element that matches this agreement.
This is because no service mode configuration is added to the web. config of the website that calls the web service. Add the related configuration and restart the SharePoint site.
When you add a WebService reference to a webpart project, the following configuration information is generated in the configuration file of your Web part. Copy the entire servicemode configuration section.
The configuration information is as follows:
<System. servicemodel>
<Bindings>
<Basichttpbinding>
<Binding name = "basicdatawebservicesoap" closetimeout = "00:01:00"
Opentimeout = "00:01:00" receivetimeout = "00:10:00" sendtimeout = "00:01:00"
Allowcookies = "false" bypassproxyonlocal = "false" hostnamecomparisonmode = "strongwildcard"
Maxbuffersize = "65536" maxbufferpoolsize = "524288" maxcompute edmessagesize = "65536"
Messageencoding = "text" textencoding = "UTF-8" transfermode = "buffered"
Usedefaultwebproxy = "true">
<Readerquotas maxdepth = "32" maxstringcontentlength = "8192" maxarraylength = "16384"
Maxbytesperread = "4096" maxnametablecharcount = "16384"/>
<Security mode = "NONE">
<Transport clientcredentialtype = "NONE" proxycredentialtype = "NONE"
Realm = ""/>
<Message clientcredentialtype = "username" algorithmsuite = "default"/>
</Security>
</Binding>
<Binding name = "pmadmwebservicesoap" closetimeout = "00:01:00" opentimeout = "00:01:00"
Receivetimeout = "00:10:00" sendtimeout = "00:01:00" allowcookies = "false"
Bypassproxyonlocal = "false" hostnamecomparisonmode = "strongwildcard"
Maxbuffersize = "65536" maxbufferpoolsize = "524288" maxcompute edmessagesize = "65536"
Messageencoding = "text" textencoding = "UTF-8" transfermode = "buffered"
Usedefaultwebproxy = "true">
<Readerquotas maxdepth = "32" maxstringcontentlength = "8192" maxarraylength = "16384"
Maxbytesperread = "4096" maxnametablecharcount = "16384"/>
<Security mode = "NONE">
<Transport clientcredentialtype = "NONE" proxycredentialtype = "NONE"
Realm = ""/>
<Message clientcredentialtype = "username" algorithmsuite = "default"/>
</Security>
</Binding>
</Basichttpbinding>
</Bindings>
<Client>
<Endpoint address = "http: // localhost/basicwebservice. asmx"
Binding = "basichttpbinding" bindingconfiguration = "basicdatawebservicesoap"
Contract = "basicdatawebservice. basicdatawebservicesoap" name = "basicdatawebservicesoap"/>
<Endpoint address = "http: // localhost: 8090/pmadmwebservice. asmx"
Binding = "basichttpbinding" bindingconfiguration = "pmadmwebservicesoap"
Contract = "pmadmwebservice. pmadmwebservicesoap" name = "pmadmwebservicesoap"/>
</Client>
</System. servicemodel>