更新时间:2022-02-12 18:07:29
我终于想出了一个解决方案:groovy-wslight 实际上解决了我的问题,并且最终能够轻松部署并毫无问题地访问 Web 服务.
I finally came up with a solution: groovy-wslight actually solved my problem and was finally able to deploy easily and access the web service without problems/exceptions.
脚本:
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.7.1')
import wslite.soap.*
def client = new SOAPClient("http://127.0.0.1/axis2/services/ReleaseService")
def response = client.send {
body {
myFunction(xmlns:"http://my.namespace.com") {
stringParameter("6.3.0.0")
status() { value("default") }
mode() { value("full") }
}
}
}
其中 status
和 mode
是 complexTypes
,它们由一个值"属性组成(例如).
Where status
and mode
are complexTypes
which consist of one "value" attribute (as an example).
println(response.myFunctionResponse.return)
给我 Web 服务返回的对象.当然,令牌的名称取决于 WSDL.在我的例子中,请求的响应称为 myFunctionResponse
,它有一个字段 name="return"
并给我一个 complexType
对象.可以根据 WSDL 中给出的名称检索对象的字段:
gives me the object returned by the web service. Of course the names of the tokens depend on the WSDL. In my case the response of the request is called myFunctionResponse
, which has a field name="return"
and gives me a complexType
object. The fields of the object can be retrieved according to the names given in the WSDL:
println(response.myFunctionResponse.return.location) // gives me the field value of the field "location" for my complexType