I am trying to request a web service using the below code
HttpURLConnection conn = null;
String operation = "validateAddress";
String urlStr = "http://.....";
String requestXML = "<soapenv:Envelope "
+ "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ "xmlns:v3=\"http://cio.att.com/commonheader/v3\" "
+ "xmlns:loc=\"http://ovalsgis.ebm.att.com/locationgeocoderservicerequest.xsd\">"
+ "<soapenv:Body>"
+ "<loc:validateGisAddressRequest "
+ "requestFlag=\"F\" "
+ "telcoFlag=\"N\">"
+ "<loc:FieldedAddressInfo>"
+ " <loc:houseNumber>10</loc:houseNumber> "
+ " <loc:streetName>E MURPHY AVE</loc:streetName> "
+ " <loc:city>SAPULPA</loc:city> "
+ " <loc:state>OK</loc:state> "
+ " <loc:country>USA</loc:country>"
+ "</loc:FieldedAddressInfo>"
+ "</loc:validateGisAddressRequest>"
+ "</soapenv:Body>"
+ "</soapenv:Envelope>";
byte[] reqload = requestXML.getBytes();
URL server = new URL(urlStr.trim());
conn = (HttpURLConnection) server.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setAllowUserInteraction(false);
conn.setRequestProperty("Username", "abcTest");
conn.setRequestProperty("Password", "abcPassword");
conn.setRequestProperty("WSS-Password Type", "PasswordText");
conn.setRequestProperty("Content-Type", "text/xml");
String reqLen = Integer.toString(reqload.length);
conn.setRequestProperty("Content-Length", reqLen);
conn.setRequestProperty("SOAPAction", operation);
OutputStream os = conn.getOutputStream();
os.write(reqload);
os.flush();
logger.info("Received response Code (" + conn.getResponseCode() + ")");
But i am getting the following in response:
Bad Request - Invalid Header HTTP Error 400. The request has an invalid header name
Can anyone help me with this?