my dog learned polymorphism*
The moose likes Web Services and the fly likes Invoking JAX-WS method from browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Invoking JAX-WS method from browser" Watch "Invoking JAX-WS method from browser" New topic

Invoking JAX-WS method from browser

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Hi all
Is it possible to invoke from the browser Jax-Ws method who's signature is :

Thank you
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Additional info:
The Ws engine is CXF running on Tomcat (JAX-WS implementation)

Thank you!!!

Peer Reynders

Joined: Aug 19, 2005
Posts: 2906
The simple answer is No. (At least not if it is exposed as a SOAP web service)

SOAP web services were never designed to be directly accessed via a browser. There always has been the expectation that the client application would build a SOAP request and place that request inside of an HTTP request - browsers were never designed to do that, they simply issue HTTP requests.

That being said it is always possible to have browser-based client-side scripting (e.g. JavaScript) build that HTTP/SOAP Request, parse the HTTP/SOAP response and use the content to modify the browser document object model.

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Why not?
In order to invoke method with 2 params, one can write:

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 39548
Originally posted by Sharon whipple:
In order to invoke method with 2 params, one can write:

IF the WS is written in a RESTful style, and recognizes HTTP parameters. But as Peer said, in the general case -where a SOAP request is expected- this won't work.

Ping & DNS - updated with new look and Ping home screen widget
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12681
However, note that with JavaScript in the browser you can create a normal SOAP request in XML format and POST it to the service and get back the XML formatted response.

Really thats the basis for the whole AJAX thing so it is done all the time.


Java Resources at
Peer Reynders

Joined: Aug 19, 2005
Posts: 2906
Originally posted by Ulf Dittmer:
IF the WS is written in a RESTful style, and recognizes HTTP parameters.

Even that is debatable with the example given. In the Richardson/Ruby philosophy the HTTP parameters are part of the URI that names a linkable resource. Now that does work if a response is returned pretty snappily from the URI - even if it is sooooo RPC. However if a response can be so quickly "calculated" (rather than retrieved) then there must be some question whether this functionality actually classifies (in terms of granularity) as a service. A more general REST implementation might have you
  • POST the parameter data to and return a URI for your results (a new resource).
  • GET the result at (e.g.) You would then get a 204 ("No Content") code if processing wasn't yet complete or a 200 ("OK") with the result representation.

  • Also a RESTful web service may use the full range of HTTP methods including PUT and DELETE which aren't usually supported by browsers. So to support manipulation-by-browser a properly designed RESTful web service may have to support a URI kludge (HTTP method tunneling in the query string or entity body):
  • When the browser issues: POST /user/myusername/processname/results/12345678?_method=delete
  • The service interprets it as: DELETE /user/myusername/processname/results/12345678

  • The good news it that a RESTful web service can be designed to serve multiple representations of the same resource.
    A browser might request:

    and then get a nice human readable html page of the result. An application on the other hand could request:

    and an XML version of the same results is returned in the HTTP response.

    Properly designed RESTful web services use a broader range of HTTP protocol features than most browsers and for the time being the RESTful developer has to have a pretty good understanding of the HTTP protocol even more so than what would be expected of a competent web component developer (as web components serve their results only to browsers).

    If you are interested in implementing a RESTful web service then I would recommend that you set JAX-WS aside for the moment and that you have a look at Restlet.
    JAX-WS focuses primarily on SOAP web services - REST web services were only of secondary importance when JAX-WS was defined. So it wouldn't surprise me at all if it would be simpler to build a proper RESTful web service (along the lines of RESTful Web Services (amazon US)) with Restlet which is dedicated to implementing RESTful web services rather than JAX-WS.
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    subject: Invoking JAX-WS method from browser
    Similar Threads
    web service xml output
    JAX-WS endPoint implementation
    Check if web service is running
    SCDJWS 5 (310-230) Cleared
    Looking for a simple JAX-WS top down tutorial