consuming xml webservice using retrofit Parameter `soap12:Body` does not have a match in class
You are missing one more class to to hold Body
for request.
That is Envelope
will contain Body
object and
Body
will contain GetCountriesAvailable
object.
Example:
@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)
Do not include prefix
as part of element name.
Change
@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")
])
to
@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")
])
And for Body
element change as below.
@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?)