aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Fitzsimmons2016-03-16 11:03:31 -0400
committerThomas Fitzsimmons2016-03-16 11:03:31 -0400
commit6e3d1682eefd7a9e2ac0c707d48de7adec5ab0a3 (patch)
treeeb2e907568b77a20fdd5480d686c07bb2384dae3
parentb48197d8eda0d4fe221a128d862807d804e2ebf0 (diff)
downloademacs-6e3d1682eefd7a9e2ac0c707d48de7adec5ab0a3.tar.gz
emacs-6e3d1682eefd7a9e2ac0c707d48de7adec5ab0a3.zip
Sync with soap-client repository, version 3.1.1
* lisp/net/soap-client.el (soap-encode-xs-complex-type): Fix error message. (soap-find-port): Delete trailing whitespace. (soap-find-operation): Fix documentation and rename parameter. (soap-find-port): Likewise. (soap-operation-arity): Likewise. * lisp/net/soap-client.el: Update copyright years. (soap-warning): Fix docstring quoting. (soap-decode-date-time): Likewise. (soap-validate-xs-simple-type): Remove tabs for indentation. * lisp/net/soap-inspect.el: Update copyright years. * lisp/net/soap-client.el (soap-encode-xs-basic-type): Do not assume xsd:base64Binary values are UTF-8 strings. (soap-decode-xs-basic-type): Likewise. (soap-invoke): Document xsd:base64Binary handling. * lisp/net/soap-client.el (soap-find-port, soap-find-operation) (soap-operation-arity): new defuns (soap-invoke-internal): use soap-find-port, soap-find-operation. Co-authored-by: Alex Harsanyi <AlexHarsanyi@gmail.com>
-rw-r--r--lisp/net/soap-client.el132
1 files changed, 76 insertions, 56 deletions
diff --git a/lisp/net/soap-client.el b/lisp/net/soap-client.el
index 74024644966..f8973a3a537 100644
--- a/lisp/net/soap-client.el
+++ b/lisp/net/soap-client.el
@@ -5,7 +5,7 @@
5;; Author: Alexandru Harsanyi <AlexHarsanyi@gmail.com> 5;; Author: Alexandru Harsanyi <AlexHarsanyi@gmail.com>
6;; Author: Thomas Fitzsimmons <fitzsim@fitzsim.org> 6;; Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
7;; Created: December, 2009 7;; Created: December, 2009
8;; Version: 3.0.2 8;; Version: 3.1.1
9;; Keywords: soap, web-services, comm, hypermedia 9;; Keywords: soap, web-services, comm, hypermedia
10;; Package: soap-client 10;; Package: soap-client
11;; Homepage: https://github.com/alex-hhh/emacs-soap-client 11;; Homepage: https://github.com/alex-hhh/emacs-soap-client
@@ -538,7 +538,7 @@ This is a specialization of `soap-encode-value' for
538 (base64Binary 538 (base64Binary
539 (unless (stringp value) 539 (unless (stringp value)
540 (error "Not a string value for base64Binary")) 540 (error "Not a string value for base64Binary"))
541 (base64-encode-string (encode-coding-string value 'utf-8))) 541 (base64-encode-string value))
542 542
543 (otherwise 543 (otherwise
544 (error "Don't know how to encode %s for type %s" 544 (error "Don't know how to encode %s for type %s"
@@ -682,7 +682,7 @@ This is a specialization of `soap-decode-type' for
682 decimal byte float double duration) 682 decimal byte float double duration)
683 (string-to-number (car contents))) 683 (string-to-number (car contents)))
684 (boolean (string= (downcase (car contents)) "true")) 684 (boolean (string= (downcase (car contents)) "true"))
685 (base64Binary (decode-coding-string (base64-decode-string (car contents)) 'utf-8)) 685 (base64Binary (base64-decode-string (car contents)))
686 (anyType (soap-decode-any-type node)) 686 (anyType (soap-decode-any-type node))
687 (Array (soap-decode-array node)))))) 687 (Array (soap-decode-array node))))))
688 688
@@ -1249,8 +1249,8 @@ See also `soap-wsdl-resolve-references'."
1249 (when messages 1249 (when messages
1250 (error (mapconcat 'identity (nreverse messages) "; and: ")))) 1250 (error (mapconcat 'identity (nreverse messages) "; and: "))))
1251 (cl-labels ((fail-with-message (format value) 1251 (cl-labels ((fail-with-message (format value)
1252 (push (format format value) messages) 1252 (push (format format value) messages)
1253 (throw 'invalid nil))) 1253 (throw 'invalid nil)))
1254 (catch 'invalid 1254 (catch 'invalid
1255 (let ((enumeration (soap-xs-simple-type-enumeration type))) 1255 (let ((enumeration (soap-xs-simple-type-enumeration type)))
1256 (when (and (> (length enumeration) 1) 1256 (when (and (> (length enumeration) 1)
@@ -1630,7 +1630,7 @@ This is a specialization of `soap-encode-value' for
1630`soap-xs-complex-type' objects." 1630`soap-xs-complex-type' objects."
1631 (case (soap-xs-complex-type-indicator type) 1631 (case (soap-xs-complex-type-indicator type)
1632 (array 1632 (array
1633 (error "soap-encode-xs-complex-type arrays are handled elsewhere")) 1633 (error "Arrays of type soap-encode-xs-complex-type are handled elsewhere"))
1634 ((sequence choice all nil) 1634 ((sequence choice all nil)
1635 (let ((type-list (list type))) 1635 (let ((type-list (list type)))
1636 1636
@@ -2999,6 +2999,33 @@ http://schemas.xmlsoap.org/soap/encoding/\"\n"))
2999 :type 'boolean 2999 :type 'boolean
3000 :group 'soap-client) 3000 :group 'soap-client)
3001 3001
3002(defun soap-find-port (wsdl service)
3003 "Return the WSDL port having SERVICE name.
3004Signal an error if not found."
3005 (or (catch 'found
3006 (dolist (p (soap-wsdl-ports wsdl))
3007 (when (equal service (soap-element-name p))
3008 (throw 'found p))))
3009 (error "Unknown SOAP service: %s" service)))
3010
3011(defun soap-find-operation (port operation-name)
3012 "Inside PORT, find OPERATION-NAME, a `soap-port-type'.
3013Signal an error if not found."
3014 (let* ((binding (soap-port-binding port))
3015 (op (gethash operation-name (soap-binding-operations binding))))
3016 (or op
3017 (error "No operation %s for SOAP service %s"
3018 operation-name (soap-element-name port)))))
3019
3020(defun soap-operation-arity (wsdl service operation-name)
3021 "Return the number of arguments required by a soap operation.
3022WSDL, SERVICE, OPERATION-NAME and PARAMETERS are as described in
3023`soap-invoke'."
3024 (let* ((port (soap-find-port wsdl service))
3025 (op (soap-find-operation port operation-name))
3026 (bop (soap-bound-operation-operation op)))
3027 (length (soap-operation-parameter-order bop))))
3028
3002(defun soap-invoke-internal (callback cbargs wsdl service operation-name 3029(defun soap-invoke-internal (callback cbargs wsdl service operation-name
3003 &rest parameters) 3030 &rest parameters)
3004 "Implement `soap-invoke' and `soap-invoke-async'. 3031 "Implement `soap-invoke' and `soap-invoke-async'.
@@ -3006,54 +3033,43 @@ If CALLBACK is non-nil, operate asynchronously, then call CALLBACK as (apply
3006CALLBACK RESPONSE CBARGS), where RESPONSE is the SOAP invocation result. 3033CALLBACK RESPONSE CBARGS), where RESPONSE is the SOAP invocation result.
3007If CALLBACK is nil, operate synchronously. WSDL, SERVICE, 3034If CALLBACK is nil, operate synchronously. WSDL, SERVICE,
3008OPERATION-NAME and PARAMETERS are as described in `soap-invoke'." 3035OPERATION-NAME and PARAMETERS are as described in `soap-invoke'."
3009 (let ((port (catch 'found 3036 (let* ((port (soap-find-port wsdl service))
3010 (dolist (p (soap-wsdl-ports wsdl)) 3037 (operation (soap-find-operation port operation-name)))
3011 (when (equal service (soap-element-name p)) 3038 (let ((url-request-method "POST")
3012 (throw 'found p)))))) 3039 (url-package-name "soap-client.el")
3013 (unless port 3040 (url-package-version "1.0")
3014 (error "Unknown SOAP service: %s" service)) 3041 (url-request-data
3015 3042 ;; url-request-data expects a unibyte string already encoded...
3016 (let* ((binding (soap-port-binding port)) 3043 (encode-coding-string
3017 (operation (gethash operation-name 3044 (soap-create-envelope operation parameters wsdl
3018 (soap-binding-operations binding)))) 3045 (soap-port-service-url port))
3019 (unless operation 3046 'utf-8))
3020 (error "No operation %s for SOAP service %s" operation-name service)) 3047 (url-mime-charset-string "utf-8;q=1, iso-8859-1;q=0.5")
3021 3048 (url-http-attempt-keepalives t)
3022 (let ((url-request-method "POST") 3049 (url-request-extra-headers
3023 (url-package-name "soap-client.el") 3050 (list
3024 (url-package-version "1.0") 3051 (cons "SOAPAction"
3025 (url-request-data 3052 (concat "\"" (soap-bound-operation-soap-action
3026 ;; url-request-data expects a unibyte string already encoded... 3053 operation) "\""))
3027 (encode-coding-string 3054 (cons "Content-Type"
3028 (soap-create-envelope operation parameters wsdl 3055 "text/xml; charset=utf-8"))))
3029 (soap-port-service-url port)) 3056 (if callback
3030 'utf-8)) 3057 (url-retrieve
3031 (url-mime-charset-string "utf-8;q=1, iso-8859-1;q=0.5") 3058 (soap-port-service-url port)
3032 (url-http-attempt-keepalives t) 3059 (lambda (status)
3033 (url-request-extra-headers 3060 (let ((data-buffer (current-buffer)))
3034 (list 3061 (unwind-protect
3035 (cons "SOAPAction" 3062 (let ((error-status (plist-get status :error)))
3036 (concat "\"" (soap-bound-operation-soap-action 3063 (if error-status
3037 operation) "\"")) 3064 (signal (car error-status) (cdr error-status))
3038 (cons "Content-Type" 3065 (apply callback
3039 "text/xml; charset=utf-8")))) 3066 (soap-parse-envelope
3040 (if callback 3067 (soap-parse-server-response)
3041 (url-retrieve 3068 operation wsdl)
3042 (soap-port-service-url port) 3069 cbargs)))
3043 (lambda (status) 3070 ;; Ensure the url-retrieve buffer is not leaked.
3044 (let ((data-buffer (current-buffer))) 3071 (and (buffer-live-p data-buffer)
3045 (unwind-protect 3072 (kill-buffer data-buffer))))))
3046 (let ((error-status (plist-get status :error)))
3047 (if error-status
3048 (signal (car error-status) (cdr error-status))
3049 (apply callback
3050 (soap-parse-envelope
3051 (soap-parse-server-response)
3052 operation wsdl)
3053 cbargs)))
3054 ;; Ensure the url-retrieve buffer is not leaked.
3055 (and (buffer-live-p data-buffer)
3056 (kill-buffer data-buffer))))))
3057 (let ((buffer (url-retrieve-synchronously 3073 (let ((buffer (url-retrieve-synchronously
3058 (soap-port-service-url port)))) 3074 (soap-port-service-url port))))
3059 (condition-case err 3075 (condition-case err
@@ -3077,7 +3093,7 @@ OPERATION-NAME and PARAMETERS are as described in `soap-invoke'."
3077 (error 3093 (error
3078 (when soap-debug 3094 (when soap-debug
3079 (pop-to-buffer buffer)) 3095 (pop-to-buffer buffer))
3080 (error (error-message-string err)))))))))) 3096 (error (error-message-string err)))))))))
3081 3097
3082(defun soap-invoke (wsdl service operation-name &rest parameters) 3098(defun soap-invoke (wsdl service operation-name &rest parameters)
3083 "Invoke a SOAP operation and return the result. 3099 "Invoke a SOAP operation and return the result.
@@ -3096,7 +3112,11 @@ the SOAP request.
3096NOTE: The SOAP service provider should document the available 3112NOTE: The SOAP service provider should document the available
3097operations and their parameters for the service. You can also 3113operations and their parameters for the service. You can also
3098use the `soap-inspect' function to browse the available 3114use the `soap-inspect' function to browse the available
3099operations in a WSDL document." 3115operations in a WSDL document.
3116
3117NOTE: `soap-invoke' base64-decodes xsd:base64Binary return values
3118into unibyte strings; these byte-strings require further
3119interpretation by the caller."
3100 (apply #'soap-invoke-internal nil nil wsdl service operation-name parameters)) 3120 (apply #'soap-invoke-internal nil nil wsdl service operation-name parameters))
3101 3121
3102(defun soap-invoke-async (callback cbargs wsdl service operation-name 3122(defun soap-invoke-async (callback cbargs wsdl service operation-name