import java.io.*;
import java.net.URL;
import java.net.HttpURLConnection;

class Functions
{

    public static String hitUrl(String urlToHit, String param)
        {
            try
            {
                URL url = new URL(urlToHit);
                HttpURLConnection http = (HttpURLConnection)url.openConnection();
                http.setDoOutput(true);
                http.setDoInput(true);
                http.setRequestMethod("POST");

                DataOutputStream wr = new DataOutputStream(http.getOutputStream());
                wr.writeBytes(param);
                wr.flush();
                wr.close();
                http.disconnect();  
  

                BufferedReader in = new BufferedReader(new InputStreamReader(http.getInputStream()));
                String inputLine;
                if ((inputLine = in.readLine()) != null)
                {
                        in.close();
                        return inputLine;
                }
                else
                {
                        in.close();
                        return "-1";
                }

            }
            catch(Exception e)
            {
                System.out.println("Exception Caught..!!!");
                e.printStackTrace();
                return "-2";
            }
        }
}

public class HitXmlData 
{
    public static void main(String[] args) 
    {
            String strUrl = "https://www.smsgatewayhub.com/api/mt/SendSMS?";
            String xmlData = "data=
                                   <SmsQueue>
                                      <Account>
                                        <User>abc</User>
                                        <Password>123</Password>
                                        <SenderId>TESTIN</SenderId>
                                        <Channel>1</Channel>
                                        <DCS>0</DCS>
                                        <FlashSms>0</FlashSms>
                                        <Route>1</Route>
                                      </Account>
                                      <Messages>
                                        <Message>
                                          <Number>9198981XXXXX</Number>
                                          <Text>Messge from xml</Text>
                                        </Message>
                                      </Messages>
                                    </SmsQueue>
                                "

        String output = Functions.hitUrl(strUrl, xmlData);
        System.out.println("Output is: "+output);

    }

}