【发布时间】:2009-11-08 19:58:20
【问题描述】:
正如标题所说,我们需要在 .NET 应用程序和 Adobe AIR 应用程序之间设置 WCF 服务。我们不想在机器上运行 IIS,而是更愿意安装和运行托管在 Windows 服务中的 WCF 服务。
但是,我不确定这样做是否会让我们使用 HTTP 作为传输,这是否仅在 IIS 中有效?我能够设置使用 TCP 传输,但它与 AIR 的互操作不如使用 HTTP 好。
编辑:我一直在使用一些测试代码来查看这是否有效:
常规控制台应用程序:
static void Main()
{
using (ServiceHost host = new ServiceHost(typeof(TestService)))
{
host.Open();
}
Console.WriteLine("Waiting...");
Console.ReadLine();
}
TestService 是一个简单的 HelloWorld 类型的服务。
在 App.Config 中:
<configuration>
<system.serviceModel>
<services>
<service name="WCFExample2.TestService" behaviorConfiguration="WCFExample2.TestServiceBehavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8731/Design_Time_Addresses/WCFExample2/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="" binding="wsHttpBinding" contract="WCFExample2.ITestService">
<!--
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>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFExample2.TestServiceBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- 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="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
【问题讨论】:
-
好吧,使用此处的默认配置(没有任何
<bindings>部分),您将使用 wsHttpBinding (SOAP 1.2),并且您将使用基于消息的安全性,期望 Windows 用户凭据进行身份验证。在互操作场景中,这可能不是一个很好的选择(取决于您的具体设置)
标签: wcf