System.InvalidOperationException: 无法加载协定为“ServiceReference1.XXXXXXXXXXXXXXXX”的终结点配置部分,因为找到了该协定的多个终结点配置。请按名称指示首选的终结点配置部分。
1 <system.serviceModel> 2 <bindings> 3 <basicHttpBinding> 4 <binding name="testWebServiceSoap" /> 5 </basicHttpBinding> 6 <customBinding> 7 <binding name="testWebServiceSoap12"> 8 <textMessageEncoding messageVersion="Soap12" /> 9 <httpTransport /> 10 </binding> 11 </customBinding> 12 </bindings> 13 <client> 14 <endpoint address="http://localhost:3360/WebServices/testWebService.asmx" 15 binding="basicHttpBinding" bindingConfiguration="testWebServiceSoap" 16 contract="ServiceReference1.testWebServiceSoap" name="testWebServiceSoap" /> 17 <endpoint address="http://localhost:3360/WebServices/testWebService.asmx" 18 binding="customBinding" bindingConfiguration="testWebServiceSoap12" 19 contract="ServiceReference1.testWebServiceSoap" name="testWebServiceSoap12" /> 20 </client> 21 </system.serviceModel>
导致的原因是多了一段,删除这里即可:
1 <endpoint address="http://localhost:3360/WebServices/testWebService.asmx" 2 binding="customBinding" bindingConfiguration="testWebServiceSoap12" 3 contract="ServiceReference1.testWebServiceSoap" name="testWebServiceSoap12" />