two clients using two services using same port with singleton in service to manage application servers

two clients using two services using same port with singleton in service to manage application servers

Old forum URL: forums.lhotka.net/forums/t/9135.aspx


edreyes77 posted on Friday, June 25, 2010

Greetings,

I am hoping someone can assist in this new request involving wcf configuration for a project I am working on. 

The current project is using CSLA 3.8.2, has a Silverlight client hosted in an asp.net web server (just regular stuff) that also hosts WCF dataportal service written in a .net assembly - just like the silverlight videos show. The wcf/dataportal service has a singleton that maintains some service information that is required for all clients to talk to an appropriate application server.  There is only one singleton object to manage clients talking to the application servers.  This was the easy part thanks to the silverlight videos.

Now I have to have a second endpoint for essentially the same service.  The second endpoint must go into the service and use the single singleton to manage clients from either endpoint to talk to the various application servers.  All the application servers essentially run the same code and have access to the same data.  The application servers are identical.

The new endpoint is for third party client software that cannot use CSLA/dataportal. 

I believe I am suppose to have 2 svc files. 
The two service files point to the below servicemodel info in my web.config.

<system.serviceModel>
<services>
<service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
<endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal" bindingConfiguration="BasicHttpBinding_IWcfPortal"/>
</service>

<service behaviorConfiguration="WcfPortalBehavior" name="Demo.Web.OVSDataPortal">
<endpoint address="" binding="basicHttpBinding" contract="IOWcfPortal" bindingConfiguration="BasicHttpBinding_IWcfPortal"/>
</service>
</services>

</system.serviceModel>

or should I try to do something like?

<system.serviceModel>
<services>
<service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
<endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal" bindingConfiguration="BasicHttpBinding_IWcfPortal"/>

<endpoint address="" binding="basicHttpBinding" contract="IOWcfPortal" bindingConfiguration="BasicHttpBinding_IWcfPortal"/>
</service>
</services>

I am not even sure if the second servicemodel config is even possible. 

I currently cannot get the non-csla wcf service to work in iis.  I can get them both to work in web development server through VS2008 but i cannot test to see if they will work togeher in VS2008, but when I deploy I can't get them to work at the same time using the service and the same singleton object to track application servers.

I can get several silverlight clients to work in iis and use the dataportal service and use the singleton object to manage server applications, but I am having trouble getting the new non-csla version to work with the csla version in iis, and I don't seem to get any error messages.

can someone suggest anything I might try.  I think it's an issue with configuration of maybe even packaging of my services.  I am not sure what to think yet.
 

RockfordLhotka replied on Friday, June 25, 2010

Architecturally, you need more than just another endpoint. You need a service interface designed for use by external applications. This is the focus of Chapter 21 in the Expert 2008 Business Objects book.

You can build that interface on top of your business objects, because your objects are running on the server as well as in your SL client. So you already have the objects - you just need to define a service contract and implement it.

The data portal service endpoints require that the consumer be a client-side data portal. No third party application will have that capability, so that's a complete dead-end.

edreyes77 replied on Friday, June 25, 2010

I did as you suggested already.  

 I have one service with two contracts for a respective endpoint as below:

<system.serviceModel>
<services>
<service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
<endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal" bindingConfiguration="BasicHttpBinding_IWcfPortal"/>
<endpoint address="" binding="basicHttpBinding" contract="IOWcfPortal" bindingConfiguration="BasicHttpBinding_IWcfPortal"/>
</service>
</services>

</system.serviceModel>

the first uses mobile business objects and is using IWcfPortal for it's contract. 

the second does not use any csla nor mobile objects and is using IOWcfPortal for it's contract. 

I would like both contracts to be in one service, so they can share functionality.  They need to share a single instance of a resource manager so they can assign resources (application servers) correctly to the silverlight clients.

When I add the second endpoint and run, I get:

System .Reflection.TargetlnvocationException: An exception occurred during the operation, making the result invalid. Check InnerException for exception details.
---> System .ServiceModel .Com municationException: The remote server returned an error: NotFound. ---> System .Net.WebException: The remote server returned
an error: Nolfound. ---> System .Net.WebException: The remote server returned an error: NoFound.
at System .Net.Browser .ßrowserHttpWebRequest. InternalEndGetResponse(IAsyncResult asyncResult)
at System .Net.Browser .BrowserHttpWebRequest. < >c_D isplayClass5. <EndSetResponse >b_4(Object sendState)
at System .Net.Browser .AsyncHelper. < > c_DisplayClass2. <BeginOnUl >b_O(Object sendState)
--- End of inner exception stack trace ---
at System .Net.Browser .AsyncHelper .BeginOnUl (SendOrPostCal Iback beg inMethod, Object state)
at System .Net.Browser .BrowserHtlp WebRequest.EndGelResponse( JAsyncResult asyncResult)
at System .ServiceModel Channels .HttpChannelFactory .HttpRequestChannel .HttpChannelAsyncRequest .Co mpleteGetResponse(IAsyncResul t result)
--- End of inner exception stack trace ---
at System .ServiceModel .AsyncResult .End[TAsyncResult](IAsyncResult result)
at System .ServiceModel Channels .ServiceChannel .EndCal I (String action, Object[] outs, JAsyncResul t result)
at System .ServiceModel .Clienlßase’ 1 .ChannelBase’ 1 .Endlnvoke(String methodName, Object[] args, JAsyncResult result)
at Csla .Wcf Portal .WcfPortalCl ient .WcfPortalCl ientChannel . EndFetch(IAsyncResu It result)
at Csla .Wcf Portal .WcfPortalCl ient .Cs la .WcfPortal . I Wcf Portal .EndFetch( I AsyncResult result)
at Csla .Wcf Portal .WcfPortalCl ient.OnEndFetch(IAsyncResult result)
at System .ServiceModel Cl ientBase’ 1 .OnAsyncCal lCompleted(IAsyncResul t result)
--- End of inner exception stack trace ---
at System .ComponentModel .AsyncCompletedEventArgs .RaiseExceptionlfNecessary()
at Csla .Wcf Portal .FetchCompletedEventArgs .get_Result()
at Csla .DataPortalCl ient.WcfProxy’ 1 ,proxy_FetchCompleted(Object sender, FetchCompletedEventArgs e)


Rocky,  Is it possible to add a second endpoint with a different contract to a service that is using a Csla/DataPortal and mobile objects through the "Csla.Server.Hosts.Silverlight.IWcfPortal" contract?  I am doing this because I need to use a single instance of an object in a service with two contracts

 

 

RockfordLhotka replied on Monday, June 28, 2010

Terminology becomes important here.

A "service" is a unit of functionality running on a server. Typically a service has one contract. In rare cases a service may have multiple contracts - though that is arguably multiple services that share a common implementation behind the contracts.

A single virtual root can host any number of services.

In any case, each service can have one or more endpoints, each defined by a URL to a svc file (or asmx, etc). So you can have http and tcp endpoints exposing the same service - on different ports of course. Each endpoint has its own svc file and config.

You can also have multiple http endpoints for a single service - typically using different WCF bindings. In this case they'd share the same port - but each endpoint has its own svc file and config.

The IWcfPortal interface is a contract, and therefore it is a service. You can expose multiple endpoints for this service - but they'll all be the same service, just with different protocols.

What you want is different. You want two different services. You want the data portal service (which you already have), and you want a completely new service with a contract you've defined for use by external clients.

That's easily accomplished - you just need a second svc file and config entry for your second service. Again, multiple services can be hosted in one virtual root - each service just has a different URL to get to the appropriate svc file.

Copyright (c) Marimer LLC