This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RPC SOAP Client in Javascript

 
meetu arora
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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?


 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
no i have to do in browser, cannot post data to server
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
No, webservice is in a different domain.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic