Run Web-Service and Client on two computers - c#

I have to run my Web-Service project on two computers. I have created very simple project with tutorial helps, but it working only on localhost. Next thing I have to do is create a local network, where on first computer I will run web-server and second will be a client.
Do you have some ideas how to do this?
I'm new in C# and WS technology.

You can setup a Virtual Machine on your Computer to simulate a small local network.
The server socket must be bind to your network ip address or just 0.0.0.0, so that it is reachable from everywhere.
It would help to post some code here, to show what you already have done.

Related

How to run TCP Sockets application from different computers

I would appreciate if someone could help.
I have written a Client/Server Sockets application. The client is Windows Forms C# app and the server is a C# console app which runs locally. The client application has a login form containing the field with generated port.
When user logins he is connecting to the server using that port and the server continues listening incoming connections.
Everything works fine when I test my application simply running several instances of Visual Studio project on one PC. Now, I would like to test it on several PCs and I am very confused here.
I would be grateful if someone could explain in simle words how to run my app on two machines.
How do both users connect to the same server? Where should it be located? Should the server have one IP and different ports per one users group?
Also, my application uses SQL Server Database which is installed locally on one PC. So the application uses connection string with that PC Name. In case of two PCs is it possible to connect the second computer to DB on first PC?
I am sorry if this sounds silly :)
Thanks a lot
So if I am correct you are wondering the following three things?
Q1. How do I test my software in a multiple machine environment.
A: This is perhaps not really a Stackoverflow question but what I would do in this case is to have a small setup in Hyper-V with several machines with different operating systems that all have a shared folder that I can deploy my code to. Of course for more extended testing you would need to get more machines and copy the executables to that machine for testing for the first stage and perhaps write a setup software for the second stage of testing, but that depends on the how much testing you actually do.
Q2. How to I allow several users to connect to my service?
A: I think that Anthony Horne has a great answer to this in the comments - Tell your service to listen on port X and when a client tries to connect open a new communication instance on port Y and ask the client to call back to that port. This is as far as I know industry standard for solving this type of problem.
Q3. My application uses a SQL Server Database can I allow clients to connect to it remotely.
A: Yes you can. Please see this Stackoverflow question.

Windows Service communication, sockets, c#

i'm writing a server side application and a windows service which need to be installed on a remote host
the service returns CPU usage to the serverside application - this is NOT the problem
the serverside application deploys the service on the remote host. - also, not the problem
THE PROBLEM:
but how do i setup a socket connection between the two, when i dont want to hardcode the ip address? (for scalability) - do i need to use multicast or is there some devious way of doing this? is there another solution than using sockets? -
i'm new to writing Windows Services.
I need help figuring out how to communicate between the server and the service without hardcoding IP-addr.
thank you in advance.
MY SOLUTION:
I created a windows service, that reads a xml file with the IP and port of the Server application. so when i deploy my client application, i also create a xml file with the network information.
Regards Alex
A lot of communication platforms now use network discovery; there's an article on codeproject that goes into detail about using network discovery.
The problem was, I did not know what machine name the server was running on, in fact I wanted this to be flexible, and selectable by the user.
Seems relevant to http://www.codeproject.com/Articles/16113/Retreiving-a-list-of-network-computer-names-using
Have you thought of using WCF?
http://msdn.microsoft.com/en-us/library/ms731082.aspx
Regarding multicast, you can have a WCF server multicast announce it's availability on a network; see http://msdn.microsoft.com/en-us/library/dd456782.aspx
another solution could be to create the service as a console application with arguments (endpoint ip address) and then just deploy it with the arguments on the remote host

Socket Programming on a single computer?

