2

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

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

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

GET > https://localhost/company/get

请求标头:

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

收到错误 404.0 Not Found。我想我在做一个小学生?

在此先感谢,奥南。

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>
4

0 回答 0