I've seen other posts on this, but none seem to help. The issue seems to be adding the parameter to the request. Note this is a .svc -- not wsdl. The C# .svc file has a data contract of:
[DataContract]
public class MyMethod_In
{
[DataMember]
public string rc;
}
Kotlin code: (constants take out for easier reading, and names changed to protect the innocent)
val soapObject = SoapObject("https://qa.mysite.com/ws/MyService.svc/", "MyMethod")
soapObject.addProperty("rc", "xyz")
val envelope = SoapSerializationEnvelope(SoapEnvelope.VER11)
envelope.setOutputSoapObject(soapObject)
envelope.dotNet = true
val httpTransport = HttpTransportSE("https://qa.mysite.com/ws/MyService.svc/MyMethod")
try {
httpTransport.call("https://qa.mysite.com/ws/MyService.svc/MyMethod", envelope)
blah blah
}
catch (e: Exception) {
exception happens with 400 error
}
The problem seems to be the soapObject.addProperty line. I've also tried other code where I construct the property info and set the name, type, and value, but I still always get the 400 error. I tried that with a type of String and a type of JSON, and it made no difference.
I'm not totally sure of some of the hard coded values, but I seem to be calling the service correctly, because I tried another service with no input parameters, and this worked fine and got the response.
I'm probably missing one small thing, but can't find it. Any ideas on why the bad request? Thanks
Figured it out for okhttp3, version 4.2.0. As I suspected, I need to pass JSON data. This code does it:
Should probably clean it up and use gson or something, but at least this works.