I'm sending a SOAP call to a server, and the server insists on a certain Content-Type. I'm trying to set the content type but it doesn't seem to be transmitted properly.
I get a response from the server:
415 Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'
My rough code:
val soapConnectionFactory = SOAPConnectionFactory.newInstance()
val soapConnection = soapConnectionFactory.createConnection()
val url = "https://secure.com"
val messageFactory = MessageFactory.newInstance()
val soapMessage = messageFactory.createMessage()
// (create envelope)
val headers = soapMessage.mimeHeaders
headers.setHeader("Content-Type", "application/soap+xml; charset=utf-8")
soapMessage.saveChanges()
val soapResponse = soapConnection.call(soapMessage, url)
soapConnection.close()
Debugging through, the content type appears to be set properly up to the soapConnection.call(). Any ideas?