使用 WCF 服务

Consuming WCF service

当我使用 Live WCF 服务时它显示错误

There was no endpoint listening at this that could accept the message. This is often caused by an incorrect address or SOAP action

将您的端点配置放在项目根目录下的 Web.config 上。

这是 web.configend-point 的示例。

<system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service  behaviorConfiguration="TestWcfHttps1.Service1" name="TestWcfHttps1.Service1">
        <endpoint address="https://MYSERVER/GpTest/Service1.svc" 

                  binding="basicHttpBinding" 

                  bindingConfiguration="TransportSecurity"

                  contract="TestWcfHttps1.IService1">
          <identity>
            <dns value="" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="TestWcfHttps1.Service1">
          <serviceMetadata httpsGetEnabled="true" externalMetadataLocation="https://MYSERVER//GpTest/Service1.wsdl" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

以上示例代码将解决您的问题,但请在您的解决方案中详细描述您的项目并将您的代码放在这里。您是否在 class 库中使用了 web-service 并在您的网络应用程序项目中引用了它?