c# - How to Use One EF DataContract and 2 WCF Services in the Same Application -
i'm having horrible time trying work. have multiple - identical - wcf services using ef installed on different servers. each of them access different database on different instances of sql server.
i'm trying create method will allow me connect instance1.mydatabase , instance2.mydatabase @ same time.
i can create 1 endpoint address in app.config because there 1 contract ef data. here endpoint in app.config
<endpoint address="http://server01/dataservice/data.svc" binding="basichttpbinding" contract="query.ipsidata" bindingconfiguration="wcfhttpbinding" behaviorconfiguration="wcfhttpbehavior" />
when creating data context object entity framework object, have tried using 2 different uris.
context1 = new deventities(service1uri) context2 = new deventities(service2uri)
what happens context1 returns data , context2, while creating , querying without error, not returning records. have tried entering new endpoint in config, not compile because both endpoints use same contract.
is there way around this?
ok, feel stupid posting question. helps if terminology right before posting. helps if reference correct services in config files.
i have lot of info in config. no excuse, i'll use anyway.
so, access 2 different services using same entity framework wcf service definition, it's matter of creating endpoints correct service! mine had typos, why didn't work.
first, need reference uris in appsettings:
<add key="productiondatauri" value="http://prodserver/prodservice.svc"/> <add key="qadatauri" value="http://qaserver/qaservice.svc"/>
second, need webhttpbinding endpoints:
<webhttpbinding> <binding name="wcfwebbinding" opentimeout="00:10:00" closetimeout="00:10:00" sendtimeout="00:10:00" receivetimeout="00:30:00" maxbufferpoolsize="2147483647" maxbuffersize="2147483647" maxreceivedmessagesize="2147483647"> <readerquotas maxdepth="2147483647" maxstringcontentlength="2147483647" maxarraylength="2147483647" maxbytesperread="2147483647" maxnametablecharcount="2147483647" /> </binding> </webhttpbinding>
third, need 2 endpoints match uris:
<endpoint address="http://qaserver/qaservice.svc" binding="webhttpbinding" bindingconfiguration="wcfwebbinding" name="wcfqawebbinding" contract="*"/> <endpoint address="http://prodserver/prodservice.svc" binding="webhttpbinding" bindingconfiguration="wcfwebbinding" name="wcfproductionwebbinding" contract="*"/>
done.
Comments
Post a Comment