aspose file tools*
The moose likes Web Services and the fly likes Request web service through socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Request web service through socket" Watch "Request web service through socket" New topic
Author

Request web service through socket

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Hi all,

I just saw some code where a web service operation is invoked by means of doing an HTTP Post whereby the HTTP headers and soap envelope are constructed manually and pushed through a socket to the endpoint.
Can anyone tell me what are the disadvantages of doing this as opposed to doing something like Service.create ???

Thanks,

===>SCJP 1.5(72%)<===
==>SCWCD1.5(76%)<===
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 381
Simplified analogy: How do we go from USA to India?

1. Walk
2. Sea
3. Airplane
4. Car
5. Train
6. Use your imagination

Even though any way can lead you to India. But the proper way would be by Airplane if you have the mean.

In another word, use the right tool at your disposal if applicable.

The next question then what is the right tool for any given scenario?
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Okay so then it's not wrong I guess
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 381
Don't try to insist on being right rather try to look at things from context/perspective point of view.

2011- Use Airplane
2000 year ago - by what? and why?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
There is (usually) not right or wrong, because in some cases, may they be rare, there may be justification for using a specific solution to a problem.
If you consider sending a SOAP request by sending a string of characters over a socket, you will have the following consequences:
  • More code to write

  • This will also mean more code to test and more code to maintain.
  • Simpler technology

  • The solution does not require special knowledge about some web service stack or such, albeit there is a slight feeling of reinventing the wheel.
    However, there may be circumstances, such as a special environment (cellphone, for instance), where there are restrictions on the libraries and frameworks that can be used.
  • A non-standard solution

  • Using an existing standard, like JAX-WS, has the advantage of it being a standard.
    If someone knows how to develop, for instance, JAX-WS web services, it will be relatively easy to switch to another web service stack adhering to the standard.
    Understanding a non-standard solution will, most likely, require more effort.

    I am sure there are additional things that can be considered, but I think this will give you a hint.
    Best wishes!


    My free books and tutorials: http://www.slideshare.net/krizsan
    H Paul
    Ranch Hand

    Joined: Jul 26, 2011
    Posts: 381
    1. Suppose my company A (provider) (too good to be true ) and another company B (consumer) choose to do web service using SOAP over JMS.
    2. When A recieve SOAP Message from B, it can simply POST to another company C as it is (with or with additional SOAP Message manipulation)
    using either URL/Apache Client OR JAX-RPC/JAX-WS client API.

    Would URL or Apache Client not enough?
    This is like replacing the hard-coded SOAP message with a ready SOAP Message from JMS Queue.
    Duran Harris
    Ranch Hand

    Joined: Nov 09, 2008
    Posts: 598

    Think I will try to replace the Socket connection with a a call to javax.xml.ws.Dispatch.createDispatch
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Request web service through socket
     
    Similar Threads
    Design error in my app?
    web service vs HTTP session
    Web Services and AS400 RPG
    fix the sockets used by axis2 clients
    Webservice Responses