.NET Framework Bookmark and Share   
 index > .NET StockTrader Sample Application > accessing MCS Service From Windows Client(Not implementing MCS)
 

accessing MCS Service From Windows Client(Not implementing MCS)

Hi Greg,

How can i access my MCS WCF Servicefrom a windows client which doesn't implement MCS.
Also how can i create a proxy for myn service as i am unable to create it through SVCutil.
Narayan Sahu
Hi Narayan,

You can access a configuration service based WCF service from a client that does not implement the configuration service just like any other WCF service, since after all, it is simply a WCF service, through a proxy that you can generate with svcutil. What trouble did you have generating the client? I have sucessfully created proxies from running services using the mex endpoint.

Although I haven't used it, the Create Configuration Repository tool can also generate proxy's using svcutil from the assemblies, under the Service Client Generation tab.

Thanks,
Darren
dbrust
Hi Darren,

I have successfully created the proxy using repository create tool svcutil; but in client constructor it requires "Service Host Name" and since the client application doesn't point to config service repository,its failing over there.

Its failing at :

public PreviewWinClient(string serviceName)

{

Settings settings = new Settings();

theClient =

new Client(serviceName,settings);--->Failing with error null reference exception

}


Also i would like to know what client endpoint addreess do i need to use to send message to wcf service(MCS).


Thanks
Narayan sahu

Narayan Sahu
To use the client generated from Repositort Create tool, the client app currently must implement the Configuration Service as well.The client hooks into its own repository and then is geared to send/receive notifications to/from the services it consumes for those services that also implement the Configuration Service, and also load balance/failover against services that do not implement config service. This is best suited for remoting scenarios (for example, asp.net server app that is a client to backend services within an intranet--ala StockTrader app); although windows clients can implement the configuration service as well. The load balancing is achieved via the client logic. HOwever, as noted above, a service that implements the config service can be accessed from a standard WCF client as well (such as generated by svcutil); but this client will not load balance/provide auto failover across service nodes (which the repository create tool generated client does--but requires client app to also implement the config service). For details, there is a step by step, end-to-end tutorial included in the docs. In the future, we plan to work on a "client-lite" solution that does not require client to implement config service.

-Greg
Greg Leake, Microsoft
Gregory Leake
Hi greg,

Thanks for the reply.

My problem is i don't want to implement Configuration Service in my client Application which is a windows application.

My Service implements MCS and i don't want to load balance that service since it will have only one instance.

