I'm using an JAva HttpsURLConnection to send an Soap envelope message. See bellow my Soap envelope payload:
OutputStream out = con.getOutputStream();
Writer wout = new OutputStreamWriter(out);
wout.write("<?xml version='1.0' encoding='UTF-8'?>\r\n");
wout.write("<S:Envelope xmlns:S= ");
wout.write(
"'http://schemas.xmlsoap.org/soap/envelope/'>\r\n"
);
wout.write("<S:Body><ns2:getAccessibleDBs xmlns:ns2=");
wout.write(
"'http://webservice.namespace.com/'>\r\n");
wout.write(" </ns2:getAccessibleDBs>\r\n");
wout.write(" </S:Body>\r\n");
wout.write("</S:Envelope>\r\n");
wout.flush();
wout.close();
However the server message is as follows:
com.sun.xml.ws.transport.http.HttpAdapter E Unsupported Content-Type: application/x-www-form-urlencoded Supported ones are: [text/xml] com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: application/x-www-form-urlencoded Supported ones are: [text/xml]
Can, you please give an insight on how to format the message paylod in order to avoid server error.
Regards,
You have two hardles,
Content-Type="text/xml"
that server is expecting. Your XML is incorrect. It should be like below, no unnecessary newlines \\r\\n
etc and namespace should start with double quote
rather then single quote.
<xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body><ns2:getAccessibleDBs xmlns:ns2="http://webservice.namespace.com/">
</ns2:getAccessibleDBs></S:Body></S:Envelope>
It should work if you do above two changes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.