像标题所说的那样,我们需要在.NET应用程序和Adobe AIR应用程序之间设置WCF服务。我们不想在机器上运行IIS,而更愿意安装和运行Windows服务中托管的WCF服务。当不在IIS中承载时通过HTTP公开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>
好吧,在这里使用您的默认配置(没有任何''部分),您将使用wsHttpBinding(SOAP 1.2),并且您将使用基于消息的安全性,期望Windows用户凭证进行身份验证。这可能不是一个非常好的选择(取决于你的具体设置) –
2009-11-08 20:28:52