VB.NET&;SOAP-找到该协定的多个端点配置

VB.NET&;SOAP-找到该协定的多个端点配置,vb.net,wcf,web-services,soap,Vb.net,Wcf,Web Services,Soap,我正在尝试调用可以在以下位置看到的Web服务: 我使用的是VB.net,但是任何C#语言的解决方案都是非常受欢迎的 我的做法是: 我正在添加一个新的服务引用,并选择fchXMLInterface>FCHXMLInterfaceHttpost 在我的代码中,我有:dimapi作为新的服务引用1.fchxmlcinterfacesapplient 当我运行它时,我收到一条错误消息,上面说: 无法加载协定“ServiceReference1.fchXMLInterfaceSoap”的终结点配置节,因

我正在尝试调用可以在以下位置看到的Web服务:

我使用的是VB.net,但是任何C#语言的解决方案都是非常受欢迎的

我的做法是:

  • 我正在添加一个新的服务引用,并选择fchXMLInterface>FCHXMLInterfaceHttpost

  • 在我的代码中,我有:
    dimapi作为新的服务引用1.fchxmlcinterfacesapplient

  • 当我运行它时,我收到一条错误消息,上面说:

    无法加载协定“ServiceReference1.fchXMLInterfaceSoap”的终结点配置节,因为找到了该协定的多个终结点配置。请按名称指明首选端点配置部分

    我在这里发布的第一个链接上查看了帮助,但没有找到。我怎样才能解决这个问题


    如果我不能将此Web服务称为ServiceReference,我如何才能将此Web服务称为?

    当我添加服务引用时,它已创建了下面提供的配置。在那里,您可以看到同一联系人的两个端点。
    您应该指定要使用的端点名称,如

    var a = new ServiceReference1.fchXMLInterfaceSoapClient("fchXMLInterfaceSoap12");
    
    或者只是删除不需要的端点配置

    <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="fchXMLInterfaceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
            receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
      <customBinding>
        <binding name="fchXMLInterfaceSoap12">
          <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
              messageVersion="Soap12" writeEncoding="utf-8">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </textMessageEncoding>
          <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
              maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
              bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
              keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
              realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
              useDefaultWebProxy="true" />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="http://www.flexiblecarhire.com/flexibleservice/fchxmlinterface.asmx"
          binding="basicHttpBinding" bindingConfiguration="fchXMLInterfaceSoap"
          contract="ServiceReference1.fchXMLInterfaceSoap" name="fchXMLInterfaceSoap" />
      <endpoint address="http://www.flexiblecarhire.com/flexibleservice/fchxmlinterface.asmx"
          binding="customBinding" bindingConfiguration="fchXMLInterfaceSoap12"
          contract="ServiceReference1.fchXMLInterfaceSoap" name="fchXMLInterfaceSoap12" />
    </client>
    </system.serviceModel>
    

    以下是我使用上述web服务尝试的步骤,并返回了无效的agentcode/密码错误消息:

    单击AddWebReference并添加URL,我将其命名为“carhirref”作为引用名称,然后单击OK

    现在,我调用服务的代码如下所示:

    CarHireRef.fchXMLInterface ob = new CarHireRef.fchXMLInterface();
    CarHireRef.ResultsGetLocations result = ob.GetAirportLocations("", "");
    

    上面的过程没有任何配置项,因为我正在添加web引用而不是服务引用。

    无论调用什么协议,如basic、net.tcp或wshttp,该地址都应该在web配置文件中。从app.config文件的客户端部分删除其他地址,在我的情况下,我将呼叫服务作为htp://machinename:700/test.svc 但在客户端部分中,有一些地址具有net.tcp和wshttp配置,删除了这些地址,问题就解决了

       [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
    

    将其添加到接口文件中,它将正常工作。

    只需从web.config文件中删除customBinding,在
    注意,您有两个端点

    <endpoint address="http://www.flexiblecarhire.com/flexibleservice/fchxmlinterface.asmx"
          binding="basicHttpBinding" bindingConfiguration="fchXMLInterfaceSoap"
          contract="ServiceReference1.fchXMLInterfaceSoap" name="fchXMLInterfaceSoap" />
      <endpoint address="http://www.flexiblecarhire.com/flexibleservice/fchxmlinterface.asmx"
          binding="customBinding" bindingConfiguration="fchXMLInterfaceSoap12"
          contract="ServiceReference1.fchXMLInterfaceSoap" name="fchXMLInterfaceSoap12" />
    </client