GeeCON Prague 2014*
The moose likes Web Services and the fly likes Can you call a local WS without creating proxy classes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Can you call a local WS without creating proxy classes?" Watch "Can you call a local WS without creating proxy classes?" New topic
Author

Can you call a local WS without creating proxy classes?

Ong Vua
Ranch Hand

Joined: Jan 24, 2008
Posts: 59
I have a local secure web service on the application server running weblogic 10.3.2

Can I call it in my Java class without creating a WS proxy? If so how?

Thanks
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 462
    
    4
Server side:

1. define secured

a. basic auth
b. basic auth + https
c. WS-SECURITY
1. Confidential
2. Integrity
3. Authentication
4. Authorization

2. what kind of web service engine: JAX-WS or JAX-RPC?

Client side:

3. Without proxy class? YES until proven NO because
In theory, theory and practice are the same. In practice, they are not.




Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
It is possible to call a web service by assembling the requests at runtime using, for instance, SAAJ (see http://en.wikipedia.org/wiki/SAAJ for an explanation of SAAJ).
There should be nothing stopping you from calling a secured web service either, however I cannot elaborate on details since I do not know how the web service is secured.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Ong Vua
Ranch Hand

Joined: Jan 24, 2008
Posts: 59
Server Side:

1) basic auth + https (Right now, I just passed in username as weblogic and its password for authentication)
2) JAX-RPC

Client Side: I'm calling the WS from a java web application.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
SAAJ should do the trick for you if you do not want to generate client artifacts. It will enable communication with both JAX-WS and JAX-RPC web services.
For an example on how to use SAAJ, please take a look at section 5.7 in my book, which you can download for free here: http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287
Registration required to download, but that is also free.
Best wishes!
Ong Vua
Ranch Hand

Joined: Jan 24, 2008
Posts: 59
What do you think about this solution using HttpURLConnection class? All I want to do is to call a secure web service and pass it input parameters.

http://www.herongyang.com/Web-Services/Java-net-HttpURLConnection-Send-SOAP-Message.html
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 462
    
    4
Basic Auth+Https to send a SOAP message to JAXRPC web service

1. created a SOAP message using SAAJ (or with any thing)
2. used apache HTTPClient 4.x to send this SOAP message.
2.1 set up basic auth: username + password
2.2 set up SSL connection

So what you asked is doable until other better ways come along
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 462
    
    4
Another way without using SAAS is JAX-RPC's DII client

See http://www.ibm.com/developerworks/library/ws-tip-jaxwsrpc4/index.html
Listing 1. HelloWorld service's WSDL
Listing 2. JAX-RPC's DII client
then add
// set username/password for Basic Auth
// set SSL Connection for Https
 
GeeCON Prague 2014
 
subject: Can you call a local WS without creating proxy classes?