04004756
asked on
Web Services/Console Application/C#
Hello Experts,
I was wondering if you could give me a little help. I have created a project with 2 applications in it. One is aN ASP.NET Web Service, called "FindSum1" and the second is a Console Application called "FindSum2".
Within "FindSum1" I created a web method with the following code attached bellow.
I then created "FindSum2" which as previously stated was a Console Application. After that i connected the project via WebService and named it "AddService".
Within the console file I would like to have the user input 5 different integers and it will use the webservice to add them all up and return the answer of the sum. Any help with how I go about this? I know how to do this in the traditional method, but I have became a little lost when it comes to calling the web service. I have also attached the code that I have implemented so far for the Console Application.
This is the code I have so far. Any help would be GREATLY appreciated!
Thanks in advance!
I was wondering if you could give me a little help. I have created a project with 2 applications in it. One is aN ASP.NET Web Service, called "FindSum1" and the second is a Console Application called "FindSum2".
Within "FindSum1" I created a web method with the following code attached bellow.
I then created "FindSum2" which as previously stated was a Console Application. After that i connected the project via WebService and named it "AddService".
Within the console file I would like to have the user input 5 different integers and it will use the webservice to add them all up and return the answer of the sum. Any help with how I go about this? I know how to do this in the traditional method, but I have became a little lost when it comes to calling the web service. I have also attached the code that I have implemented so far for the Console Application.
This is the code I have so far. Any help would be GREATLY appreciated!
Thanks in advance!
[WebMethod]
public int Add(int a, int b, int c, int d, int e)
{
return a + b + c + d + e;
}
namespace FindSum2
{
class Program
{
static void Main(string[] args)
{
AddService.Service1SoapClient client = new AddService.Service1SoapClient();
Console.Write("Please Enter Integer 1: ");
}
}
}
ASKER
Thanks for the reply. I had code similar to this and it worked. When I run the console, rather than having pre determined numbers , the console would ask the user to input five numbers instead, and that would take them, add them up and display the result.
Sorry if I had originally confused you. Thanks for the help so far.
Sorry if I had originally confused you. Thanks for the help so far.
If I understand correctly, you have the web service working, but you need to know how to get input for a console application?
If that's the case, check out http://social.msdn.microsoft.com/Forums/en/vblanguage/thread/c9410e6c-4462-45aa-8172-af12c07b48f9
You can save each ReadLine to a string and then call the webservice using CInt(ReadLine1), CInt(ReadLine2), etc.
If that's the case, check out http://social.msdn.microsoft.com/Forums/en/vblanguage/thread/c9410e6c-4462-45aa-8172-af12c07b48f9
You can save each ReadLine to a string and then call the webservice using CInt(ReadLine1), CInt(ReadLine2), etc.
ASKER
Yeah, I have the web service working 100percent correct. I know in a normal application you would type:-
static void Main(string[] args)
{
// Storage
int value1 = 0;
int value2 = 0;
int total = 0;
// Get first number
Console.Write("Enter a whole number: ");
value1 = System.Convert.ToInt32(Con sole.ReadL ine());
// Get second number
Console.Write("Enter another whole number: ");
value2 = System.Convert.ToInt32(Con sole.ReadL ine());
// Add them together
total = value1 + value2;
// Output the answer
Console.WriteLine("The total is {0}", total);
}
etc. etc. to read in values from the user and to add them all up. I'm just not too sure how to edit that to fit into the web service.
static void Main(string[] args)
{
// Storage
int value1 = 0;
int value2 = 0;
int total = 0;
// Get first number
Console.Write("Enter a whole number: ");
value1 = System.Convert.ToInt32(Con
// Get second number
Console.Write("Enter another whole number: ");
value2 = System.Convert.ToInt32(Con
// Add them together
total = value1 + value2;
// Output the answer
Console.WriteLine("The total is {0}", total);
}
etc. etc. to read in values from the user and to add them all up. I'm just not too sure how to edit that to fit into the web service.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window