- (let ((port (catch 'found
- (dolist (p (soap-wsdl-ports wsdl))
- (when (equal service (soap-element-name p))
- (throw 'found p))))))
- (unless port
- (error "Unknown SOAP service: %s" service))
-
- (let* ((binding (soap-port-binding port))
- (operation (gethash operation-name
- (soap-binding-operations binding))))
- (unless operation
- (error "No operation %s for SOAP service %s" operation-name service))
-
- (let ((url-request-method "POST")
- (url-package-name "soap-client.el")
- (url-package-version "1.0")
- (url-request-data
- ;; url-request-data expects a unibyte string already encoded...
- (encode-coding-string
- (soap-create-envelope operation parameters wsdl
- (soap-port-service-url port))
- 'utf-8))
- (url-mime-charset-string "utf-8;q=1, iso-8859-1;q=0.5")
- (url-http-attempt-keepalives t)
- (url-request-extra-headers
- (list
- (cons "SOAPAction"
- (concat "\"" (soap-bound-operation-soap-action
- operation) "\""))
- (cons "Content-Type"
- "text/xml; charset=utf-8"))))
- (if callback
- (url-retrieve
- (soap-port-service-url port)
- (lambda (status)
- (let ((data-buffer (current-buffer)))
- (unwind-protect
- (let ((error-status (plist-get status :error)))
- (if error-status
- (signal (car error-status) (cdr error-status))
- (apply callback
- (soap-parse-envelope
- (soap-parse-server-response)
- operation wsdl)
- cbargs)))
- ;; Ensure the url-retrieve buffer is not leaked.
- (and (buffer-live-p data-buffer)
- (kill-buffer data-buffer))))))
+ (let* ((port (soap-find-port wsdl service))
+ (operation (soap-find-operation port operation-name)))
+ (let ((url-request-method "POST")
+ (url-package-name "soap-client.el")
+ (url-package-version "1.0")
+ (url-request-data
+ ;; url-request-data expects a unibyte string already encoded...
+ (encode-coding-string
+ (soap-create-envelope operation parameters wsdl
+ (soap-port-service-url port))
+ 'utf-8))
+ (url-mime-charset-string "utf-8;q=1, iso-8859-1;q=0.5")
+ (url-http-attempt-keepalives t)
+ (url-request-extra-headers
+ (list
+ (cons "SOAPAction"
+ (concat "\"" (soap-bound-operation-soap-action
+ operation) "\""))
+ (cons "Content-Type"
+ "text/xml; charset=utf-8"))))
+ (if callback
+ (url-retrieve
+ (soap-port-service-url port)
+ (lambda (status)
+ (let ((data-buffer (current-buffer)))
+ (unwind-protect
+ (let ((error-status (plist-get status :error)))
+ (if error-status
+ (signal (car error-status) (cdr error-status))
+ (apply callback
+ (soap-parse-envelope
+ (soap-parse-server-response)
+ operation wsdl)
+ cbargs)))
+ ;; Ensure the url-retrieve buffer is not leaked.
+ (and (buffer-live-p data-buffer)
+ (kill-buffer data-buffer))))))