Last Updated: February 25, 2016
·
5.206K
· kerrishotts

Using SOAP in a PhoneGap App

Yeah, yeah, so using SOAP is generally not the preferred solution when working from Javascript. It's so much easier to handle data in JSON rather than in XML. But sometimes you can't avoid it.

To help, I've started a simple library that helps make our lives a little bit easier. It's nothing big yet, doesn't validate the data yet, and surely has lots of bugs. In other words: don't use it for production without understanding the potential glitches. If the data you are sending to the server is likely to have "<" or ">", be careful – the library will very likely barf. I'm sure there's things I haven't even started to consider.

Even so, it's a start, and it doesn't require any additional libraries. I can verify that it works from within PhoneGap (which was the main point), at least on WebKit browsers. Android 2.x may have a bug with the "content-length" header – in which case, just remove that line. I have no idea about WP7 or WP8. On iOS, it just works.

The gist is here, under an MIT license: https://gist.github.com/3786070

Feel free to fork, improve, use, etc. If you do find a bug or implement a fix, it'd be nice to share it back, but since it's under MIT, you're under no requirement to do so.