Permalink
Browse files

Fixed connection to external SOAP service

  • Loading branch information...
1 parent f54b23c commit 73a8f72bd9c0561fba98af64c45d920456729bb0 federico committed Apr 23, 2013
Showing with 9 additions and 4 deletions.
  1. 0 .lein-repl-history
  2. +6 −4 src/clj_soap/core.clj
  3. +3 −0 test/clj_soap/test/core.clj
View
No changes.
View
@@ -95,15 +95,15 @@
(defmethod obj->soap-str :double [obj argtype] (str obj))
(defmethod obj->soap-str :string [obj argtype] (str obj))
(defmethod obj->soap-str :boolean [obj argtype] (str obj))
-(defmethod obj->soap-str :anyType [obj argtype] (str obj))
+(defmethod obj->soap-str :default [obj argtype] (str obj))
(defmulti soap-str->obj (fn [obj argtype] argtype))
(defmethod soap-str->obj :integer [soap-str argtype] (Integer/parseInt soap-str))
(defmethod soap-str->obj :double [soap-str argtype] (Double/parseDouble soap-str))
(defmethod soap-str->obj :string [soap-str argtype] soap-str)
(defmethod soap-str->obj :boolean [soap-str argtype] (Boolean/parseBoolean soap-str))
-(defmethod soap-str->obj :anyType [soap-str argtype] soap-str)
+(defmethod soap-str->obj :default [soap-str argtype] soap-str)
(defn make-client [url]
(doto (org.apache.axis2.client.ServiceClient. nil (java.net.URL. url) nil nil)
@@ -120,13 +120,15 @@
(doseq [[argval argtype] (map list args op-args)]
(.addChild request
(doto (.createOMElement
- factory (javax.xml.namespace.QName. (:name argtype)))
+ factory (javax.xml.namespace.QName. (axis-op-namespace op) (:name argtype)))
(.setText (obj->soap-str argval (:type argtype))))))
request))
(defn get-result [op retelem]
(let [ret-str (.getText (first (iterator-seq (.getChildElements retelem))))]
- (soap-str->obj ret-str (axis-op-rettype op))))
+ (if (not (empty? ret-str))
+ (soap-str->obj ret-str (axis-op-rettype op))
+ (str retelem))))
(defn client-call [client op & args]
(if (isa? (class op) org.apache.axis2.description.OutOnlyAxisOperation)
@@ -25,3 +25,6 @@
;(is (= "abcabc" (cl :doubl2 "abc")))
))
+;;;; Test for exteral SOAP service
+(let [client (client-fn "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL")]
+ (client :GetCityWeatherByZIP "16001"))

0 comments on commit 73a8f72

Please sign in to comment.