aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus2011-02-16 20:33:35 +0100
committerMichael Albinus2011-02-16 20:33:35 +0100
commit88ae2870cbcd5d15729e1c53baa58eb037c2c99b (patch)
tree4f98f197c7691ddf78f18bee42bf80012724ac2e /lisp
parent026d69ecec7ec7cb19470779126041e065aea6b1 (diff)
downloademacs-88ae2870cbcd5d15729e1c53baa58eb037c2c99b.tar.gz
emacs-88ae2870cbcd5d15729e1c53baa58eb037c2c99b.zip
* net/soap-client.el: Add "comm" and "hypermedia" to the
keywords. Reflow too long lines. * net/soap-inspect.el: Ditto. Require 'cl.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/net/soap-client.el189
-rw-r--r--lisp/net/soap-inspect.el24
3 files changed, 139 insertions, 81 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ce58c47ad12..fa0820d23ac 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12011-02-16 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/soap-client.el: Add "comm" and "hypermedia" to the
4 keywords. Reflow too long lines.
5
6 * net/soap-inspect.el: Ditto. Require 'cl.
7
12011-02-16 Bastien Guerry <bzg@altern.org> 82011-02-16 Bastien Guerry <bzg@altern.org>
2 9
3 * play/doctor.el (doctor-mode): Bugfix: escape the "," character 10 * play/doctor.el (doctor-mode): Bugfix: escape the "," character
diff --git a/lisp/net/soap-client.el b/lisp/net/soap-client.el
index c43c17dc9ef..68067d69314 100644
--- a/lisp/net/soap-client.el
+++ b/lisp/net/soap-client.el
@@ -1,4 +1,4 @@
1;;;; soap.el -- Access SOAP web services from Emacs 1;;;; soap-client.el -- Access SOAP web services from Emacs
2 2
3;; Copyright (C) 2009-2011 Alex Harsanyi <AlexHarsanyi@gmail.com> 3;; Copyright (C) 2009-2011 Alex Harsanyi <AlexHarsanyi@gmail.com>
4 4
@@ -17,12 +17,12 @@
17 17
18;; Author: Alexandru Harsanyi (AlexHarsanyi@gmail.com) 18;; Author: Alexandru Harsanyi (AlexHarsanyi@gmail.com)
19;; Created: December, 2009 19;; Created: December, 2009
20;; Keywords: soap, web-services 20;; Keywords: soap, web-services, comm, hypermedia
21;; Homepage: http://code.google.com/p/emacs-soap-client 21;; Homepage: http://code.google.com/p/emacs-soap-client
22;; 22;;
23 23
24;;; Commentary: 24;;; Commentary:
25;; 25;;
26;; To use the SOAP client, you first need to load the WSDL document for the 26;; To use the SOAP client, you first need to load the WSDL document for the
27;; service you want to access, using `soap-load-wsdl-from-url'. A WSDL 27;; service you want to access, using `soap-load-wsdl-from-url'. A WSDL
28;; document describes the available operations of the SOAP service, how their 28;; document describes the available operations of the SOAP service, how their
@@ -157,14 +157,13 @@ namespace of LOCAL-NAME."
157 nil))) 157 nil)))
158 ;; if no namespace is defined, just return the unqualified name 158 ;; if no namespace is defined, just return the unqualified name
159 name))) 159 name)))
160 160
161 161
162(defun soap-l2fq (local-name &optional use-tns) 162(defun soap-l2fq (local-name &optional use-tns)
163 "Convert LOCAL-NAME into a fully qualified name. 163 "Convert LOCAL-NAME into a fully qualified name.
164A fully qualified name is a cons of the namespace name and the 164A fully qualified name is a cons of the namespace name and the
165name of the element itself. For example \"xsd:string\" is 165name of the element itself. For example \"xsd:string\" is
166converted to \(\"http://www.w3.org/2001/XMLSchema\" . \"string\" 166converted to \(\"http://www.w3.org/2001/XMLSchema\" . \"string\"\).
167\).
168 167
169The USE-TNS argument specifies what to do when LOCAL-NAME has no 168The USE-TNS argument specifies what to do when LOCAL-NAME has no
170namespace tag. If USE-TNS is non-nil, the `*soap-target-xmlns*' 169namespace tag. If USE-TNS is non-nil, the `*soap-target-xmlns*'
@@ -201,14 +200,15 @@ different namespace aliases for the same element."
201 (setq default-ns value)) 200 (setq default-ns value))
202 ((string-match "^xmlns:\\(.*\\)$" name) 201 ((string-match "^xmlns:\\(.*\\)$" name)
203 (push (cons (match-string 1 name) value) xmlns))))) 202 (push (cons (match-string 1 name) value) xmlns)))))
204 203
205 (let ((tns (assoc "tns" xmlns))) 204 (let ((tns (assoc "tns" xmlns)))
206 (cond ((and tns target-ns) 205 (cond ((and tns target-ns)
207 ;; If a tns alias is defined for this node, it must match the target 206 ;; If a tns alias is defined for this node, it must match
208 ;; namespace. 207 ;; the target namespace.
209 (unless (equal target-ns (cdr tns)) 208 (unless (equal target-ns (cdr tns))
210 (soap-warning "soap-extract-xmlns(%s): tns alias and targetNamespace mismatch" 209 (soap-warning
211 (xml-node-name node)))) 210 "soap-extract-xmlns(%s): tns alias and targetNamespace mismatch"
211 (xml-node-name node))))
212 ((and tns (not target-ns)) 212 ((and tns (not target-ns))
213 (setq target-ns (cdr tns))) 213 (setq target-ns (cdr tns)))
214 ((and (not tns) target-ns) 214 ((and (not tns) target-ns)
@@ -217,7 +217,7 @@ different namespace aliases for the same element."
217 ;; that we might override an existing tns alias in XMLNS-TABLE, 217 ;; that we might override an existing tns alias in XMLNS-TABLE,
218 ;; but that is intended. 218 ;; but that is intended.
219 (push (cons "tns" target-ns) xmlns)))) 219 (push (cons "tns" target-ns) xmlns))))
220 220
221 (list default-ns target-ns (append xmlns xmlns-table)))) 221 (list default-ns target-ns (append xmlns xmlns-table))))
222 222
223(defmacro soap-with-local-xmlns (node &rest body) 223(defmacro soap-with-local-xmlns (node &rest body)
@@ -248,7 +248,8 @@ namespace tag."
248 ;; We use `ignore-errors' here because we want to silently 248 ;; We use `ignore-errors' here because we want to silently
249 ;; skip nodes for which we cannot convert them to a 249 ;; skip nodes for which we cannot convert them to a
250 ;; well-known name. 250 ;; well-known name.
251 (eq (ignore-errors (soap-l2wk (xml-node-name c))) child-name))) 251 (eq (ignore-errors (soap-l2wk (xml-node-name c)))
252 child-name)))
252 (push c result))) 253 (push c result)))
253 (nreverse result))) 254 (nreverse result)))
254 255
@@ -346,7 +347,9 @@ binding) but the same name."
346 (throw 'found e))))) 347 (throw 'found e)))))
347 ((= (length elements) 1) (car elements)) 348 ((= (length elements) 1) (car elements))
348 ((> (length elements) 1) 349 ((> (length elements) 1)
349 (error "Soap-namespace-get(%s): multiple elements, discriminant needed" name)) 350 (error
351 "Soap-namespace-get(%s): multiple elements, discriminant needed"
352 name))
350 (t 353 (t
351 nil)))) 354 nil))))
352 355
@@ -389,7 +392,8 @@ binding) but the same name."
389(defstruct soap-bound-operation 392(defstruct soap-bound-operation
390 operation ; SOAP-OPERATION 393 operation ; SOAP-OPERATION
391 soap-action ; value for SOAPAction HTTP header 394 soap-action ; value for SOAPAction HTTP header
392 use ; 'literal or 'encoded, see http://www.w3.org/TR/wsdl#_soap:body 395 use ; 'literal or 'encoded, see
396 ; http://www.w3.org/TR/wsdl#_soap:body
393 ) 397 )
394 398
395(defstruct (soap-binding (:include soap-element)) 399(defstruct (soap-binding (:include soap-element))
@@ -412,7 +416,8 @@ binding) but the same name."
412 416
413(defun soap-default-soapenc-types () 417(defun soap-default-soapenc-types ()
414 "Return a namespace containing some of the SOAPEnc types." 418 "Return a namespace containing some of the SOAPEnc types."
415 (let ((ns (make-soap-namespace :name "http://schemas.xmlsoap.org/soap/encoding/"))) 419 (let ((ns (make-soap-namespace
420 :name "http://schemas.xmlsoap.org/soap/encoding/")))
416 (dolist (type '("string" "dateTime" "boolean" "long" "int" "float" 421 (dolist (type '("string" "dateTime" "boolean" "long" "int" "float"
417 "base64Binary" "anyType" "Array" "byte[]")) 422 "base64Binary" "anyType" "Array" "byte[]"))
418 (soap-namespace-put 423 (soap-namespace-put
@@ -425,7 +430,7 @@ binding) but the same name."
425 (or (soap-basic-type-p element) 430 (or (soap-basic-type-p element)
426 (soap-sequence-type-p element) 431 (soap-sequence-type-p element)
427 (soap-array-type-p element))) 432 (soap-array-type-p element)))
428 433
429 434
430;;;;; The WSDL document 435;;;;; The WSDL document
431 436
@@ -482,7 +487,7 @@ used to resolve the namespace alias."
482 487
483 (when use-local-alias-table 488 (when use-local-alias-table
484 (setq alias-table (append *soap-local-xmlns* alias-table))) 489 (setq alias-table (append *soap-local-xmlns* alias-table)))
485 490
486 (cond ((consp name) ; a fully qualified name, as returned by `soap-l2fq' 491 (cond ((consp name) ; a fully qualified name, as returned by `soap-l2fq'
487 (setq element-name (cdr name)) 492 (setq element-name (cdr name))
488 (when (symbolp element-name) 493 (when (symbolp element-name)
@@ -490,19 +495,21 @@ used to resolve the namespace alias."
490 (setq namespace (soap-wsdl-find-namespace (car name) wsdl)) 495 (setq namespace (soap-wsdl-find-namespace (car name) wsdl))
491 (unless namespace 496 (unless namespace
492 (error "Soap-wsdl-get(%s): unknown namespace: %s" name namespace))) 497 (error "Soap-wsdl-get(%s): unknown namespace: %s" name namespace)))
493 498
494 ((string-match "^\\(.*\\):\\(.*\\)$" name) 499 ((string-match "^\\(.*\\):\\(.*\\)$" name)
495 (setq element-name (match-string 2 name)) 500 (setq element-name (match-string 2 name))
496 501
497 (let* ((ns-alias (match-string 1 name)) 502 (let* ((ns-alias (match-string 1 name))
498 (ns-name (cdr (assoc ns-alias alias-table)))) 503 (ns-name (cdr (assoc ns-alias alias-table))))
499 (unless ns-name 504 (unless ns-name
500 (error "Soap-wsdl-get(%s): cannot find namespace alias %s" name ns-alias)) 505 (error "Soap-wsdl-get(%s): cannot find namespace alias %s"
501 506 name ns-alias))
507
502 (setq namespace (soap-wsdl-find-namespace ns-name wsdl)) 508 (setq namespace (soap-wsdl-find-namespace ns-name wsdl))
503 (unless namespace 509 (unless namespace
504 (error "Soap-wsdl-get(%s): unknown namespace %s, referenced by alias %s" 510 (error
505 name ns-name ns-alias)))) 511 "Soap-wsdl-get(%s): unknown namespace %s, referenced by alias %s"
512 name ns-name ns-alias))))
506 (t 513 (t
507 (error "Soap-wsdl-get(%s): bad name" name))) 514 (error "Soap-wsdl-get(%s): bad name" name)))
508 515
@@ -513,10 +520,10 @@ used to resolve the namespace alias."
513 (or (funcall 'soap-namespace-link-p e) 520 (or (funcall 'soap-namespace-link-p e)
514 (funcall predicate e))) 521 (funcall predicate e)))
515 nil))) 522 nil)))
516 523
517 (unless element 524 (unless element
518 (error "Soap-wsdl-get(%s): cannot find element" name)) 525 (error "Soap-wsdl-get(%s): cannot find element" name))
519 526
520 (if (soap-namespace-link-p element) 527 (if (soap-namespace-link-p element)
521 ;; NOTE: don't use the local alias table here 528 ;; NOTE: don't use the local alias table here
522 (soap-wsdl-get (soap-namespace-link-target element) wsdl predicate) 529 (soap-wsdl-get (soap-namespace-link-target element) wsdl predicate)
@@ -597,7 +604,8 @@ See also `soap-resolve-references-for-element' and
597 (setq name (format "in%d" (incf counter)))) 604 (setq name (format "in%d" (incf counter))))
598 (when (or (consp message) (stringp message)) 605 (when (or (consp message) (stringp message))
599 (setf (soap-operation-input operation) 606 (setf (soap-operation-input operation)
600 (cons (intern name) (soap-wsdl-get message wsdl 'soap-message-p)))))) 607 (cons (intern name)
608 (soap-wsdl-get message wsdl 'soap-message-p))))))
601 609
602 (let ((output (soap-operation-output operation)) 610 (let ((output (soap-operation-output operation))
603 (counter 0)) 611 (counter 0))
@@ -607,7 +615,8 @@ See also `soap-resolve-references-for-element' and
607 (setq name (format "out%d" (incf counter)))) 615 (setq name (format "out%d" (incf counter))))
608 (when (or (consp message) (stringp message)) 616 (when (or (consp message) (stringp message))
609 (setf (soap-operation-output operation) 617 (setf (soap-operation-output operation)
610 (cons (intern name) (soap-wsdl-get message wsdl 'soap-message-p)))))) 618 (cons (intern name)
619 (soap-wsdl-get message wsdl 'soap-message-p))))))
611 620
612 (let ((resolved-faults nil) 621 (let ((resolved-faults nil)
613 (counter 0)) 622 (counter 0))
@@ -617,7 +626,8 @@ See also `soap-resolve-references-for-element' and
617 (when (or (null name) (equal name "")) 626 (when (or (null name) (equal name ""))
618 (setq name (format "fault%d" (incf counter)))) 627 (setq name (format "fault%d" (incf counter))))
619 (if (or (consp message) (stringp message)) 628 (if (or (consp message) (stringp message))
620 (push (cons (intern name) (soap-wsdl-get message wsdl 'soap-message-p)) 629 (push (cons (intern name)
630 (soap-wsdl-get message wsdl 'soap-message-p))
621 resolved-faults) 631 resolved-faults)
622 (push fault resolved-faults)))) 632 (push fault resolved-faults))))
623 (setf (soap-operation-faults operation) resolved-faults)) 633 (setf (soap-operation-faults operation) resolved-faults))
@@ -626,7 +636,7 @@ See also `soap-resolve-references-for-element' and
626 (setf (soap-operation-parameter-order operation) 636 (setf (soap-operation-parameter-order operation)
627 (mapcar 'car (soap-message-parts 637 (mapcar 'car (soap-message-parts
628 (cdr (soap-operation-input operation)))))) 638 (cdr (soap-operation-input operation))))))
629 639
630 (setf (soap-operation-parameter-order operation) 640 (setf (soap-operation-parameter-order operation)
631 (mapcar (lambda (p) 641 (mapcar (lambda (p)
632 (if (stringp p) 642 (if (stringp p)
@@ -641,7 +651,8 @@ See also `soap-resolve-references-for-element' and
641 (when (or (consp (soap-binding-port-type binding)) 651 (when (or (consp (soap-binding-port-type binding))
642 (stringp (soap-binding-port-type binding))) 652 (stringp (soap-binding-port-type binding)))
643 (setf (soap-binding-port-type binding) 653 (setf (soap-binding-port-type binding)
644 (soap-wsdl-get (soap-binding-port-type binding) wsdl 'soap-port-type-p))) 654 (soap-wsdl-get (soap-binding-port-type binding)
655 wsdl 'soap-port-type-p)))
645 656
646 (let ((port-ops (soap-port-type-operations (soap-binding-port-type binding)))) 657 (let ((port-ops (soap-port-type-operations (soap-binding-port-type binding))))
647 (maphash (lambda (k v) 658 (maphash (lambda (k v)
@@ -801,7 +812,8 @@ calls."
801 (dolist (node (soap-xml-get-children1 node 'wsdl:portType)) 812 (dolist (node (soap-xml-get-children1 node 'wsdl:portType))
802 (let ((port-type (soap-parse-port-type node))) 813 (let ((port-type (soap-parse-port-type node)))
803 (soap-namespace-put port-type ns) 814 (soap-namespace-put port-type ns)
804 (soap-wsdl-add-namespace (soap-port-type-operations port-type) wsdl))) 815 (soap-wsdl-add-namespace
816 (soap-port-type-operations port-type) wsdl)))
805 817
806 (dolist (node (soap-xml-get-children1 node 'wsdl:binding)) 818 (dolist (node (soap-xml-get-children1 node 'wsdl:binding))
807 (soap-namespace-put (soap-parse-binding node) ns)) 819 (soap-namespace-put (soap-parse-binding node) ns))
@@ -810,10 +822,12 @@ calls."
810 (dolist (node (soap-xml-get-children1 node 'wsdl:port)) 822 (dolist (node (soap-xml-get-children1 node 'wsdl:port))
811 (let ((name (xml-get-attribute node 'name)) 823 (let ((name (xml-get-attribute node 'name))
812 (binding (xml-get-attribute node 'binding)) 824 (binding (xml-get-attribute node 'binding))
813 (url (let ((n (car (soap-xml-get-children1 node 'wsdlsoap:address)))) 825 (url (let ((n (car (soap-xml-get-children1
826 node 'wsdlsoap:address))))
814 (xml-get-attribute n 'location)))) 827 (xml-get-attribute n 'location))))
815 (let ((port (make-soap-port 828 (let ((port (make-soap-port
816 :name name :binding (soap-l2fq binding 'tns) :service-url url))) 829 :name name :binding (soap-l2fq binding 'tns)
830 :service-url url)))
817 (soap-namespace-put port ns) 831 (soap-namespace-put port ns)
818 (push port (soap-wsdl-ports wsdl)))))) 832 (push port (soap-wsdl-ports wsdl))))))
819 833
@@ -854,7 +868,8 @@ Return a SOAP-NAMESPACE containing the elements."
854 ;; construct the actual complex type for it. 868 ;; construct the actual complex type for it.
855 (let ((type-node (soap-xml-get-children1 node 'xsd:complexType))) 869 (let ((type-node (soap-xml-get-children1 node 'xsd:complexType)))
856 (when (> (length type-node) 0) 870 (when (> (length type-node) 0)
857 (assert (= (length type-node) 1)) ; only one complex type definition per element 871 (assert (= (length type-node) 1)) ; only one complex type
872 ; definition per element
858 (setq type (soap-parse-complex-type (car type-node))))) 873 (setq type (soap-parse-complex-type (car type-node)))))
859 (setf (soap-element-name type) name) 874 (setf (soap-element-name type) name)
860 type)) 875 type))
@@ -919,7 +934,8 @@ A list of these types is returned."
919 (setq type (soap-parse-complex-type (car type-node)))))) 934 (setq type (soap-parse-complex-type (car type-node))))))
920 935
921 (push (make-soap-sequence-element 936 (push (make-soap-sequence-element
922 :name (intern name) :type type :nillable? nillable? :multiple? multiple?) 937 :name (intern name) :type type :nillable? nillable?
938 :multiple? multiple?)
923 elements))) 939 elements)))
924 (nreverse elements))) 940 (nreverse elements)))
925 941
@@ -938,12 +954,14 @@ contents."
938 (soap-l2wk (xml-node-name node))) 954 (soap-l2wk (xml-node-name node)))
939 (let (array? parent elements) 955 (let (array? parent elements)
940 (let ((extension (car-safe (soap-xml-get-children1 node 'xsd:extension))) 956 (let ((extension (car-safe (soap-xml-get-children1 node 'xsd:extension)))
941 (restriction (car-safe (soap-xml-get-children1 node 'xsd:restriction)))) 957 (restriction (car-safe
958 (soap-xml-get-children1 node 'xsd:restriction))))
942 ;; a complex content node is either an extension or a restriction 959 ;; a complex content node is either an extension or a restriction
943 (cond (extension 960 (cond (extension
944 (setq parent (xml-get-attribute-or-nil extension 'base)) 961 (setq parent (xml-get-attribute-or-nil extension 'base))
945 (setq elements (soap-parse-sequence 962 (setq elements (soap-parse-sequence
946 (car (soap-xml-get-children1 extension 'xsd:sequence))))) 963 (car (soap-xml-get-children1
964 extension 'xsd:sequence)))))
947 (restriction 965 (restriction
948 (let ((base (xml-get-attribute-or-nil restriction 'base))) 966 (let ((base (xml-get-attribute-or-nil restriction 'base)))
949 (assert (equal base "soapenc:Array") 967 (assert (equal base "soapenc:Array")
@@ -951,8 +969,10 @@ contents."
951 "restrictions supported only for soapenc:Array types, this is a %s" 969 "restrictions supported only for soapenc:Array types, this is a %s"
952 base)) 970 base))
953 (setq array? t) 971 (setq array? t)
954 (let ((attribute (car (soap-xml-get-children1 restriction 'xsd:attribute)))) 972 (let ((attribute (car (soap-xml-get-children1
955 (let ((array-type (soap-xml-get-attribute-or-nil1 attribute 'wsdl:arrayType))) 973 restriction 'xsd:attribute))))
974 (let ((array-type (soap-xml-get-attribute-or-nil1
975 attribute 'wsdl:arrayType)))
956 (when (string-match "^\\(.*\\)\\[\\]$" array-type) 976 (when (string-match "^\\(.*\\)\\[\\]$" array-type)
957 (setq parent (match-string 1 array-type)))))) 977 (setq parent (match-string 1 array-type))))))
958 978
@@ -961,7 +981,7 @@ contents."
961 981
962 (if parent 982 (if parent
963 (setq parent (soap-l2fq parent 'tns))) 983 (setq parent (soap-l2fq parent 'tns)))
964 984
965 (if array? 985 (if array?
966 (make-soap-array-type :element-type parent) 986 (make-soap-array-type :element-type parent)
967 (make-soap-sequence-type :parent parent :elements elements)))) 987 (make-soap-sequence-type :parent parent :elements elements))))
@@ -999,11 +1019,13 @@ contents."
999 (dolist (node (soap-xml-get-children1 node 'wsdl:operation)) 1019 (dolist (node (soap-xml-get-children1 node 'wsdl:operation))
1000 (let ((o (soap-parse-operation node))) 1020 (let ((o (soap-parse-operation node)))
1001 1021
1002 (let ((other-operation (soap-namespace-get (soap-element-name o) ns 'soap-operation-p))) 1022 (let ((other-operation (soap-namespace-get
1023 (soap-element-name o) ns 'soap-operation-p)))
1003 (if other-operation 1024 (if other-operation
1004 ;; Unfortunately, the Confluence WSDL defines two operations 1025 ;; Unfortunately, the Confluence WSDL defines two operations
1005 ;; named "search" which differ only in parameter names... 1026 ;; named "search" which differ only in parameter names...
1006 (soap-warning "Discarding duplicate operation: %s" (soap-element-name o)) 1027 (soap-warning "Discarding duplicate operation: %s"
1028 (soap-element-name o))
1007 1029
1008 (progn 1030 (progn
1009 (soap-namespace-put o ns) 1031 (soap-namespace-put o ns)
@@ -1032,7 +1054,8 @@ contents."
1032 "soap-parse-operation: expecting wsdl:operation node, got %s" 1054 "soap-parse-operation: expecting wsdl:operation node, got %s"
1033 (soap-l2wk (xml-node-name node))) 1055 (soap-l2wk (xml-node-name node)))
1034 (let ((name (xml-get-attribute node 'name)) 1056 (let ((name (xml-get-attribute node 'name))
1035 (parameter-order (split-string (xml-get-attribute node 'parameterOrder))) 1057 (parameter-order (split-string
1058 (xml-get-attribute node 'parameterOrder)))
1036 input output faults) 1059 input output faults)
1037 (dolist (n (xml-node-children node)) 1060 (dolist (n (xml-node-children node))
1038 (when (consp n) ; skip string nodes which are whitespace 1061 (when (consp n) ; skip string nodes which are whitespace
@@ -1065,7 +1088,8 @@ contents."
1065 (soap-l2wk (xml-node-name node))) 1088 (soap-l2wk (xml-node-name node)))
1066 (let ((name (xml-get-attribute node 'name)) 1089 (let ((name (xml-get-attribute node 'name))
1067 (type (xml-get-attribute node 'type))) 1090 (type (xml-get-attribute node 'type)))
1068 (let ((binding (make-soap-binding :name name :port-type (soap-l2fq type 'tns)))) 1091 (let ((binding (make-soap-binding :name name
1092 :port-type (soap-l2fq type 'tns))))
1069 (dolist (wo (soap-xml-get-children1 node 'wsdl:operation)) 1093 (dolist (wo (soap-xml-get-children1 node 'wsdl:operation))
1070 (let ((name (xml-get-attribute wo 'name)) 1094 (let ((name (xml-get-attribute wo 'name))
1071 soap-action 1095 soap-action
@@ -1144,7 +1168,8 @@ decode function to perform the actual decoding."
1144 (if (equal (soap-xml-get-attribute-or-nil1 node 'xsi:nil) "true") 1168 (if (equal (soap-xml-get-attribute-or-nil1 node 'xsi:nil) "true")
1145 nil 1169 nil
1146 (let ((decoder (get (aref type 0) 'soap-decoder))) 1170 (let ((decoder (get (aref type 0) 'soap-decoder)))
1147 (assert decoder nil "no soap-decoder for %s type" (aref type 0)) 1171 (assert decoder nil "no soap-decoder for %s type"
1172 (aref type 0))
1148 (funcall decoder type node)))))))) 1173 (funcall decoder type node))))))))
1149 1174
1150(defun soap-decode-any-type (node) 1175(defun soap-decode-any-type (node)
@@ -1282,9 +1307,11 @@ WSDL is used to decode the NODE"
1282 1307
1283 (let ((fault (car (soap-xml-get-children1 body 'soap:Fault)))) 1308 (let ((fault (car (soap-xml-get-children1 body 'soap:Fault))))
1284 (when fault 1309 (when fault
1285 (let ((fault-code (let ((n (car (xml-get-children fault 'faultcode)))) 1310 (let ((fault-code (let ((n (car (xml-get-children
1311 fault 'faultcode))))
1286 (car-safe (xml-node-children n)))) 1312 (car-safe (xml-node-children n))))
1287 (fault-string (let ((n (car (xml-get-children fault 'faultstring)))) 1313 (fault-string (let ((n (car (xml-get-children
1314 fault 'faultstring))))
1288 (car-safe (xml-node-children n))))) 1315 (car-safe (xml-node-children n)))))
1289 (while t 1316 (while t
1290 (signal 'soap-error (list fault-code fault-string)))))) 1317 (signal 'soap-error (list fault-code fault-string))))))
@@ -1319,7 +1346,8 @@ reference multiRef parts which are external to RESPONSE-NODE."
1319 1346
1320 (when (eq use 'encoded) 1347 (when (eq use 'encoded)
1321 (let* ((received-message-name (soap-l2fq (xml-node-name response-node))) 1348 (let* ((received-message-name (soap-l2fq (xml-node-name response-node)))
1322 (received-message (soap-wsdl-get received-message-name wsdl 'soap-message-p))) 1349 (received-message (soap-wsdl-get
1350 received-message-name wsdl 'soap-message-p)))
1323 (unless (eq received-message message) 1351 (unless (eq received-message message)
1324 (error "Unexpected message: got %s, expecting %s" 1352 (error "Unexpected message: got %s, expecting %s"
1325 received-message-name 1353 received-message-name
@@ -1342,12 +1370,15 @@ reference multiRef parts which are external to RESPONSE-NODE."
1342 ((eq use 'literal) 1370 ((eq use 'literal)
1343 (catch 'found 1371 (catch 'found
1344 (let* ((ns-aliases (soap-wsdl-alias-table wsdl)) 1372 (let* ((ns-aliases (soap-wsdl-alias-table wsdl))
1345 (ns-name (cdr (assoc (soap-element-namespace-tag type) ns-aliases))) 1373 (ns-name (cdr (assoc
1374 (soap-element-namespace-tag type)
1375 ns-aliases)))
1346 (fqname (cons ns-name (soap-element-name type)))) 1376 (fqname (cons ns-name (soap-element-name type))))
1347 (dolist (c (xml-node-children response-node)) 1377 (dolist (c (xml-node-children response-node))
1348 (when (consp c) 1378 (when (consp c)
1349 (soap-with-local-xmlns c 1379 (soap-with-local-xmlns c
1350 (when (equal (soap-l2fq (xml-node-name c)) fqname) 1380 (when (equal (soap-l2fq (xml-node-name c))
1381 fqname)
1351 (throw 'found c)))))))))) 1382 (throw 'found c))))))))))
1352 1383
1353 (unless node 1384 (unless node
@@ -1402,8 +1433,9 @@ instead."
1402 ((memq value '(t nil)) 1433 ((memq value '(t nil))
1403 (setq xsi-type "xsd:boolean" basic-type 'boolean)) 1434 (setq xsi-type "xsd:boolean" basic-type 'boolean))
1404 (t 1435 (t
1405 (error "Soap-encode-basic-type(%s, %s, %s): cannot classify anyType value" 1436 (error
1406 xml-tag value xsi-type)))) 1437 "Soap-encode-basic-type(%s, %s, %s): cannot classify anyType value"
1438 xml-tag value xsi-type))))
1407 1439
1408 (insert "<" xml-tag " xsi:type=\"" xsi-type "\"") 1440 (insert "<" xml-tag " xsi:type=\"" xsi-type "\"")
1409 1441
@@ -1425,13 +1457,15 @@ instead."
1425 (>= (length value) 2) 1457 (>= (length value) 2)
1426 (numberp (nth 0 value)) 1458 (numberp (nth 0 value))
1427 (numberp (nth 1 value))) 1459 (numberp (nth 1 value)))
1428 ;; Value is a (current-time) style value, convert to a string 1460 ;; Value is a (current-time) style value, convert
1461 ;; to a string
1429 (insert (format-time-string "%Y-%m-%dT%H:%M:%S" value))) 1462 (insert (format-time-string "%Y-%m-%dT%H:%M:%S" value)))
1430 ((stringp value) 1463 ((stringp value)
1431 (insert (url-insert-entities-in-string value))) 1464 (insert (url-insert-entities-in-string value)))
1432 (t 1465 (t
1433 (error "Soap-encode-basic-type(%s, %s, %s): not a dateTime value" 1466 (error
1434 xml-tag value xsi-type)))) 1467 "Soap-encode-basic-type(%s, %s, %s): not a dateTime value"
1468 xml-tag value xsi-type))))
1435 1469
1436 (boolean 1470 (boolean
1437 (unless (memq value '(t nil)) 1471 (unless (memq value '(t nil))
@@ -1444,7 +1478,7 @@ instead."
1444 (error "Soap-encode-basic-type(%s, %s, %s): not an integer value" 1478 (error "Soap-encode-basic-type(%s, %s, %s): not an integer value"
1445 xml-tag value xsi-type)) 1479 xml-tag value xsi-type))
1446 (insert (number-to-string value))) 1480 (insert (number-to-string value)))
1447 1481
1448 (base64Binary 1482 (base64Binary
1449 (unless (stringp value) 1483 (unless (stringp value)
1450 (error "Soap-encode-basic-type(%s, %s, %s): not a string value" 1484 (error "Soap-encode-basic-type(%s, %s, %s): not a string value"
@@ -1452,9 +1486,10 @@ instead."
1452 (insert (base64-encode-string value))) 1486 (insert (base64-encode-string value)))
1453 1487
1454 (otherwise 1488 (otherwise
1455 (error "Soap-encode-basic-type(%s, %s, %s): don't know how to encode" 1489 (error
1456 xml-tag value xsi-type)))) 1490 "Soap-encode-basic-type(%s, %s, %s): don't know how to encode"
1457 1491 xml-tag value xsi-type))))
1492
1458 (insert " xsi:nil=\"true\">")) 1493 (insert " xsi:nil=\"true\">"))
1459 (insert "</" xml-tag ">\n"))) 1494 (insert "</" xml-tag ">\n")))
1460 1495
@@ -1487,12 +1522,14 @@ instead."
1487 ;; Do some sanity checking 1522 ;; Do some sanity checking
1488 (cond ((and (= instance-count 0) 1523 (cond ((and (= instance-count 0)
1489 (not (soap-sequence-element-nillable? element))) 1524 (not (soap-sequence-element-nillable? element)))
1490 (soap-warning "While encoding %s: missing non-nillable slot %s" 1525 (soap-warning
1491 (soap-element-name type) e-name)) 1526 "While encoding %s: missing non-nillable slot %s"
1527 (soap-element-name type) e-name))
1492 ((and (> instance-count 1) 1528 ((and (> instance-count 1)
1493 (not (soap-sequence-element-multiple? element))) 1529 (not (soap-sequence-element-multiple? element)))
1494 (soap-warning "While encoding %s: multiple slots named %s" 1530 (soap-warning
1495 (soap-element-name type) e-name)))))))) 1531 "While encoding %s: multiple slots named %s"
1532 (soap-element-name type) e-name))))))))
1496 (insert " xsi:nil=\"true\">")) 1533 (insert " xsi:nil=\"true\">"))
1497 (insert "</" xml-tag ">\n"))) 1534 (insert "</" xml-tag ">\n")))
1498 1535
@@ -1563,7 +1600,8 @@ document."
1563 (goto-char start-pos) 1600 (goto-char start-pos)
1564 (when (re-search-forward " ") 1601 (when (re-search-forward " ")
1565 (let* ((ns (soap-element-namespace-tag type)) 1602 (let* ((ns (soap-element-namespace-tag type))
1566 (namespace (cdr (assoc ns (soap-wsdl-alias-table wsdl))))) 1603 (namespace (cdr (assoc ns
1604 (soap-wsdl-alias-table wsdl)))))
1567 (when namespace 1605 (when namespace
1568 (insert "xmlns=\"" namespace "\" "))))))))) 1606 (insert "xmlns=\"" namespace "\" ")))))))))
1569 1607
@@ -1632,7 +1670,8 @@ operations in a WSDL document."
1632 (error "Unknown SOAP service: %s" service)) 1670 (error "Unknown SOAP service: %s" service))
1633 1671
1634 (let* ((binding (soap-port-binding port)) 1672 (let* ((binding (soap-port-binding port))
1635 (operation (gethash operation-name (soap-binding-operations binding)))) 1673 (operation (gethash operation-name
1674 (soap-binding-operations binding))))
1636 (unless operation 1675 (unless operation
1637 (error "No operation %s for SOAP service %s" operation-name service)) 1676 (error "No operation %s for SOAP service %s" operation-name service))
1638 1677
@@ -1645,9 +1684,13 @@ operations in a WSDL document."
1645 (url-request-coding-system 'utf-8) 1684 (url-request-coding-system 'utf-8)
1646 (url-http-attempt-keepalives t) 1685 (url-http-attempt-keepalives t)
1647 (url-request-extra-headers (list 1686 (url-request-extra-headers (list
1648 (cons "SOAPAction" (soap-bound-operation-soap-action operation)) 1687 (cons "SOAPAction"
1649 (cons "Content-Type" "text/xml; charset=utf-8")))) 1688 (soap-bound-operation-soap-action
1650 (let ((buffer (url-retrieve-synchronously (soap-port-service-url port)))) 1689 operation))
1690 (cons "Content-Type"
1691 "text/xml; charset=utf-8"))))
1692 (let ((buffer (url-retrieve-synchronously
1693 (soap-port-service-url port))))
1651 (condition-case err 1694 (condition-case err
1652 (with-current-buffer buffer 1695 (with-current-buffer buffer
1653 (declare (special url-http-response-status)) 1696 (declare (special url-http-response-status))
@@ -1657,9 +1700,12 @@ operations in a WSDL document."
1657 ;; This is a warning because some SOAP errors come 1700 ;; This is a warning because some SOAP errors come
1658 ;; back with a HTTP response 500 (internal server 1701 ;; back with a HTTP response 500 (internal server
1659 ;; error) 1702 ;; error)
1660 (warn "Error in SOAP response: HTTP code %s" url-http-response-status)) 1703 (warn "Error in SOAP response: HTTP code %s"
1704 url-http-response-status))
1661 (when (> (buffer-size) 1000000) 1705 (when (> (buffer-size) 1000000)
1662 (soap-warning "Received large message: %s bytes" (buffer-size))) 1706 (soap-warning
1707 "Received large message: %s bytes"
1708 (buffer-size)))
1663 (let ((mime-part (mm-dissect-buffer t t))) 1709 (let ((mime-part (mm-dissect-buffer t t)))
1664 (unless mime-part 1710 (unless mime-part
1665 (error "Failed to decode response from server")) 1711 (error "Failed to decode response from server"))
@@ -1667,7 +1713,8 @@ operations in a WSDL document."
1667 (error "Server response is not an XML document")) 1713 (error "Server response is not an XML document"))
1668 (with-temp-buffer 1714 (with-temp-buffer
1669 (mm-insert-part mime-part) 1715 (mm-insert-part mime-part)
1670 (let ((response (car (xml-parse-region (point-min) (point-max))))) 1716 (let ((response (car (xml-parse-region
1717 (point-min) (point-max)))))
1671 (prog1 1718 (prog1
1672 (soap-parse-envelope response operation wsdl) 1719 (soap-parse-envelope response operation wsdl)
1673 (kill-buffer buffer) 1720 (kill-buffer buffer)
diff --git a/lisp/net/soap-inspect.el b/lisp/net/soap-inspect.el
index 4ea6bef0d8c..163ba13b05b 100644
--- a/lisp/net/soap-inspect.el
+++ b/lisp/net/soap-inspect.el
@@ -17,12 +17,12 @@
17 17
18;; Author: Alexandru Harsanyi (AlexHarsanyi@gmail.com) 18;; Author: Alexandru Harsanyi (AlexHarsanyi@gmail.com)
19;; Created: October 2010 19;; Created: October 2010
20;; Keywords: soap, web-services 20;; Keywords: soap, web-services, comm, hypermedia
21;; Homepage: http://code.google.com/p/emacs-soap-client 21;; Homepage: http://code.google.com/p/emacs-soap-client
22;; 22;;
23 23
24;;; Commentary: 24;;; Commentary:
25;; 25;;
26;; This package provides an inspector for a WSDL document loaded with 26;; This package provides an inspector for a WSDL document loaded with
27;; `soap-load-wsdl' or `soap-load-wsdl-from-url'. To use it, evaluate: 27;; `soap-load-wsdl' or `soap-load-wsdl-from-url'. To use it, evaluate:
28;; 28;;
@@ -32,11 +32,13 @@
32;; and types to explore the structure of the wsdl document. 32;; and types to explore the structure of the wsdl document.
33;; 33;;
34 34
35(require 'soap-client)
36
37 35
38;;; Code: 36;;; Code:
39 37
38(eval-when-compile (require 'cl))
39
40(require 'soap-client)
41
40;;; sample-value 42;;; sample-value
41 43
42(defun soap-sample-value (type) 44(defun soap-sample-value (type)
@@ -148,12 +150,12 @@ entire WSDL can be inspected."
148 (setq buffer-read-only t) 150 (setq buffer-read-only t)
149 (let ((inhibit-read-only t)) 151 (let ((inhibit-read-only t))
150 (erase-buffer) 152 (erase-buffer)
151 153
152 (when soap-inspect-current-item 154 (when soap-inspect-current-item
153 (push soap-inspect-current-item 155 (push soap-inspect-current-item
154 soap-inspect-previous-items)) 156 soap-inspect-previous-items))
155 (setq soap-inspect-current-item element) 157 (setq soap-inspect-current-item element)
156 158
157 (funcall inspect element) 159 (funcall inspect element)
158 160
159 (unless (null soap-inspect-previous-items) 161 (unless (null soap-inspect-previous-items)
@@ -252,11 +254,13 @@ entire WSDL can be inspected."
252 (insert "\tOutput: " (symbol-name (car output)) " (") 254 (insert "\tOutput: " (symbol-name (car output)) " (")
253 (soap-insert-describe-button (cdr output)) 255 (soap-insert-describe-button (cdr output))
254 (insert ")\n")) 256 (insert ")\n"))
255 257
256 (insert "\n\nSample invocation:\n") 258 (insert "\n\nSample invocation:\n")
257 (let ((sample-message-value (soap-sample-value (cdr (soap-operation-input operation)))) 259 (let ((sample-message-value
260 (soap-sample-value (cdr (soap-operation-input operation))))
258 (funcall (list 'soap-invoke '*WSDL* "SomeService" (soap-element-name operation)))) 261 (funcall (list 'soap-invoke '*WSDL* "SomeService" (soap-element-name operation))))
259 (let ((sample-invocation (append funcall (mapcar 'cdr sample-message-value)))) 262 (let ((sample-invocation
263 (append funcall (mapcar 'cdr sample-message-value))))
260 (pp sample-invocation (current-buffer))))) 264 (pp sample-invocation (current-buffer)))))
261 265
262(defun soap-inspect-port-type (port-type) 266(defun soap-inspect-port-type (port-type)
@@ -335,7 +339,7 @@ entire WSDL can be inspected."
335 'soap-inspect-message) 339 'soap-inspect-message)
336 (put (aref (make-soap-operation) 0) 'soap-inspect 340 (put (aref (make-soap-operation) 0) 'soap-inspect
337 'soap-inspect-operation) 341 'soap-inspect-operation)
338 342
339 (put (aref (make-soap-port-type) 0) 'soap-inspect 343 (put (aref (make-soap-port-type) 0) 'soap-inspect
340 'soap-inspect-port-type) 344 'soap-inspect-port-type)
341 345