I am building a client-server chat application.
It has both a server and a client part.
Is it possible to test the application on the same machine or do i need really need two different computer to run the application.
Yes, it is possible to test your application on same machine.
IP Address of both client and server in this case would be same. Just open different ports for client and server.
Yes, it's possible.
Start your server up and it will listen to a specific port(The server application either has defined one or you have to provide one to it).
Start the client application and make it connect to your machine (127.0.0.1) with the port number your server application listens to.
You may have to modify the application to change the IP address or port number if the program you have does not provide you command line options to specify them.
You can test on the same machine. I am doing this right now as I type this note. :)
Of course normal things you would expect apply...you can't test two listeners on the same port which are on the same interface, for example. But a client connecting to a server on the same box should work no problem.
And of course before you release you should test on different machines as well. This could expose bugs that a single box config does not.
no need, you can bind same IP and different port. they will work.
or you can install a virtual machine.
You can test on the same machine, just make sure the the client and server bind to different ports.
Yes you can test it locally. You can use the loopback address of 127.0.0.1 , your machine name or ip address to connect.
If you are selecting port numbers for your app, please make sure you understand what ports are used and reserved for other programs. For example, if you try and use port 80, you will run into conflicts with people who are running web servers.
Also, while testing locally is great, you need to make sure you understand how your app will need to be configured in different firewall applications and routers.

Consuming Asp.net web service from remote computer

I create Asp.net WS and host it on the IIS.Now i want to consume it from remote computer or another computer.When i insert the URL of the WS on the remote computer an error message appears inside internet explorer browser page says
This program cannot display the web page
i work on Visual studio 2008, windows 7 and the client application is Asp.net website.
i don't know what is the problem??
have i connect the two computers with LAN(make network between them) or just enough each one connect to the internet??
Your computers need to be able to connect to each other.
If they on LAN, then You need to specify LAN address for asp.net WS.
Also check Your firewall for blocking connections, need to be sure that port were IIS hosted is available for connection
If nothing helps, then provide us more information about problem.
Really i don't know what is the problem.When i do the same thing in another computer it runs but on my laptop doesn't run.

Is it possible to write C# code as below and send email using network in different country?

Is it possible to write C# code as below and send email using mnetwork in different country?
MSExchangeWebServiceURL = mail.something.com/ews/exchange.asmx
It's a web service URL. This works great when I run the same code from home network, my friends home network anywhere around, but when I run it from my client's location in Columbia it fails.
I have a valid user name and password on that Exchange Server. Is there any configuration that I can set to achieve this?
BTW this code below works when I run it within office network and any network within any home network. I have tried it at least with five friends network in Plano, Texas. I want this code to work running from any network in another country.
My client in Columbia can connect to the web service using a browser using the same user name and password, but when I run the code above it is not able to connect to our web service.
EDIT: Based on the comments and updated post, I would wager that the client location has a proxy server or firewall that is blocking the traffic. The client probably needs to add the relevant domain to whatever "whitelist" they have.
If it works from an internal network, then the problem is most likely not the code. You need to debug it and see what error turns up when running it outside of the network. Then check the logs on the firewall and the target exchange server to see what is happening.
One possible culprit is that the DNS name is not setup outside the office network, or that the office firewall is not setup to pass traffic (or only to pass SMTP traffic) from the internet to the server in question. Another is that Exchange Web Services is not setup properly to accept requests from the outside world. That can be tested from http://www.testexchangeconnectivity.com/.
If this isn't enough for you to get there, post more info about what errors you are seeing. "It isn't working, I want it to work" kind of reminds me of the Star Trek TNG episode about the species who kept telling Geordi to "make it go".
If you are asking if the code works (which it doesn't look like you are but it's in your post) you should ask on stackoverflow. If you are wondering why it won't work from home Its likely because the edge server is not set up to relay, and if you are at home and not vpn'd into the network that's all you have access to.
You need to break this down a bit:
What's the MSExchangeWebServiceURL? I don't need to know your real URL, but is this resolvable from your home network? i.e. is it an internal DNS host (server.mycompany.local) or is it an externally-resolvable DNS host (mail.yourcompany.com)?
If it's internal, like another poster said, you'll at least need to VPN in (or replace that with the external URL).
I'm not a big C# guy, but I'm guessing it's looking for your Exchange Server hostname or FQDN, and since the type is "SMTP" it wants to establish a TCP session with your mail server. You can likely test this out by opening up your command prompt and trying to telnet <MSExchangeWebServiceURL> 25. When that works, my guess is your code will work too.

Categories

Resources