【问题标题】:Consuming service reference in web api在 web api 中使用服务引用
【发布时间】:2016-03-18 12:30:12
【问题描述】:

1)我正在VS2013中创建一个ASP.NET Web Application-> Empty (Web Api selected)项目并添加服务引用(wsdl)

public class BJKController : ApiController
{
   [HttpGet]
   public byte[] GetArchive(string workOrderNo)
   {
      BjkClient client =new BjkClient();
      return client.GetInvoice(workorderNo);//I'm getting error this line
   }
}

web.config:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_ICompany" maxReceivedMessageSize="64000000">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://service.karakartal.com.tr/Company.svc"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICompany"
          contract="ServiceReference1.ICompany" name="WSHttpBinding_ICompany" />
    </client>
  </system.serviceModel>

我在调试webapi项目报错:连接尝试失败,因为连接方一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应XXXXX.XXX:443

但我正在尝试一个 Windows 项目(也添加服务引用) 一切都一样(网络配置和使用)。它工作正常。

【问题讨论】:

  • 你能在浏览器中成功打开你的服务的url吗?
  • @RicardoPontual 是的。我可以调试。

标签: wcf asp.net-web-api service-reference


【解决方案1】:

当我迁移到 IIS 时,它运行良好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-04
    • 1970-01-01
    • 2014-01-08
    • 1970-01-01
    相关资源
    最近更新 更多