gpt4 book ai didi

web-services - Grails wslite SOAP参数导致解码错误

转载 作者:行者123 更新时间:2023-12-02 16:02:10 24 4
gpt4 key购买 nike

我正在尝试将wslite(0.7.2.0)与Grails(2.4.4)结合使用以使用SOAP Web服务。我能够使示例工作:

withSoap(serviceURL: 'http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx') {
def response = send(SOAPAction: 'http://www.27seconds.com/Holidays/US/Dates/GetMothersDay') {
body {
GetMothersDay(xmlns: 'http://www.27seconds.com/Holidays/US/Dates/') {
year(2011)
}
}
}

println response.GetMothersDayResponse.GetMothersDayResult.text()
}

但是,每当我尝试到达另一个需要参数的端点时,都会收到一个Unmarshall异常。

我的代码:
withSoap(serviceURL: 'http://www.wcc.nrcs.usda.gov/awdbWebService/services?wsdl') {
def response = send {
body {
getStations("xmlns": 'http://www.wcc.nrcs.usda.gov/ns/awdbWebService') {
stateCds(Arrays.asList("OR"))
logicalAnd(true)
}
}
}

response.getStationsResponse.return.each{resp->
println resp
}
}

异常(exception):
Message
soap:Client - Unmarshalling Error: unexpected element (uri:"http://www.wcc.nrcs.usda.gov/ns/awdbWebService", local:"stateCds").
Expected elements are <{}elementCds>,<{}maxElevation>,<{}networkCds>,<{}heightDepths>,<{}ordinals>,<{}maxLongitude>,
<{}minElevation>,<{}hucs>,<{}stateCds>,<{}minLatitude>,<{}countyNames>,<{}maxLatitude>,<{}minLongitude>,<{}stationIds>,<{}logicalAnd>

最佳答案

问题是stateCdslogicalAnd元素不应命名空间。这些子元素将继承您应用于getStations元素的 namespace 。

这是一个可以从Groovy控制台运行的工作示例:

@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='1.1.0')
import wslite.soap.*

def client = new SOAPClient('http://www.wcc.nrcs.usda.gov/awdbWebService/services')
def response = client.send {
body {
'awdb:getStations'("xmlns:awdb": 'http://www.wcc.nrcs.usda.gov/ns/awdbWebService') {
stateCds('OR')
logicalAnd(true)
}
}
}

assert !response.getStationsResponse.isEmpty()

关于web-services - Grails wslite SOAP参数导致解码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29402668/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com