That is so cool. Would you believe that I wrote a JSP page that used the
Commons HttpClient library to do just what you showed in javascript?! We
too use it for demo/test purposes, where we have an option of showing
the raw XML or using just Axis and showing an HTML format populated with
the resulting business objects.

This one will definately go into my toolkit.

Thanks,
Robert

>>> [EMAIL PROTECTED] 06/02/03 09:11AM >>>
Alexandru Simion wrote:
> Hi ,
> 
>    Can, anyone, tell me if it is possible to invoke an axis web
service 
> from a browser ?
> And, if yes,  what is the procedure to do that ?

If you have a recent browser (Moz or IE 6, anyway) supporting XMLHTTP
calls,
then there's no problem doing it in Javascript. You get your uri,
soapAction,
and envelope (as a string), say for an amazon keyword search request
you'd have
    "http://soap.amazon.com/onca/soap";,
    "KeywordSearchRequest",
    doAmazonKeywordSearchEnvelope(token,keyword)
where "token" is your Amazon token and "keyword" is what you're
searching for;
then you go like so:

     var inIE = document.all != null;
     var xmlhttp=null;
     if(inIE) xmlhttp=new ActiveXObject('MSXML2.XMLHTTP');
     else xmlhttp=new XMLHttpRequest();
     if(!xmlhttp)
       return alert("can't initialize xmlhttp object");
     if(!inIE)
       netscape.security.PrivilegeManager.
         enablePrivilege("UniversalBrowserRead");
     xmlhttp.open('POST',uri,false);
     xmlhttp.setRequestHeader("SOAPAction", soapAction)
     xmlhttp.setRequestHeader("Content-Type", "text/xml;
charset=utf-8")
     xmlhttp.send(envelope);
     var result=xmlhttp.responseXML;

and there you've got it. Mozilla also lets you work at a higher level,
but
this code does work on both, and an axis service should be no problem
as
long as you can figure out the envelope. (If necessary, use a Java
client
and then use tcpmon or whatever to see what's actually being passed,
then
imitate in Javascript. Crude, but you end up with a light-weight
client.)
(Comments appreciated)

Tom Myers


Reply via email to