webservices设置web.config供远程调用
在网站的解决方案的下方找到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>
浙公网安备 33010602011771号