WCF Rest SSL HTTPS简单GET

时间:2013-07-18 12:20:05

标签: c# wcf rest ssl

在创建这个主题时,我看到了很多未答复的人,希望有人可以帮助我。

  • 我在IIS中托管了一个简单的WCF服务。
  • 我已将此“网站”与自我分配的证书相关联
  • 我可以在其中的html页面强制我进入页面(localhost test.htm)

我想访问一个宁静的服务,我正在使用Fiddler模​​拟请求:

GET > https://localhost/company/get

请求标题:

User-Agent: Fiddler
Host: localhost
Authorization: Joe;Bloggs

获取错误404.0未找到。我想我正在做一个小学生?

提前致谢,Onam。

WCF代码:

public class CompanyService : ICompanyService
{
    public IEnumerable<Integration.Business.Objects.Company> Get()
    {
        List<Integration.Business.Objects.Company> c = new List<Integration.Business.Objects.Company>();
        c.Add(new Integration.Business.Objects.Company() { Name = "Blah" });
        return c;
    }
}

[ServiceContract]
public interface ICompanyService
{
    [OperationContract]
    [WebGet(UriTemplate = "company/get")]
    IEnumerable<Integration.Business.Objects.Company> Get();
}

配置文件:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="CompanyService"
               behaviorConfiguration="WebHttpBehaviour_Mango">
        <endpoint address=""
                  binding="webHttpBinding"
                  bindingConfiguration="WebHttpBinding_Mango"
                  behaviorConfiguration="WebHttpBehaviour_Mango"
                  contract="ICompanyService">
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WebHttpBehaviour_Mango">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="WebHttpBinding_Mango">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
         </binding>
      </webHttpBinding>
    </bindings>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

0 个答案:

没有答案