PDA

View Full Version : Is it possible to configure WCF only in the context?



rolandz
11-28-2009, 09:46 AM
Hi

What I would like to have is to be able to configure WPS without having system.serviceModel section in the application configuration (app.config).

All my attepts fail until now as I am really newbe to the WCF and possibly don't have enough knowledge.

The question is whether it is possible at all.

My current server configuration is as follows:

<object id="service" type="WCF.Server.Service, WCF.Server">
</object>

<object id="serviceExporter" type="Spring.ServiceModel.ServiceExporter, Spring.Services">
<property name="TargetName" value="service"/>
<property name="MemberAttributes">
<dictionary>
<entry key="Foo">
<object type="System.ServiceModel.OperationContractAttribute, System.ServiceModel">
</object>
</entry>
</dictionary>
</property>
</object>

<object id="serviceHost" type="Spring.ServiceModel.Activation.ServiceHostFactoryO bject, Spring.Services">
<property name="TargetName" value="serviceExporter" />
</object>


...but it is not enough I think.

Also - the same wish for the client side? How to get it working without standard WCF configuration?

Finally: the motivation is to have a possibility to have WCF configuration parametrized by others, like command line arguments, whatever else arguments... /espacially command line/

TIA

rolandz
11-29-2009, 08:18 AM
I've found following setup code in the ServiceHostFactoryObject class:


public virtual void AfterPropertiesSet()
{
// [...]

springServiceHost = new SpringServiceHost(TargetName, objectFactory, BaseAddresses);

springServiceHost.Open();

// [...]
}

Immediate service opening closes any ways to provide custom configuration which might be applied according to the following article: http://en.csharp-online.net/WCF_Essentials%E2%80%94Programmatic_Endpoint_Confi guration

What seems to me a good solution is to have a possibility to manually open service (with some flag?) or additional configuration stuff (properties line endpoints, bindings, etc.) that would be optionally used to configure the host object.

Currently I want to develop some solution for me. When it's done I can share the idea. Also I would like to know opinions of users that know WCF better than me.