Git Product home page Git Product logo

angular-xmlrpc's Introduction

angular-xmlrpc

An AngularJS service which provides XML-RPC communication methods.

Installation

From NPM:

npm install angular-xmlrpc --save

From Bower:

bower install angular-xmlrpc

How to use it ?

First of all, add in you application a dependency :

angular.module('MyApp', ['xml-rpc']);

This is an AngularJS service, you can use it in your application as any other service.

angular.module('MyApp')
.factory('MyAwesomeService', ['xmlrpc', function(xmlrpc){
    return {
        myAwesomeFunction: function(){
            xmlrpc.callMethod(...)
        }
    }
}]);

In order to pass parameters, you have to wrap them in an array:

myAwesomeFunction: function(){
    xmlrpc.callMethod('cookies.giveMe', [params1, params2, ...])
}

Response from the server is automatically parsed from XML to a JS object, you can use it directly:

xmlrpc.callMethod('user.me', []).then(function(response){
    console.log(response); // { attr1:..., attr2:...}
})

Configuration

You can configure the hostName and pathName of your xmlrpc webservice. You can also define a callback for each http error you want:

angular.module('MyApp.controllers', [])
.controller('MyAwesomeController', function(xmlrpc) {
    xmlrpc.config({
        hostName:"...", // Default is empty
        pathName:"/...", // Default is /rpc2
        401:function(){
            console.log("You shall not pass !");
        },
        404:function(){
            console.log("Not the droids you're looking for");
        },
        500:function(){
            console.log("Something went wrong :(");
        }, ...
});

Types

XML-RPC stardard to JS:

  • base64
  • string
  • int
  • i8
  • i4
  • double
  • boolean
  • struct
  • array
  • datetime
  • datetime.iso8601

Rock on ! \m/

angular-xmlrpc's People

Contributors

jchakra avatar tympanix avatar xeader avatar schizoduckie avatar

Watchers

James Cloos avatar Jonathan Guacaran avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.