English 中文(简体)
D. 通过提供妇女服务 未列入国际独立实体的吉大港定居地
原标题:Exposing WCF Services Via HTTP when not hosted in IIS
  • 时间:2009-11-08 19:58:20
  •  标签:

和标题一样,我们需要在互联网用户和Adobe AIR用户之间建立全球合作框架。 我们不想在机器上运行电离层电离层电离层电离层,更倾向于安装和操作以窗户服务为主的WCF服务。

然而,我不清楚这样做会让我们把吉大港山区作为运输工具,而这种运输只是国际船舶和公司内部的工作吗? 我能够制造出使用TCP运输的物品,但这种货物与AIR几乎是使用吉大港湾的冰。

EDIT: 一些测试代码I ve正在使用,以了解这项工作是否可行:

普通青少年:

    static void Main()
    {
        using (ServiceHost host = new ServiceHost(typeof(TestService)))
        {
            host.Open();
        }

        Console.WriteLine("Waiting...");
        Console.ReadLine();
    }

测试服务是一种简单的Hello World型服务。

In the 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>
最佳回答

Apart from the config file settings one more thing to consider. If you selfhost in a windows service, a http endpoint then

  • Make the service login account a local admin on the machine or
  • You have to register the service account for the http namespace with http.sys. This step has to be done by a local admin but only once in each machine. You can use the HttpSysCfg tool to do this in XP/win 2003. For vista/win 2008 use netsh.
问题回答

您不应在设立Windows NT Service方面遇到任何困难,而这个服务是您的WCF服务所在地,并暴露了吉大港山区终端点——不需要IIS(但WCF的运行时间将使用http.sys kernel路司机)。

你们是否尝试失败了? 如果是这样的话,你能否向我们表明你们的是什么,以及它是如何失败的?

作为最起码的一点,你可能想在你的工作方面有这样的想法:

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Default">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="Default" 
                 sendTimeout="00:05:00" 
                 maxBufferSize="500000" 
                 maxReceivedMessageSize="500000" >
          <security mode="Message">
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="Namespace.MyWCFService"
               behaviorConfiguration="Default">
        <host>
          <baseAddresses>
            <add baseAddress="http://MyServer:8282/MyWCFService/"/>
          </baseAddresses>
        </host>
        <endpoint
             address="basic"
             binding="basicHttpBinding" bindingConfiguration="Default"
             contract="Namespace.IMyWCFService" />
      </service>
    </services>
  </system.serviceModel>

当然,你可能需要在你具有约束力的、安全模式,以及很可能需要的其他情况下,像时间外派环境、缓冲规模环境等事情。

页: 1

You could skip all the config and use the WebServiceHost class (which will do it all for you in a fairly standard way). Get that working then look into tailoring the config manually to meet any extra requirements you may have. All the info you need is here WebServiceHost on MSDN it s a very straightforward way to get started on a custom (i.e. non IIS) hosted http service.

迈克





相关问题
热门标签