Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WCF Service on Multiple Servers

Status
Not open for further replies.

vicvirk

Programmer
Feb 4, 2009
636
CA
I work at an international organization with web servers all over the world.

I've successfully developed a WCF Service and am able to call it from my client application when I put it on any individual server.

I have been given the task to delpoy this service to multiple servers around the world and call it from the same client application.

I.E.

We are located in Vancouver, BC and the webserver/oracle db is located in Vancouver, BC.

We have an office in Paris, France.

1. The user from Paris will connect to the client interface in Vancouver, select the labels they want to print.
2. The client interface knows they are from Paris and will send the label data to the WCF service installed on the server in Paris.
3. The server in Paris will then generate these labels locally and print them on the label printer in Paris.

We could generate the labels in Vancouver and send the stream to the printer in Paris, but they contain images and barcodes and the bandwidth usage would be a killer. We'd rather just send the data and have the local server in the user's office generate the barcodes and pull the images required locally and then print locally.

I am having issues with calling the service dynamically from different locations.

I'm not looking for anyone to write the code for me, rather pointing me the right direction (i.e. examples on the web) would be great. I've searched and searched and searched, but can't find any examples of calling the same service in multiple locations.



--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
bump...

Anyone???

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
it sounds like your topology looks like this
1. A Client in Paris tells Vancouver Server to query data
2. Vancouver Server queries data and sends response to Paris Server.
3. Paris Server prints data.
4. Paris Server notifies Paris Client of printed documents.
[tt]
Paris Client
| ^
| |
| 3
1 |
| Paris Server
| ^
| |
| 2
\/ |
Vancouver Server
[/tt]

Why not:
1. Paris Client tells Paris Server to print
2. Paris Server asks Vancouver Server for data
3. Vancouver queries data and responds to Paris Server
4. Paris Server prints documents and notifies Paris Client.
[tt]
Paris Client
| ^
1 4
| |
\/ |
Paris Server
| ^
2 3
| |
\/ |
Vancouver Server
[/tt]
With this model
1. clients in Paris only knows about the server in Paris
2. The server in Paris knows about the clients in Paris and the server in Vancouver
3. Vancouver only knows about Paris server.

Adding nodes (New York, Tokyo, Dubia) would be easier as well because you would mirror the same Local Server/Clients model that you have in Paris.

I'm not up to speed on WCF, but I have some experience with message buses. I believe that is was WCF is in some aspects. if so, the request/response mechanism should handle itself because it knows how to response to.


Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Hi Jason,

Thanks for the response...

Your solution makes sense, but the client in Paris (New York, Moscow, Tokyo...etc) already connects to a webserver in Vancouver to do everything else.

Your suggested setup is how we are running things right now:

Paris client uses a desktop application to query the server in Vancouver. Vancouver returns this data to the client application in Paris and it processes/prints the labels in Paris.

We are moving away from the client application and building everying into a web application. The only way I can think of doing this is to install the service in all of our locations, create a service reference to each of these and use switch / if/then/else statements to determine which service I want to invoke - the only issue with this is that as we deploy to more locations, we need to keep updating the program to add new service references.





--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
you my need service with each web deployment, but I'm still confused as to why you need an if/else statement to determine where to send response. if point a (client or server) send a request to point b. point b knows where to send the response. back to the sender.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Here is how I am calling the service, notice the code highlighted in RED, which sets the label printing (lp) object (note this file is on a server in Vancouver):

Code:
protected void Page_Load(object sender, EventArgs e)
    {
        string strWorkorder = Request["wo"];
        string strLabels = Request["sample"];
        string strUser = Request["user"];
        string strPrinter = Request["printer"];
		string strServer = Request["server"];
        string strServerCall = "[URL unfurl="true"]http://"[/URL] + strServer + "/labelPrinting/Service1.svc";    
        [COLOR=red]
		WCFService.Service1Client lp =
			new WCFService.Service1Client("BasicHttpBinding_IService1", strServerCall);
        strResult = lp.generateLabels(strWorkorder, strLabels, "", "", strUser, strPrinter);
		[/color]
        lp = null;
        lblResult.InnerText = strResult;
    }

WCFService is the name of my namespace when I added a reference to the service on the server (call it ABC), and I pass the value of "ABC" as a "POST" when I call this file.

If I install the service on a different server (call it XYZ), I need to add that service as a reference to this file and I cannot execute the above code because it has a differnt namespace.

So I am going to try something like this (and if you know / can suggest a quicker method to make it more dynamic, that would be awesome!

1. Recreate each service reference as WCFService_SERVER
2. Set one up a service reference as a default in case the service has not yet been installed on a remote server.

Code:
protected void Page_Load(object sender, EventArgs e)
    {
        string strWorkorder = Request["wo"];
        string strLabels = Request["sample"];
        string strUser = Request["user"];
        string strPrinter = Request["printer"];
		string strServer = Request["server"];
        string strServerCall = "[URL unfurl="true"]http://"[/URL] + strServer + "/labelPrinting/Service1.svc";    
        [COLOR=red]
		switch (strServer) {
			case "ABC":
				WCFService_ABC.Service1Client lp =
					new WCFService_ABC.Service1Client("BasicHttpBinding_IService1", strServerCall);
				strResult = lp.generateLabels(strWorkorder, strLabels, "", "", strUser, strPrinter);
				break;
			case "XYZ":
				WCFService_XYZ.Service1Client lp =
					new WCFService_XYZ.Service1Client("BasicHttpBinding_IService1", strServerCall);
				strResult = lp.generateLabels(strWorkorder, strLabels, "", "", strUser, strPrinter);
				break;
			default:
				WCFService_DEFAULT.Service1Client lp =
					new WCFService_DEFAULT.Service1Client("BasicHttpBinding_IService1", strServerCall);
				strResult = lp.generateLabels(strWorkorder, strLabels, "", "", strUser, strPrinter);
			break;
		}
		[/color]
        lp = null;
        lblResult.InnerText = strResult;
    }






--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
I'm not following what you mean here
WCFService is the name of my namespace when I added a reference to the service on the server (call it ABC), and I pass the value of "ABC" as a "POST" when I call this file.

If I install the service on a different server (call it XYZ), I need to add that service as a reference to this file and I cannot execute the above code because it has a differnt namespace.
unless all you mean is that referencing a different server requires adding new references to the project and thus changing the namespace of where the server is located.

where the request is sent to should not be hardcoded into the system, it should be configurable.

An if/else or switch statement is the worst possible solution, as you need to change the code if another end point is added.

this may require another layer of abstraction, and possibly reflection (although I hope not) to get this working in a configurable manner.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
where the request is sent to should not be hardcoded into the system, it should be configurable.

That is where I don't know what I'm doing.

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
here is a thought. WCFService.Service1Client may just be a subclass of the object doing to the work (super class). in that case WCFService.Service1Client will be hardcoded because it's a convenience object, it' not doing any real work.

navigate to WCFService.Service1Client and take a look at the code. chances are you will want to move this code into your code behind to send the message. this should be the code that is configurable.

you should not need to directly reference the service assembly in your client project because the client doesn't really know what's on the other ender, it only knows to send it there.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top