我正在尝试编写一个clojure应用程序来连接到SOAP端点并下载一些数据。我是clojure的新手,这个项目对我的语言技能水平有点雄心勃勃。我发现,学习曲线的一部分是解析clojure产生的错误信息。我有以下代码:
(require '[clj-soap.core :as soap])
(defn -main
"I don't do a whole lot ... yet."
[& args]
(let [client (soap/client-fn "https://sna.etapestry.com/v2messaging/service?WSDL")]
(client :login "username" "password") ;replaced with real credentials
(client :logout))
(println "Hello, World!"))
产生这个大量错误信息:
jonathan at tardis [11:47:19] ~/rc_import
[master] -> lein run
Exception in thread "main" org.apache.axis2.AxisFault: caught exception while handling request: unexpected encoding style: expected=http://schemas.xmlsoap.org/soap/encoding/, actual=, compiling:(/tmp/form-init3897130533799964700.clj:1:72)
at clojure.lang.Compiler.load(Compiler.java:7142)
at clojure.lang.Compiler.loadFile(Compiler.java:7086)
at clojure.main$load_script.invoke(main.clj:274)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invoke(main.clj:307)
at clojure.main$null_opt.invoke(main.clj:342)
at clojure.main$main.doInvoke(main.clj:420)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: org.apache.axis2.AxisFault: caught exception while handling request: unexpected encoding style: expected=http://schemas.xmlsoap.org/soap/encoding/, actual=
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:555)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at clj_soap.core$client_call.doInvoke(core.clj:150)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:628)
at clj_soap.core$client_proxy$iter__314__318$fn__319$soap_call__324.doInvoke(core.clj:156)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:624)
at clj_soap.core$client_fn$fn__335.doInvoke(core.clj:164)
at clojure.lang.RestFn.invoke(RestFn.java:439)
at rc_import.core$_main.doInvoke(core.clj:9)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.Var.invoke(Var.java:375)
at user$eval5.invoke(form-init3897130533799964700.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6693)
at clojure.lang.Compiler.load(Compiler.java:7130)
... 11 more
我的project.clj文件中的依赖项如下:
:dependencies [[org.clojure/clojure "1.6.0"]
[com.uswitch/clj-soap "0.2.3"]]
这些已正确安装并正确导入库。问题是错误消息说
Exception in thread "main" org.apache.axis2.AxisFault: caught exception while handling request: unexpected encoding style: expected=http://schemas.xmlsoap.org/soap/encoding/, actual= ...
这是什么意思?我如何解决它?我对端点xml文件没有任何控制权。
真正令人费解的是,我可以使用python和suds连接到同一个端点。我将继续使用python,但我需要该程序是跨平台和“白痴证明”。 JVM是跨平台的,特别是比python更容易移植到Windows,而且我可以写一个“白痴抗性”程序。