I have a question about how to obtain the results, condition codes and messages from a C# 2008 console application and a web service
Basically I have received the C# 2008 console application code that calls a remote webservice and consumes the results. The console application runs by giving it commands to know what method in the web service to call.
Now I am going to write a C# 2010 service application that will call the C# 2008 console and run the commands in a specificed order. There are three types of calls that need to be called in a specified order.
Basically the steps would be:
1. write the new .net app to make callls in a sequential order to a console app progrm.
2. The console application calls the web service and obtains the results,
3. The new .net app obtains the results of the web service from the console application it called.
Let me know how I can accomplish my goal with code and/or references.
VulpesPosted Sep 4, 2012, 1:41 PM
http://blogs.msdn.com/b/lifenglu/archive/2007/06/15/svcmap-file.aspx
dcPosted Sep 3, 2012, 7:16 PM
1. You mentioned the following, "Basically, the log file needs to have a fixed format, so that the new app can read it."
Can you show me code that I can add to the console application so the log file can be in a fixed format?
2. I am also assuming that a log file from the console application should write out any messages that have been generated by the web service.
Thus would I want the messages required for step #1 in a fixed format to be in the same file with messages that are generated by the web service?
I would think I would want two log files? Is that possible?
Can you show me code to have two separate log files?
dcPosted Sep 3, 2012, 7:05 PM
- *.wsdl and
- reference.svcmap.
I know the wsdl file is the web service but do you know what the reference.svcmap is (the code that consumes the web service?)
b. the xsd is auto-generated is generated by a tool.
c. the xsd is connected to the ip address of the web service. The web service is connected is the xml since it is setup to parse the dom object.
VulpesPosted Sep 3, 2012, 7:01 PM
For example, suppose the log file contains something like this:
Customer number : 1
// lines of info for c/n 1
Customer number : 2
// lines of info for c/n 2
The new app can then read the file as follows:
class Customer
{
public int Number {get; set;}
// other properties
}
// ...
List
string[] lines = File.ReadAllLines("customer.log");
Customer currentCust = null;
foreach(string line in lines)
{
if (line.StartsWith("Customer number")) // time to process a new Customer
{
if (currentCust != null) customers.Add(currentCust); // save existing Customer, if any
currentCust = new Customer(); // create new Customer object
currentCust.Number = int.Parse(line.Split(':')[1]); // set Number property
}
// set currentCust properties using data from following line(s)
}
customers.Add(currentCust); // add final Customer object to list
// code to process customer list
dcPosted Sep 3, 2012, 6:22 PM
I still want to mention/ask the following:
1. Your statemenet, "Going back to the first of your original questions, do you mean how would the console application (as opposed to the new app) obtain the values of the customers it needs to loop through?"
I do mean the new app (not the console application). The console application obtains a list of customer numbers and the console application can parses the list of customer numbers.
However I need to pass all the customer numbers to the new application.
Thus can you tell me how the console application can the list of customer numbers to the new application. It is the new application that needs to process each customer number in a sequential order.
2. I like the idea of writing the output from the console application to a new file each time it writes to the log file for the new application to access. However my is, do you have code that would show me how the new application can read the log file that is in a text file? (Basically how would I know where the file starts and where the file ends, carriage return characters?)
It would be easier to use a new file for each call but,
VulpesPosted Sep 3, 2012, 11:41 AM
dcPosted Sep 2, 2012, 5:38 PM
1. I do have access to the console application's source code (and can therefore alter it).
2. Extra note: there is an *.xsd file that is included in the console application. When I just look at this *.xsd file, it looks like a large percentage of the error messages that I have seen might come from this code. My problem is that I do not know how this *.xsd code is wired into the application to cause the error messages to be displayed. Is there some kind of a way you would know how these error messages are wired into the C# 2008 application?
This *.xsd file looks like this is the schema defintion of the database the contract shop uses. Maybe this *.xsd file is not even used by this console application. Maybe it is in the code base just for me to look at. Is there a way that I can tell of the *.xsd file is not being used? if so, I would I be able to tell?
I do know that the webservice that I call must be written in java since I see alot of java runtime errors.
3. The console application is only set up to run when I run the commands from the console application.
As far as I can tell the log messages just appear on a popup dos window.
VulpesPosted Sep 2, 2012, 11:47 AM
Do you have access to the console application's source code (and can therefore alter it) or do you have to live with it as it stands?
Is the console application designed to run continuously, writing results to the log file from time to time or does it collect all the results at once, write them to the file, and then exit?
dcPosted Sep 2, 2012, 11:17 AM
1. One of the commands is a list of cusomter numbers that need to be processed. The second command in the sequence is to download informaton from the web service one customer at a time. Thus how would this new .net application obtain the values of the customers it needs to loop through?
Would I need to save the data to a database or some other method? What do you suggest?
2. How would the new .net application use the results of the text file that is written as a log file? Basically how can the .net application know how to read the log file to obtain the results it needs to work with?
VulpesPosted Sep 2, 2012, 10:45 AM
The console application can then read the command line arguments, call the web service, obtain the results and write them to a text file before exiting.
When the console application ends (use Process.WaitForExit method), the windows service can then read the results from the file and (if necessary) delete it.