• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

RPC SOAP Client in Javascript

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I need to write a make a SOAP client call from javascript.
Here is the code that I need to write in javascript:

URL url = new URL (stringURL);
SOAPMappingRegistry smr = new SOAPMappingRegistry();
Call call = new Call();
call.setSOAPMappingRegistry(smr);
call.setTargetObjectURI("<>");
call.setMethodName(operacion);
call.setEncodingStyleURI(encodingStyleURI);
SOAPHTTPConnection hc = new SOAPHTTPConnection();

hc.setProxyPort(8080);

hc.setTimeout(Integer.parseInt(timeout));
call.setSOAPTransport(hc);

Vector params = new Vector();
params.addElement(new Parameter("", String.class, peticion, null));
call.setParams(params);
Response resp=null;
resp = call.invoke(url, "");

Can anyone help on this?


 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you would have to use the XMLHttpRequest object to send the request to the server.

Eric
 
meetu arora
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But normally, with XMLHttpRequest object, we have to send xml SOAP to Webservice

In my case, I am passing these parameters
call.setParams(params);

and also setting call.setTargetObjectURI("<>");

how do i set that.What would be the javascript equivalent of this?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Easiest thing to do is to make a request to a servlet that makes the soap request.

Eric
 
meetu arora
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no i have to do in browser, cannot post data to server
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically you need to use setRequestHeaders and build a strung version of an xml file to post to the server. If you search the net for soap, you are looking at stuff that is 5 to 6 years old. Basicallly no one does this

Just remember that you have to deal with the same origin policy so that webservice needs to be in the same domain.
 
meetu arora
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, webservice is in a different domain.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

meetu arora wrote:No, webservice is in a different domain.



JavaScript can not call the other domain because of the same origin policy. Modern day browsers can get around it if the site supports CORS. Still the best bet is to have something on your server make the call.

Eric
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic