Use JavaScript to call a SOAP web service that requires authentication - javascript

Can I call a SOAP web service from JavaScript? The SOAP web service in question is a member of the Exchange Web Services platform. I have found the Exchange Web Services OSX Widget but that uses Curl to do the actual SOAP call. So I am wondering if there is a limitation in the JavaScript abilities to interface with SOAP using authentication.

Javascript isn't very good at web services because of the same origin policy which means you're only allowed to request resources from the same domain as the page you call from.
You could work around this by setting up a proxy on your server to hand the request off to elsewhere. The problem with this is you'd have to build the SOAP message yourself as I very much doubt anyone has ever bothered to write a js SOAP library due to the afore mentioned limitations.
Instead, I would pick your favourite server side SOAP library and expose an interface to be called via AJAX.

Related

What is a SOAP JavaScript proxy?

I would like to call a WSDL web service from JavaScript using https://github.com/doedje/jquery.soap.
When I use the above library, it run into CORS problems, and the documentation says if i install some kind of proxy I can override that problem. My question is what is a proxy and how does it work? My intention is to call Escapia (https://beta.escapia.com) using jQuery.
A proxy would reside on your server, the same server you serve your pages from.
jQuery would send a request to your proxy (e.g., your server). The proxy would make the request to the WSDL web service and pass it back to your jQuery. This avoids the cross-site issue.

Access the force.com REST API with a pure Javascript page

I want to develop a front-end in Javascript (possibly with one of the fancy frameworks around such as AngularJS) that consumes the REST API of my Salesforce org.
I don't want to embed my project in Salesforce technologies, so basically
no Visualforce pages
no Force.com Sites
I do want to write my own front-end on a separate server that just makes AJAX calls to the Salesforce back-end.
In addition, I want the application to be accessible for any user, even if he/she does not have a Salesforce account. So the AJAX calls should not require that the user logs in on Salesforce. I want anonymous users to be able to retrieve public data from my organization and create new entries when it is useful (in the case of a survey for instance).
Even though these requirements generate some security concerns, I can imagine that Salesforce takes care about the requests rate limits on their API endpoints and that it is possible to restrict the access to the API on a host name base (e.g., only requests with origin host my-trusted-domain.com should be allowed, send a 403-Forbidden otherwise). I would be surprised if SF does not provide such basic features.
How would you proceed? Is there a minimal Javascript code that works out-of-the-box on any domain without getting into troubles with CORS?
All REST API calls to Salesforce must be authenticated. If you want anonymous API access then you will need to proxy authenticated calls through a server (like on Heroku) that adds the auth token. Or you can use Heroku Connect to expose your Salesforce data to a Heroku app as a Postrgres database.
If you go the REST route then checkout the ForceServer and my CORS Proxy for Salesforce. Both are not setup out-of-the-box for the anonymous access you are looking for but could easily be tweaked to support that use case.
BTW: When allowing anonymous access to your Salesforce data through a proxy make sure you are dealing correctly with security and request limits.

Why XMPP client using strophe.js still working with out including flXHR.js?

I am using ejabberd as XMPP server,one of our project need to have a xmpp web client,for that i am referring Professional "XMPP Programming with JavaScript and jQuery" by jake moffitt i was going through chapter 3 hello world application ,here in order to make xmpp web client using strophe i have to include creating java script file such as strophe.js,flXHR.js,and strophe.flxhr.js
i have gone through example many time but failed to connect with the server,
when i checked bosh connection using localhost:5280/http-bind it is working fine!!!!!
with try and error when i try to connect with xmpp server with removing flXHR.js ,it magically got connected to xmpp server!!!!!
FLxhr.js is used for making cross domain call as per book" Flash has a strict security policy, but unlike JavaScript, it allows cross-domain
requests to be sent to domains that permit such requests."
If i bypass above FLxhr.js i have to use a proxies
i am using apache tomcat as web-app server ,i haven't setup any proxies and not included FLxhr.js file in my html page ,but still xmpp client is able to communicate with server!!
Can some one please explains me what is the reason behind this??
thanks in advance!!
It's likely that your XMPP server has CORS enabled, I know Openfire now supports this. With CORS, strophe.js is able to make a cross origin request without needing the workaround provided by flash(FLxhr.js), and also works without any server side redirects.
Cross-Origin Resource Sharing
Cross Domain AJAX for XMPP HTTP-Binding Made Easy
CORS Browser Support
If you want to quickly check to see if your XMPP server has CORS enabled, you should be able to locate a crossdomain.xml file hosted on the root of your server.
Example:
I connect Strophe to my XMPP server using the address http://192.168.0.26:7070/http-bind/.
Since I have CORS enabled, I can browse to http://192.168.0.26:7070/crossdomain.xml and the server will return an XML file.

Calling SOAP webwervice from a javascript

Is there any method of calling a SOAP Service with the URL :
http://localhost:8088/...TestService?wsdl
How can I invoke and get the values from the client using javascript?
Cheers!!
Thanks
You shouldnt call soap service directly from js because soap is not limited to http communication and there is no good support for soap in JavaScript.
It is better to use intermediate layer which is more capable in terms of soap communication. For example you can call from JavaScript your asp.net mvc application using ajax and then call soap service from asp.net mvc app using wcf. Instead of asp.net mvc you can use any other server side technology and soap communication library. JavaScript is good for ajax/json communication but not for soap.
JavaScript doesn't have a SOAP library out of the box, though you can google around and find them, The web services still need to be on the origin server.
Similar Question found
here

A JavaScript client for consuming Axis2 service

I have written a service using Axis2. Now I wish to consume it using a browser based client written in JavaScript.
There are several options when deploying an Axis2 service, ranging from the webservice style (ex: RPC), encoding, transport (tcp/http), handlers, attachments, WS-Security, etc. which makes it hard or impossible to implement a fully compliant Axis2 client.
I would strongly recommend you publish your services enabling the REST api and consume the services via REST. Here's the link to the docs: http://ws.apache.org/axis2/1_5/rest-ws.html
If you want to take the hard route and parse soap messages, I would recommend that you write your client using GWT and expose some services using GWT exporter

Categories