import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
Это работает для меня.
запрос
@Root(name = "soap:Envelope")
@NamespaceList(
value = [
Namespace(prefix = "xsi", reference = "http://www.w3.org/2001/XMLSchema-instance"),
Namespace(prefix = "xsd", reference = "http://www.w3.org/2001/XMLSchema"),
Namespace(prefix = "soap", reference = "http://www.w3.org/2003/05/soap-envelope")
]
)
class CountriesAvailableRequestEnvelope(
@field:Path("soap:Body")
@field:Element(name ="GetCountriesAvailable")
@param:Element(name ="GetCountriesAvailable")
@field:Namespace(reference = "http://www.holidaywebservice.com/HolidayService_v2/")
val getCountries: String = ""
)
использование
val result = webServices.getAvailableCountries(CountriesAvailableRequestEnvelope())
...
ответ
@Root(name = "soap:Envelope")
@NamespaceList(
value = [
Namespace(prefix = "xsi", reference = "http://www.w3.org/2001/XMLSchema-instance"),
Namespace(prefix = "xsd", reference = " http://www.w3.org/2001/XMLSchema"),
Namespace(prefix = "soap", reference = "http://www.w3.org/2003/05/soap-envelope")]
)
class CountriesAvailableResponseEnvelope {
@field:Path("soap:Body")
@field:Element(name = "GetCountriesAvailableResponse")
@field:Namespace(reference = "http://www.holidaywebservice.com/HolidayService_v2/")
var response: GetCountriesAvailableResponse? = null
}
@Element
class GetCountriesAvailableResponse {
var GetCountriesAvailableResult: List<CountryCode>? = null
}
class CountryCode {
@field:Element(name = "Description")
var description: String? = null
@field:Element(name = "Code")
var code: String? = null
}
logcat
2019-04-08 12:00:23.989 22722-22748/nz.org.westforce.mobileui D/OkHttp: --> POST http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx
2019-04-08 12:00:23.989 22722-22748/nz.org.westforce.mobileui D/OkHttp: Content-Type: text/xml
2019-04-08 12:00:23.989 22722-22748/nz.org.westforce.mobileui D/OkHttp: Content-Length: 329
2019-04-08 12:00:23.989 22722-22748/nz.org.westforce.mobileui D/OkHttp: <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
2019-04-08 12:00:23.989 22722-22748/nz.org.westforce.mobileui D/OkHttp: <soap:Body>
2019-04-08 12:00:23.989 22722-22748/nz.org.westforce.mobileui D/OkHttp: <GetCountriesAvailable xmlns="http://www.holidaywebservice.com/HolidayService_v2/"></GetCountriesAvailable>
2019-04-08 12:00:23.989 22722-22748/nz.org.westforce.mobileui D/OkHttp: </soap:Body>
2019-04-08 12:00:23.989 22722-22748/nz.org.westforce.mobileui D/OkHttp: </soap:Envelope>
2019-04-08 12:00:23.990 22722-22748/nz.org.westforce.mobileui D/OkHttp: --> END POST (329-byte body)
2019-04-08 12:00:24.363 22722-22748/nz.org.westforce.mobileui D/OkHttp: <-- 200 OK http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx (372ms)
2019-04-08 12:00:24.363 22722-22748/nz.org.westforce.mobileui D/OkHttp: Cache-Control: private, max-age=0
2019-04-08 12:00:24.363 22722-22748/nz.org.westforce.mobileui D/OkHttp: Content-Type: application/soap+xml; charset=utf-8
2019-04-08 12:00:24.363 22722-22748/nz.org.westforce.mobileui D/OkHttp: Server: Microsoft-IIS/8.5
2019-04-08 12:00:24.363 22722-22748/nz.org.westforce.mobileui D/OkHttp: X-AspNet-Version: 4.0.30319
2019-04-08 12:00:24.363 22722-22748/nz.org.westforce.mobileui D/OkHttp: X-Powered-By: ASP.NET
2019-04-08 12:00:24.363 22722-22748/nz.org.westforce.mobileui D/OkHttp: X-Powered-By-Plesk: PleskWin
2019-04-08 12:00:24.363 22722-22748/nz.org.westforce.mobileui D/OkHttp: Date: Mon, 08 Apr 2019 03:48:45 GMT
2019-04-08 12:00:24.363 22722-22748/nz.org.westforce.mobileui D/OkHttp: Content-Length: 983
2019-04-08 12:00:24.368 22722-22748/nz.org.westforce.mobileui D/OkHttp: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetCountriesAvailableResponse xmlns="http://www.holidaywebservice.com/HolidayService_v2/"><GetCountriesAvailableResult><CountryCode><Code>Canada</Code><Description>Canada</Description></CountryCode><CountryCode><Code>GreatBritain</Code><Description>Great Britain and Wales</Description></CountryCode><CountryCode><Code>IrelandNorthern</Code><Description>Northern Ireland</Description></CountryCode><CountryCode><Code>IrelandRepublicOf</Code><Description>Republic of Ireland</Description></CountryCode><CountryCode><Code>Scotland</Code><Description>Scotland</Description></CountryCode><CountryCode><Code>UnitedStates</Code><Description>United States</Description></CountryCode></GetCountriesAvailableResult></GetCountriesAvailableResponse></soap:Body></soap:Envelope>
2019-04-08 12:00:24.369 22722-22748/nz.org.westforce.mobileui D/OkHttp: <-- END HTTP (983-byte body)
Не включайте prefix
как часть имени элемента.
Измените
@Root(name = "soap12:Envelope")
@NamespaceList(value = [
Namespace(prefix = "xsi", reference = "http://www.w3.org/2001/XMLSchema-instance"),
Namespace(prefix = "xsd", reference = "http://www.w3.org/2001/XMLSchema"),
Namespace(prefix = "soap12", reference = "http://www.w3.org/2003/05/soap-envelope")
])
на
@Root(name = "Envelope")
@NamespaceList(value = [
Namespace(prefix = "xsi", reference = "http://www.w3.org/2001/XMLSchema-instance"),
Namespace(prefix = "xsd", reference = "http://www.w3.org/2001/XMLSchema"),
Namespace(prefix = "soap12", reference = "http://www.w3.org/2003/05/soap-envelope")
])
И для Body
измените элемент, как показано ниже.
@Root(name = "Body", strict = false)
@Namespace(reference="http://www.w3.org/2003/05/soap-envelope")
data class CountryCode(
@Element(name = "description", required = false) val description: String?,
@Element(name = "code", required = false) val code: String?)
Вам не хватает еще одного класса, чтобы держать Body
для запроса.
То есть Envelope
будет содержать Body
объект, а Body
будет содержать GetCountriesAvailable
объект.
Пример:
@Root(name = "Envelope")
@NamespaceList(value = [
Namespace(prefix = "xsi", reference = "http://www.w3.org/2001/XMLSchema-instance"),
Namespace(prefix = "xsd", reference = "http://www.w3.org/2001/XMLSchema"),
Namespace(prefix = "soap12", reference = "http://www.w3.org/2003/05/soap-envelope")
])
data class CountriesAvailableRequestEnvelope(
@Element(name = "Body", required = false)
@Namespace(reference="http://www.w3.org/2003/05/soap-envelope", prefix:"soap12")
val Body: Body)
@Root(name = "Body", strict = false)
@Namespace(reference="http://www.w3.org/2003/05/soap-envelope", prefix:"soap12")
data class Body(
@Element(name = "GetCountriesAvailable", required = false)
val countriesAvailableRequest: CountriesAvailableRequest)
@Root(name = "GetCountriesAvailable", strict = false)
@Namespace(reference = "http://www.holidaywebservice.com")
data class CountriesAvailableRequest(
@Element(name = "GetCountriesAvailable", required = false) val code: String)