kotlin dependencies { implementation("io.ktor:ktor-client-core:$ktorVersion") } kotlin val client = HttpClient() kotlin val restResponse = client.get<HttpResponse>("https://rest.api.com/products") val restResponseBody = restResponse.readText() kotlin val soapRequest = """ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://supplier.api.com/"> <soapenv:Header/> <soapenv:Body> <web:GetProductsRequest/> </soapenv:Body> </soapenv:Envelope> """.trimIndent() val soapResponse = client.post<HttpResponse>("https://soap.api.com/products") { body = soapRequest } val soapResponseBody = soapResponse.readText() kotlin val graphQLRequest = """ { "query": "{ products { id name price } }" } """.trimIndent() val graphQLResponse = client.post<HttpResponse>("https://graphql.api.com/products") { body = graphQLRequest } val graphQLResponseBody = graphQLResponse.readText()


上一篇:
下一篇:
切换中文