1

Context:

I have never created something or worked on this subject before but I have done my research and now I know what's the subject.

I have a virtual server machine(machineVM) and not a virtual client machine (machineA).

I should send a HTTP request from machineVM to machineA to a specific port. machineVM sees and knows machineA,i.e, it knows client name of machineA(myClient) via the HTTP request .

I'd like to say to machineA: "I have a document for you, come and get it.". On machineA I will have a windows service that will listen to that port and do its stuff.

That HTTP request should look like:

http:\\myClient:port/request_message_body

What are the possible wayouts to achieve the task?

  • HTTP POST ?
  • I am aware that HTTP uses port 80. How to decide and which port to use, which port will windows service listen, on which port should HTTP request be sent?
  • In this request_message_body I'd like to share a path to the folder from which machineA could fetch the document and to specify server and port.
  • How to format HTTP request correctly?

I should be able to create windows service that listens to a port, because I've created few services before, but I really need help with creation of this HTTP request and sending it.

Any help will be appreciated.

Sheridan
  • 68,826
  • 24
  • 143
  • 183
Sylca
  • 2,523
  • 4
  • 31
  • 51
  • 2
    Well... do you have an actual HTTP server which can accept HTTP requests? Otherwise you can send all you want, nothing is going to respond. – Gimby Feb 26 '14 at 11:51
  • 1
    suggestions: HTTP is port 80 whether in windows or linux. I will suggest to use scripting langs like php on the server side (just based on my expr),things like file upload are easier there. to do the client side http post here:http://stackoverflow.com/questions/4205980/java-sending-http-parameters-via-post-method-easily. I am assuming you are having standard http server like @Gimby said. – dsharew Feb 26 '14 at 11:56
  • @Gimby I have standard http server. – Sylca Feb 26 '14 at 12:13
  • Good, and now I can in all certainty upvote Lance Java's answer because I know your working environment supports it. – Gimby Feb 26 '14 at 12:52

2 Answers2

3

If you want to roll-your-own solution, you'll probably want to build on top of httpclient

There's also loads of libraries out there to help you to build restful webservices (springws, resteasy, jaxrs etc)

lance-java
  • 25,497
  • 4
  • 59
  • 101
0

Solved!

Thank you @Gimby and @user2412816. You guys made me go through my code again and it was my mistake, like the most of the time. :-)

Sylca
  • 2,523
  • 4
  • 31
  • 51