Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can you call a local WS without creating proxy classes?

 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic