プロジェクトで Castle WCF 統合機能を使用しようとしています。城の公式サイトhttp://docs.castleproject.org/Windsor.WCF-Facility-Registration.ashxの指示に従いましたが、 うまくいきませんでした。これが私のコードと構成です。
protected void Application_Start(object sender, EventArgs e)
{
BuildContainer();
}
private void BuildContainer()
{
Container = new WindsorContainer();
//1st
Container.Kernel.AddFacility<WcfFacility>();
Container.Kernel.Register(Component.For<IProductService>()
.ImplementedBy<ProductService>()
.Named("ProductService"));
//2nd
Container.AddFacility<WcfFacility>()
.Install(Castle.Windsor.Installer.Configuration.FromXmlFile("Castle.config"));
//3rd
Container.Register(
Component.For<IProductService>()
.ImplementedBy<ProductService>()
.LifeStyle.PerWcfOperation()
.AsWcfService(new DefaultServiceModel()
.AddEndpoints(WcfEndpoint.BoundTo(new WSHttpBinding(SecurityMode.None)
{
MaxReceivedMessageSize = Int32.MaxValue,
MaxBufferPoolSize = Int32.MaxValue,
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas
{
MaxStringContentLength = Int32.MaxValue
}
}).At("http://localhost:1278/ProductService")
)
.AddBaseAddresses("http://localhost:1278/ProductService")
.PublishMetadata()
));
}
上記のように、3 つの異なる方法でサービスを登録しようとしました。明確にするために、一度に 3 つの登録コードのうち 1 つだけを実行し、他のコードはコメントアウトしています。Castle.config から構成を取得するものは、私の castle.config です。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<components>
<component id="TestService"
service="IProductService"
type="ProductService"
lifestyle="transient">
</component>
</components>
</configuration>
最後に、ここに私の web.config があります
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="WCFLibrary.ProductService">
<endpoint name ="IProductService_Endpoint" address="http://localhost:1278/ProductService" binding="httpBinding" contract="WCFLibrary.IProductService" />
</service>
</services>
</system.serviceModel>
</configuration>
助けてくれてありがとう...