引用WebService出现错误

在引用WebService作为服务引用的时候,由于VS生成时生成了两个入口点,导致出现

引发的异常:“System.Windows.Markup.XamlParseException”(位于 PresentationFramework.dll 中)

其他信息: 'The invocation of the constructor on type 'WebServiceInvokingDemo.MainWindow' that matches the specified binding constraints threw an exception.' Line number '6' and line position '9'.

解决办法

      打开程序的App.Config

找到节点

bindings节点下只能有一个
Client 节点下智能有一个

 <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="Service1Soap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
                <binding name="IotServiceSoap"/>
            </basicHttpBinding>
            
        </bindings>
    
        <client>
            <endpoint address="http://192.168.0.41:5/BHService.asmx" binding="basicHttpBinding" bindingConfiguration="Service1Soap" contract="BHService.Service1Soap" name="Service1Soap"/>
            <endpoint address="http://192.168.0.121:8/IotService.asmx" binding="basicHttpBinding" bindingConfiguration="IotServiceSoap" contract="IotSrf.IotServiceSoap" name="IotServiceSoap"/>
            
        </client>
    </system.serviceModel>

 

如果不修改App.config 可以通过指定入口的方式

 

MesService.Service1Soap m_MesServer = new MesService.Service1SoapClient(“IotServiceSoap”);

  

posted on 2017-07-27 10:42  坐看疯云  阅读(648)  评论(0编辑  收藏  举报

导航