Host WCF service with Castle-Windsor outside IIS with code only

瀏覽次數:651 次
跳到第一則未讀訊息

Khash

未讀,
2010年8月11日 凌晨2:53:272010/8/11
收件者:Castle Project Users
I'm trying to host a WCF service inside a console app using Castle-
Windsor 2.5 (.NET 4) with the following code:

new WindsorContainer()
.AddFacility<WcfFacility>()
.Register(
Component.For<IMyService>().ImplementedBy<MyService>()
.ActAs(new DefaultServiceModel()
.AddEndpoints(
WcfEndpoint.BoundTo(new
BasicHttpBinding()).At("http://localhost:1010/MyService"),

WcfEndpoint.BoundTo(MetadataExchangeBindings.CreateMexHttpBinding()).At("http://
localhost:1010/MyService/mex"))
));

I don't have and prefer not to have any config in my app.config for
WCF if possible.

This however doesn't seem to work (doesn't complain but WcfTestUtil
can't see the service).

Am I missing anything?

Craig Neuwirt

未讀,
2010年8月11日 下午1:18:562010/8/11
收件者:castle-pro...@googlegroups.com
So you can't browse to wsdl? Are all dependencies of MyService available?

> --
> You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
> To post to this group, send email to castle-pro...@googlegroups.com.
> To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
>

Khash

未讀,
2010年8月11日 下午6:58:222010/8/11
收件者:Castle Project Users
Yes all the dependencies are available. Browsing to WSDL shows a 404
Bad Request. Same for WCFClientUtil and mex.

On Aug 11, 6:18 pm, Craig Neuwirt <cneuw...@gmail.com> wrote:
> So you can't browse to wsdl?  Are all dependencies of MyService available?
>
> On Aug 11, 2010, at 1:53 AM, Khash wrote:
>
>
>
> > I'm trying to host a WCF service inside a console app using Castle-
> > Windsor 2.5 (.NET 4) with the following code:
>
> >        new WindsorContainer()
> >            .AddFacility<WcfFacility>()
> >            .Register(
> >            Component.For<IMyService>().ImplementedBy<MyService>()
> >                          .ActAs(new DefaultServiceModel()
> >                                             .AddEndpoints(
> >                                             WcfEndpoint.BoundTo(new
> > BasicHttpBinding()).At("http://localhost:1010/MyService"),
>
> > WcfEndpoint.BoundTo(MetadataExchangeBindings.CreateMexHttpBinding()).At("ht tp://

Craig Neuwirt

未讀,
2010年8月12日 清晨7:39:472010/8/12
收件者:castle-pro...@googlegroups.com
Is it possible to send me your app, or the part the does the WCF stuff so I can try it out.

Khash

未讀,
2010年8月13日 上午11:27:352010/8/13
收件者:Castle Project Users
Sent to your email address.

Craig Neuwirt

未讀,
2010年8月17日 清晨7:50:392010/8/17
收件者:castle-pro...@googlegroups.com
I service is ok. I think you need PublishMetadata() instead of WithMetadata()

Khash

未讀,
2010年8月20日 清晨6:16:492010/8/20
收件者:Castle Project Users
Thanks. Using PublishMetaData fixed it. Here is what worked:

var container =
new WindsorContainer()
.AddFacility<WcfFacility>()
.Register(Component
.For<IMyService>()
.ImplementedBy<MyService>()
.LifeStyle
.Transient
.AsWcfService(new
DefaultServiceModel()
.AddBaseAddresses("http://
localhost:1010/MyService")
.AddEndpoints(WcfEndpoint
.BoundTo(new
BasicHttpBinding())
.At("basic"))
.PublishMetadata(o
=> o.EnableHttpGet())))
.Register(Component.For<IMyRepository>().ImplementedBy<MyRepository>());
回覆所有人
回覆作者
轉寄
0 則新訊息