Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Web引用可以工作,但服务引用会抱怨Soap版本_C#_Visual Studio 2012_Asmx_Service Reference_Web Reference - Fatal编程技术网

C# Web引用可以工作,但服务引用会抱怨Soap版本

C# Web引用可以工作,但服务引用会抱怨Soap版本,c#,visual-studio-2012,asmx,service-reference,web-reference,C#,Visual Studio 2012,Asmx,Service Reference,Web Reference,我必须连接到传统的web服务 在VisualStudio中,如果我执行添加服务引用,则输入服务器上WSDL文件的url。我的服务出现了,我编写了相应的代码。但是当我运行代码时,我得到了以下错误: System.ServiceModel.CommunicationException:的信封版本 传入消息(Soap12) ())与 编码器(Soap11())。制作 确保使用与预期版本相同的版本配置绑定 信息 我的app.config如下所示: <system.serviceModel>

我必须连接到传统的web服务

在VisualStudio中,如果我执行添加服务引用,则输入服务器上WSDL文件的url。我的服务出现了,我编写了相应的代码。但是当我运行代码时,我得到了以下错误:

System.ServiceModel.CommunicationException:的信封版本 传入消息(Soap12) ())与 编码器(Soap11())。制作 确保使用与预期版本相同的版本配置绑定 信息

我的app.config如下所示:

  <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="LoginServiceSoap" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://server/Service.asmx" binding="basicHttpBinding"
                bindingConfiguration="LoginServiceSoap" contract="Stuff.Login.LoginServiceSoap"
                name="LoginServiceSoap" />
        </client>
    </system.serviceModel>

但是,如果我添加了“Web参考”,我可以很好地与服务通信。但我的理解是,我现在应该使用服务引用,而不是WebReferences。我假设我上面的配置有问题

还是因为我连接的服务类型,我不得不使用网络参考

您可以(理论上)将版本号添加到绑定定义中

envelopeVersion="None/Soap11/Soap12"
当然,您的服务具有正确的价值

所以它看起来更像:

<basicHttpBinding>
    <binding name="LoginServiceSoap"
             envelopeVersion="Soap12" />
</basicHttpBinding>


希望这有助于您按自己的方式进行操作。

“确保绑定配置的版本与预期消息的版本相同。”John Saunders,很抱歉,内容过于密集,但不确定如何执行您的要求。最后只使用了Web引用,因为它们目前可以工作。我也有同样的问题。当我尝试添加'EnveloperVersion=“Soap12”时,我得到一个错误:“EnveloperVersion”属性是不允许的”。