The problem is using SvcUtil the proxy client and app.config gets created but as far as i know the client applicationstill requires Config database for client(Which i don't want) and also it requires the service host name in client constructor which is giving problem to me.

Actually My service have two contracts andboth have separate functionalities.One will be used for Load balancing that's why i have implemented MCS in it butfor the other contract no load balancing is requierd.For the first scenario i am done but for second onei simply want to create a proxy of it as regularwcf proxy using svcutil.For this i am even ready to remove theMCS section from app.config file since it won't affect my deployment and the code base will remain the same.


So please let me know how to create a proxy of a service implementing MCS and how i can use it in a client application which doesn't implement MCS.The steps mentioned in the DOC have a client which also implements MCS and all the sample code also contains client's with MCS.

So please help me out.



Narayan Sahu
Although I am a little confused about your scenario, as Greg mentioned above, every service that we are talking about is simply a WCF service...including the services that implement MCS.

You do not have to use a client generated by the MCS tools.

You can use a client generated by svcutil, however, you will not receive any soft of fail-over or load balancing.

The client does not need to implement MCS, meaning it does not require a Config database if you will not be using the MCS client generated by the tools. Again, you will not get loadbalancing or fail-over.

Just point svcutil to your mex endpoint or assembly, and give it a go.

Thanks,
Darren
dbrust
Thanks Darren,


I don't need any load balancing.Only thing is i want to create a proxy of MCS With Svcutil so that i can use it in my win client App which doesn't implement MCS.



what should i specify in Svcutil command to create proxy

This svcutil net.tcp://configserver ?I mean which address should i Specify

My app.config contains

<

services>

<

service name="SHL.ReportEngine.ReportGenerator.HostConfigurationImplementation.ConfigurationService" />

<

service name="ConfigService.ServiceNodeCommunicationImplementation.NodeCommunication" />

<

service behaviorConfiguration="SimpleServiceBehaviors" name="SHL.ReportEngine.ReportGenerator.MessageReader" >

</

service>

</

services>

<

client>

<!--

RG Client Endpoints-->

<!--

End Point For Preview Server-->

<

endpoint address="net.tcp://configserver" binding="netTcpBinding"

bindingConfiguration="Client_TcpBinding_PreviewServiceBinding"

contract="SHL.ReportEngine.ReportGenerator.IPreview"

name="Client_TcpBinding_PreviewServiceBinding" />




Narayan Sahu
You can do thisthree ways:

svcutil <assembly>

where <assembly> is the assembly that contains your service contracts.

svcutil <path>

where <path> is the path to your running service. This has nothing to do with net.tcp://configserver. The path points to the endpoint you have exposed as a running service. If this endpoint is a virtual address exposed through config service, you use that virtual endpoint. If it is defined in a .config file, then use that address. Only you could possibly know this address.

Use the repositorycreation tool that comes with MCS. You'll notice on the service client generation tab there is an option to generate a tool via svcutil. You can follow the directions in the tutorial, but choose svcutil generated client, and point to the assemblies that contain your contracts, just like in the first option.

For further information on svcutil, look at:

http://msdn.microsoft.com/en-us/library/aa347733.aspx

Thanks,
Darren
dbrust
Thanks Darren,

Sorry for troubling you again and again.

I know all the methods of creating proxies i.e. through Repository tool or svcutil but i am unable to create proxy of it using svcutil as suggested by you.

I have successfully implemented MCS both for the server and client for other projects but for this one my client doesn't need to implement MCS that's where i am facing problem creating proxy.

Here are the endpoints for my service shown at service console

My primary business service configured at port 5003 in configweb.

So my service address becomes
net.tcp://localhost:5003/Preview
net.tcp://cu-345.rave-tech.co.in:5003/preview/mex
http://cu-345.rave-tech.co.in:5001/previewservice/config
net.tcp://cu-345.rave-tech.co.in:5002/previewservice/node


Now if i say
SvcUtil net.tcp://localhost:5003/Preview

It says Cannot get Meta data from net.tcp://localhost:5003/Preview



And If i create the proxy from repositry create tool using service contract assembly, i am able to create proxy but when i use that proxy from my client it says "object reference not set to an instance of an object"


public PreviewClientProxy(string serviceName)
{
theClient =
new Client(serviceName,new Settings()); -> error: object reference not set to an instance of an object
}

And i have created my proxy client in Client application like this

client =
new SHL.SODA.Preview.PreviewClientProxy("SHLSODAPreviewReportGenerator Service Host");

Please suggest me where i am getting wrong.

Please suggest me where i am getting wrong.


Thanks
narayan Sahu

  • Edited byNarayan Sahu Friday, May 08, 2009 7:28 AMMore clarification added
  •  
Narayan Sahu
Thanks Greg,Darren,


I have sorted out the problem.

Its actually the datacontract which is creating problem in creating proxy.
I have changed the datacontract and now i was able to create proxy of MCS.

Thanks EveryBody
Narayan Sahu
Narayan Sahu

You can use google to search for other answers

Custom Search

More Threads

• XML data store as Config Service Repository
• OrderMode=’Async_Msmq?& compilation error
• Configuration Source Code and StockTrader 2.02 Release
• App.config endpointIdentities
• Architecture conceptual q.
• 2.02 Release Now Live: Read for download link!
• only IE supported for /trade application
• Silent install or other scripted install options?
• Configuration Service 2.0: the size of KeyValue in ConfigurationKeys table
• Load Balanced Windows client app - Config & Node service ports