我正在尝试使用wslite(0.7.2.0)和Grails(2.4.4)来使用SOAP Web服务。我能得到的例子来工作:Grails wslite SOAP params导致Unmarshalling错误
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()
}
但每当我试着打需要参数另一个端点,我得到一个解组异常。
我的代码:
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
}
}
例外:
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>
当我看WSDL,我看到stateCds需要一个字符串参数。而不是Arrays.asList(“OR”),试试“OR”。 – Stealth 2015-04-02 13:41:56
是的,我尝试使用stateCds(“OR”)具有相同的异常 – 2015-04-02 14:23:51
尝试将您的soapAction设置为“”空字符串。如果我没有定义soapAction,那么过去我曾经有过这样的例子,它已经炸毁了。 – Stealth 2015-04-02 16:59:15