GithubHelp home page GithubHelp logo

dedaloes / clj-soap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zeto-ltd/clj-soap

0.0 2.0 0.0 26 KB

Clojure library for SOAP clients and servers

License: Eclipse Public License 1.0

Clojure 100.00%

clj-soap's Introduction

clj-soap

clj-soap is a SOAP server and client using Apache Axis2.

This version is based on Sean Corfield's version, which is in turn based on Tetsuya Takatsuru's version. It includes patches from a range of forks to add new features, options and bug fixes. Shout out to contributors for the @jaimeagudo, @uswitch, @j1mr10rd4n, @scttnlsn, @jpmonettas, @rentpath forks.

Usage

Client

You can call remote SOAP method as following:

(require '[clj-soap.client :as soap])

(let [client (soap/client-fn {:wsdl "http://... (URL for WSDL)"})]
  (client :someMethod param1 param2 ...))

The response is a Clojure object representation of the response XML.

Optional configuration data can be passed into the client-fn function:

(let [client (soap/client-fn {:wsdl "http://... (URL for WSDL)"
                              :options {; enables authentication for retrieving the WSDL
                                        ; NB: because of Axis2 internals, this must change
                                        ; the JVM-wide Authenticator default, so be careful!
                                        :wsdl-auth {:username "test"
                                                    :password "test"}
                                        ; enables authentication for all requests
                                        :auth {:username "test"
                                               :password "test"}
                                        ; specify timeout for accessing requests
                                        :timeout 10000
                                        ; enables chunked transfer for requests
                                        :chunked? true
                                        ; by default, SOAP failures result in exceptions
                                        ; setting this value to false makes failures result in standard responses
                                        :throw-faults false}})]
  (client :someMethod param1 param2 ...))

In certain situations, Axis2 doesn't detect complex arguments. To workaround this, complex arguments can be manually specified:

(let [client (soap/client-fn {:wsdl "http://... (URL for WSDL)"
                              :options {:complex-args true}})]
  (client :someMethod [["item" "test1"] ["item" "test2"]]))

Server

To make SOAP service:

(require '[clj-soap.server :as soap])

;; Defining service class
(soap/defservice my.some.SoapClass
  (someMethod ^String [^Integer x ^String s]
              (str "x is " x "\ts is " s)))

;; Start SOAP Service
(serve "my.some.SoapClass")

defservice needs to be AOT-compiled. For example, lein compile before running server.

Type Hint

SOAP services need typehints. String for arguments and void for return value, if you don't specify typehints.

License

Copyright (C) 2011 Tetsuya Takatsuru

Distributed under the Eclipse Public License, the same as Clojure.

clj-soap's People

Contributors

fvides avatar sbreatnach avatar seancorfield avatar yogthos avatar

Watchers

 avatar  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.