在網站的解決方案的下方找到web.config
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
<system.web>
2.無法加載協定為“ServiceReference1.xxxxxx”的終結點配置部分,因為找到了該協定的多個終結點配置。請按名稱指示首選的終結點配置部分。
原因是在web.config 文件中多次引用了“添加外部引用”
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="WebServiceSoap" /> <binding name="WebServiceSoap1" /> </basicHttpBinding> </bindings> <client> <endpoint address="http://10.29.68.32/WebService.asmx" binding="basicHttpBinding" bindingConfiguration="WebServiceSoap" contract="ServiceReference.WebServiceSoap" name="WebServiceSoap" /> <endpoint address="http://10.29.68.32/WebService.asmx" binding="basicHttpBinding" bindingConfiguration="WebServiceSoap1" contract="ServiceReference.WebServiceSoap" name="WebServiceSoap1" /> </client> </system.serviceModel>
所以刪掉一個節點既可(如查引用的是WebServiceSoap,刪掉WebServiceSoap1的有關節點,反之~)
也可以在頁面引用的時候指定bindingConfiguration名字:
如:ServiceReference.WebServiceSoap web = new WebServiceSoapClient("WebServiceSoap");
3.
在調用webservice返回數據的時候, 出現以下錯誤:
已超過傳入消息(65536)的最大消息大小配額。若要增加配額,請使用相應綁定元素上的 MaxReceivedMessageSize 屬性
這個就需要在調用webservice的解決方案中,在web.config或者app.config中配置一下:注意紅色字體為哪個節點下加的哪些配置。
<system.serviceModel>
<bindings >
<basicHttpBinding>
<binding name="InterfaceSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
<customBinding>
<binding name="InterfaceSoap12" >
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://218.90.168.115:8000/PJSDFacade/PJSD/Interface.asmx"
binding="basicHttpBinding" bindingConfiguration="InterfaceSoap"
contract="ServiceReference.InterfaceSoap" name="InterfaceSoap" />
</client>
</system.serviceModel>
