aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes RPC SOAP Client in Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "RPC SOAP Client in Javascript" Watch "RPC SOAP Client in Javascript" New topic
Author

RPC SOAP Client in Javascript

meetu arora
Greenhorn

Joined: Jun 17, 2009
Posts: 7
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Well you would have to use the XMLHttpRequest object to send the request to the server.

Eric
meetu arora
Greenhorn

Joined: Jun 17, 2009
Posts: 7
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Easiest thing to do is to make a request to a servlet that makes the soap request.

Eric
meetu arora
Greenhorn

Joined: Jun 17, 2009
Posts: 7
no i have to do in browser, cannot post data to server
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jun 17, 2009
Posts: 7
No, webservice is in a different domain.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RPC SOAP Client in Javascript