【发布时间】:2010-12-02 01:16:05
【问题描述】:
我创建了一个简单的 WCF REST 服务,我打算从 iPhone 应用程序中使用它。 该服务运行良好,但现在我想保护它。
在我的测试环境(Windows 7 上的 IIS)中,我已经使用 makecert.exe 设置了自签名证书。
我还覆盖了 validate() 方法,因此我可以使用自定义用户名和密码(因为 Windows 身份验证是不可能的)。
现在我被困了两天多,想知道如何配置所有东西才能正常工作。
我现在的目标是能够通过浏览器进行简单的 GET 请求,例如:
https://localhost/testservice/service1.svc/sayHello
当这可行时,我将继续处理所有与 iPhone 相关的内容。
任何帮助/示例将不胜感激!
这是我的 web.config:
<system.serviceModel>
<services>
<service name="IphoneWcf.Service1" behaviorConfiguration="IphoneWcf.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="webBehavior" contract="IphoneWcf.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> -->
<host>
<baseAddresses>
<add baseAddress="https://localhost/iphonewcf" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="IphoneWcf.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="false" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="webBinding">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
提前致谢!
【问题讨论】:
标签: iphone wcf .net-3.5 ssl rest