I am trying to call an web service by sending an xml file as input and i should be receiving an xml as a reply but whenever i send the xml i get proxy authentication error so i thought i was sending the wrong xml but the same xml works fine when i use SOAP UI so i guess there is some problem with my code.
Here is the code below
URL url = null;
String strUrl="<soapenv:Envelope xmlns:soapenv=\"http://ift.tt/1bLnMDr\" xmlns:soap=\"SoapAuthenticator\" xmlns:ship=\"http://ift.tt/1zznUkv\"><soapenv:Header> <soap:ServiceAuthenticationHeader><soap:Username>TDC43671</soap:Username> <soap:Password>hTiNMft/KaMfDDD</soap:Password><soap:IsEncrypted>false</soap:IsEncrypted></soap:ServiceAuthenticationHeader></soapenv:Header><soapenv:Body><ship:SearchForDropPoints><ship:productConceptID>92</ship:productConceptID><ship:installationID>00000000018</ship:installationID><ship:country>DK</ship:country><ship:address></ship:address><ship:postCode>6000</ship:postCode><ship:city></ship:city><ship:limit>5</ship:limit></ship:SearchForDropPoints></soapenv:Body></soapenv:Envelope>";
String ss="http://ift.tt/175o3W6";
url = new URL(ss);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestProperty("Content-type", "text/xml");
conn.setRequestProperty("Accept", "text/xml, application/xml");
conn.setRequestMethod("POST");
conn.connect();
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(strUrl);
wr.flush();
wr.close();
int iHttpResponseCode = conn.getResponseCode();
String strErrorMessage = conn.getResponseMessage();
System.out.println("Getting Response status");
System.out.println(iHttpResponseCode);
System.out.println(strErrorMessage);
Can anybode help me as to where i am going wrong.
No comments:
Post a Comment