Help: Sending HTTPService request using POST to a php script

Hello all,
I need help in learning the proper method of communicating to php scripts from flex 3. I am very new to flex 3, php and web development. Thanks!
What I am trying to do is as follows:
1. User drags and drops a few items in a list control
2. user clicks a button to send these keywords to server php script
3. server will form a query based on the words sent and retrieve records and send them back
Here is what I have done so far:
1. When I send a request to server without any parameters, I amable to receive the request and query the database and send results in xml format
current issues I am facing:
1. I am gathering the list of entries in list control as follows:
<*** this function is callled when user decides to send request to server ***>private function startsearch():void {
   var i:int;
   var myAC:ArrayCollection = ArrayCollection(SelCtypes_id.dataProvider);
   var nct:XML = new XML("<contenttypes></contenttypes>");
   // add contenttype child now
   for (i = 0; i<myAC.length; i++) {
    nct.appendChild(XML(<contenttype>{myAC[i].toString()}</contenttype>));
   var params:Object = new Object();
   params.contenttypes = nct.toXMLString();
   getsearchresults.send(params);
<*** my http service entry****>
  <mx:HTTPService id="getsearchresults"
   method="post"
  url="http://localhost/search_xml.php"
  result="handlesearchresultsXml(event)"
  contentType="application/xml" />
This is what I see in flex debugger just when the request is sent out:
-> just before gersearchresults.send(params) call:
params.contenttypes = "<contenttypes>
  <contenttype>AVI</contenttype>
  <contenttype>SWF</contenttype>
</contenttypes>"
<*** within the HTTPrequest send function, I see th following in debugger ***>
message.contentType="application/xml"
message.body = paramsToSend shows "<contenttypes>&lt;contenttypes&gt;
&lt;contenttype&gt;AVI&lt;/contenttype&gt;
&lt;contenttype&gt;SWF&lt;/contenttype&gt;
&lt;/contenttypes&gt;</contenttypes>"
This looks like my XML object is again formatted by an out <contenttypes> tag and the string is converted to be HTML safe (i.e. &lt, &gt notation).
It looks like I am not doing something right with my params formation to XML and HTTPservice is reformatting it to be some form of XML (I do not know XML well either :-)
My questions:
1. What am I doing wrong?
2. If there is a good example where I can send multiple parameters from flex client to php server and get data back where the request parameters will beof the form...
<query>
<type1>
     <type1val>value1</type1val>
     <type1val>value2</type1val>
</type1>
<type2>
     <type2val>value3</type2val>
     <type2val>value4</type2val>
</type2>
</query>
Thanks for your help!

Hi, I'm having a problem with a similiar issue :/
I'm getting the error #1010 (A term is undefined and has no properties):
at flexGraph/httpResultHandlerUserInfo()
at flexGraph/__userInfoXML_result()
etc.
I removed some parts of the code so it's easier to read, if you can help me. I'm trying to populate a datagrid with info from a database, according to the alias I choose in the ComboBox. I get the error when I pick an alias from the ComboBox.
<mx:Script>
     <![CDATA[
     import mx.collections.ArrayCollection;
     import mx.rpc.events.FaultEvent;
     import mx.rpc.events.ResultEvent;
     import mx.events.DropdownEvent;
     [Bindable] private var usersInfo:ArrayCollection;
     private function httpResultHandlerUserInfo(event:ResultEvent):void{
          usersInfo = event.result.users.user;
     private function chooseUserCB(event:DropdownEvent):void{
          userInfoXML.send();
]]>
<mx:HTTPService id="userInfoXML" url="http://www.mysecondplace.org/flex/userInfo.php"
result="httpResultHandlerUserInfo(event)"
useProxy="false" method="POST">
<mx:request xmlns=""><alias>{usersAliasCB.selectedItem.alias}</alias></mx:request>
</mx:HTTPService>
<mx:ComboBox id="usersAliasCB"
x="10" y="10"
labelField="alias"
close="chooseUserCB(event)"/>
<mx:DataGrid id="testing"
x="10" y="100"
dataProvider="{usersInfo}"/>
Here's an example from the PHP file:
$query_user = "SELECT * FROM users WHERE alias='.$_POST["alias"].'";
Help me please

Similar Messages

  • Passing values from applet using POST method to PHP page

    Hello there ;)
    I realy need a help here.. I`ve been working all day on sending mail from applet. I didn`t succeed bcs of the security restrictions.
    So I decided just to pass arguments into PHP page, which process them and send e-mail to me.
    So here is the problem.. I need to send String variables througth POST into my php page. Now I`m using GET method, but I need more than 4000 characters.
    My actual solution is:
      URL url = new URL("http://127.0.0.1/index.php?name=" + name + "&message=" + message);
    this.getAppletContext().showDocument(url,"_self");I really need to rewrite it into POST. Would you be so kind and write few lines example [applet + php code]? I`ve already searched, googled, etc.. Pls don`t copy links to other forums here, probably I`ve read it.
    Thanx in advance to all :)

    hi!
    i`ve got some news about my applet.. so take this applet code:
    public class Apletik extends JApplet {
        public void init() { }
        public void start()
        try
          String aLine; // only if reading response
          String  parametersAsString = "msg=ahoj&to=world";
          byte[] parameterAsBytes = parametersAsString.getBytes();
          // send parameters to server
          URL url = this.getCodeBase();
          url = new URL(url + "spracuj.php");
          URLConnection con = url.openConnection();
          con.setDoOutput(true);
          con.setDoInput(true); // only if reading response
          con.setUseCaches(false);
          con.setRequestProperty("Content=length", String.valueOf(parameterAsBytes.length));
          OutputStream oStream = con.getOutputStream();
          oStream.write(parameterAsBytes);
          oStream.flush();
          String line="";
          BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
          while ((aLine = in.readLine()) != null)
           JOptionPane.showMessageDialog(null, aLine);      
           if(aLine.equals("")) break;
          in.close();      
          oStream.close();
        catch (Exception ex)
          JOptionPane.showMessageDialog(null, ex.toString());
    }here is code of spracuj.php which is on server:
    <?php
      if(isset($_POST['msg']))
        echo('hurray!');
    ?>it has only 1 problem.. when i test it on my localhost, everything seems to be all right. but when i post it to my server, i got IOException HTTP 400 error code :( where is the problem? please help me, i`m so close :D thanx

  • HTTP error while sending SOAP request using wsdl file

    We created SOAP request using the wsdl file ; while sending SOAP request from Altova XMLSpy, we are getting the below error.
    HTTP error: could not post file
    Can you please explain how to resolve this issue
    Regards,
    Sanghamitra

    there is very little information to help you here.
    Can you confirm if this is a SOAP sender scenario or SOAP receiver scenario?
    Also do go to thru these links to help you out;
    Troubleshooting
    Troubleshooting - RFC and SOAP scenarios *** Updated on 20/04/2009 ***
    RFC -> SOAP
    RFC -> XI -> WebService - A Complete Walkthrough (Part 1)
    RFC -> XI -> WebService - A Complete Walkthrough (Part 2)
    SOAP <-> XI <-> RFC/BAPI
    Walkthrough - SOAP  XI  RFC/BAPI

  • Problem while sending/Receiving request using the HttpURLConnection obj

    Hi,
    We are facing the problem while passing the request in Weblogic.
    Looks like there is some problem with Weblogic while sending/Receiving the request using the HttpURLConnection object.
    Currently we are migrating 2 applications to WebLogic. Application1 to application2 request should pass.
    Below is some example we tried:
    "When we send a request to our code using the SSOAdaptor code (which handles the request/session in our application) which is on the SunOne server the request parameters are received by our code successfully. And also in Create User Functionality of application1 we are sending a request to webpass(which is on Sunone Server) using the HttpURLConnection object and the SOAP request is received successfully by the Webpass."
    Looks like when we send request (using HttpURLConnection) from a server other than Weblogic to a servlet in a Weblogic the request parameters are received with out issues.
    Where as when the request is sent from WebLogic to WebLogic the request parameters are missing some how.
    Is there any issue in Weblogic? Please helpus on this.
    Thanks,
    Nagesh
    Edited by: user9307541 on Mar 15, 2010 5:08 AM

    Hi,
    Please find below scenario for testing.
    We have tested the SSOAdaptor code (it is the fucntion name which will send the data from source) locally by hittiing the WPS adaptor URL in a Java client program(TestRequest.java) and the request parameters were reaching the WPS Adapter successfully.
    Then we have written two test servlets to test the communication between SSOAdaptor(TestServlet.java) and WPS adaptor(WPSServlet.java).
    Functionality of TestSevlet: It is sending a request to WPSServelt similar to the way we are doing it in SSOAdaptor.
    Functionality of WPSServlet: It will receive the request parameters and write the parameter Map to console.
    We have deployed and these two servlets(in a single webapplication) on Tomcat server and the request parameters are reaching the WPSServlet successfully.
    Output on Tomcat server:
    before sending request
    **********************Inside WPS Servlet -- the request Map is:{TypeAcc=[Ljava.lang.String;@14e3f41, ServiceName=[Ljava.lang.String;@1acd47, GMEPortalUserID=[Ljava.lang.String;@19b04e2, UserID=[Ljava.lang.String;@5dcec6, Country=[Ljava.lang.String;@b25b9d}
    after sending request
    After this we have deployed these two servlets (with in a single webapplication) on the Weblogic server in Dev machine(path: /apps/usmport/domains/usmport/servers/usmport_admin/upload/ssoAdaptor/WEB-INF/classes/com/gm/gmeportal/security/adaptor) and
    now the request parameters are not reaching the WPSServlet.
    Output on Weblogic Server:
    before sending request
    **********************Inside WPS Servlet -- the request Map is:{}
    after sending request
    Looks like there is some problem with Weblogic while sending/Receiving the request using the HttpURLConnection object.
    When we send a request to WPSAdaptor using the Old SSOAdaptor code which is on the SunOne server the request parameters are received by WPS successfully. And also in Create User Functionality of Portal we are sending a request to webpass(which is on Sunone Server) using the HttpURLConnection object and the SOAP request is received successfully by the Webpass.
    Looks like when we send request (using HttpURLConnection) from a server other than Weblogic to a servlet in a Weblogic the request parameters are received with out issues. Where as when the request is sent from weblogic to weblogic the request parameters are missing some how.
    Please find below javs source code used to test this:
    TestRequest.java
    import java.io.BufferedReader;
    import java.io.DataOutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class TestRequest {
         * @param args
         public static void main(String[] args) throws Exception{
              // TODO Auto-generated method stub
              excutePost("http://localhost:8080/Testing/TestServlet", "GMEPortalUserID=captest.wss@it0555&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
              //System.out.println("********** Now the request is from SSO *****************");
              //excuteGet("http://10.156.0.173:7013/channel21/wpsadapter", "GMEPortalUserID=captest.wss@it0554&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
         public static String excutePost(String targetURL, String urlParameters)
         URL url;
         HttpURLConnection connection = null;
         try {
         //Create connection
         url = new URL(targetURL);
         connection = (HttpURLConnection)url.openConnection();
         connection.setRequestMethod("POST");
         connection.setRequestProperty("Content-Type",
         "application/x-www-form-urlencoded");
         connection.setRequestProperty("Content-Length", "" +
         Integer.toString(urlParameters.getBytes().length));
         connection.setRequestProperty("Content-Language", "en-US");
         connection.setUseCaches (false);
         connection.setDoInput(true);
         connection.setDoOutput(true);
         //Send request
         DataOutputStream wr = new DataOutputStream (
         connection.getOutputStream ());
         wr.writeBytes (urlParameters);
         wr.flush ();
         wr.close ();
         //Get Response     
         InputStream is = connection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         System.out.println("Response is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(connection != null) {
         connection.disconnect();
         public static String excuteGet(String targetURL, String urlParameters) throws Exception
              URL url = new URL(targetURL);
              HttpURLConnection httpurlconnection =
                   (HttpURLConnection) url.openConnection();
              /*httpurlconnection.setRequestProperty(
                   "cookie",
                   constructRequestParams(httpservletrequest.getCookies()));*/
              httpurlconnection.setDoOutput(true);
              httpurlconnection.setDoInput(true);
              httpurlconnection.setRequestProperty(
                   "Content-length",
                   String.valueOf(urlParameters.length()));
              OutputStream outputstream = httpurlconnection.getOutputStream();
              outputstream.write(urlParameters.getBytes());
              outputstream.flush();
              //Get Response     
              try{
         InputStream is = httpurlconnection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         System.out.println("Response from SSO is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(httpurlconnection != null) {
              httpurlconnection.disconnect();
    TestServlet.java
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * Servlet implementation class TestServlet
    public class TestServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
    * Default constructor.
    public TestServlet() {
    // TODO Auto-generated constructor stub
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              doPost(request,response);
         * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              //System.out.println("********************** the request Map is:" + request.getParameterMap());
              try {
                   System.out.println("before sending request");
                   excuteGet("http://localhost:7003/ssoAdaptor/WPSServlet", "GMEPortalUserID=captest.wss@it0554&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
                   System.out.println("after sending request");
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public String excuteGet(String targetURL, String urlParameters) throws Exception
              URL url = new URL(targetURL);
              HttpURLConnection httpurlconnection =
                   (HttpURLConnection) url.openConnection();
              /*httpurlconnection.setRequestProperty(
                   "cookie",
                   constructRequestParams(httpservletrequest.getCookies()));*/
              httpurlconnection.setDoOutput(true);
              httpurlconnection.setDoInput(true);
              httpurlconnection.setRequestProperty(
                   "Content-length",
                   String.valueOf(urlParameters.length()));
              OutputStream outputstream = httpurlconnection.getOutputStream();
              outputstream.write(urlParameters.getBytes());
              outputstream.flush();
              //Get Response     
              try{
         InputStream is = httpurlconnection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         //System.out.println("Response from SSO is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(httpurlconnection != null) {
              httpurlconnection.disconnect();
    WPSServlet.java
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * Servlet implementation class WPSServlet
    public class WPSServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
    * @see HttpServlet#HttpServlet()
    public WPSServlet() {
    super();
    // TODO Auto-generated constructor stub
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              System.out.println("**********************Inside WPS Servlet -- the request Map is:" + request.getParameterMap());
         * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              doGet(request,response);
    Thanks,
    Nagesh

  • [Help] Sending HTTP requests

    i was to check whether the web system created can handle a certain number of requests.. is there a possibility of sending a certain number of requests per second using a java?
    is there any libraries i have to import?

    RustiX wrote:
    would you happen to have to link to show me how to use Virtual users??I don't remember any off my head, but you should be able to google it.
    also when URLConnection is used does it create session as well? cuz i when i sent request using URLConnection and check tomcat manager to see how many session had been created it showed none.. but when i used wget or tried going to the link via a different browser it created a session..You will need to write additional code to manage session cookies, but JMeter will let you do that easily.

  • MapViewer: send admin request using pl/sql

    Hello,
    i have a reqirement to send mapviewer admin requests to the mapviewer server using pl/sql.
    I found a java class in Re: How can I refresh the map cache for Oracle Maps ? , but i'm struggeling to replicate this functionality in pl/sql, without using java.
    Are there any examples out htere how to send admin requests to mapviewer using pl/sql?
    Thanks in advance,
    Dirk

    You may use the UTL_SMTP package to send e-mail via the SMTP protocol. This package has been available in the Oracle database since Oracle 8i Release 2 (8.1.6). For more information, please check its documentation in "Oracle8i Supplied PL/SQL Packages Reference".

  • Send a mail use FM 'so_object_send' with a Script form layout

    Hi,
    I try to send a mail use FM 'so_object_send', is it possible to use a sap script form for the layout?
    Please give more details....

    Hi,
    Did you debug and check this function module 'SO_NEW_DOCUMENT_SEND_API1' ?
    As you said its giving you a sy-subrc = 2, did you check at what stage it is giving you an error ?
    Also, Commit work = 'X' has nothing to do with this as you are getting an error of Sy-subrc = 2.
    Also, while debugging are you getting the email address fetched from database table ? If no, then the sender's email has not been maintained. You will have to maintain the sender's email in the user details in SU02 under Address tab.
    I would recommend you to go for BCS to send emails wherein you specify the sender email address directly in the program rather than adding email address in every user's logon details.
    Regards,
    Danish.
    Edited by: Danish2285 on Mar 5, 2012 3:28 PM

  • HTTP POST to a php script

    I have a java applet and I need to write to a file, since I can't do that directly, I am calling a php script to write to the file. Here is the relevant code in the .java file
    URL myURL=null;
    URLConnection urlConn=null;
    DataOutputStream printout=null;
    DataInputStream input=null;
    try{
         myURL=new URL(getCodeBase(),"writeFromFile.php");
         }catch(Exception easidghih){JOptionPane.showMessageDialog(null,"WRITETOFILE");}     
    try{
         urlConn=myURL.openConnection();
         }catch(Exception w){JOptionPane.showMessageDialog(null,"openConnection()");w.printStackTrace();}
    try{urlConn.setDoInput(true);
         urlConn.setUseCaches(false);
    catch(Exception a){JOptionPane.showMessageDialog(null,"Exception here");}
    try{
         urlConn.setDoOutput(true);
         PrintWriter out=new PrintWriter(urlConn.getOutputStream());
         out.println("File="+username+"P.txt"+"&text="+(Long.toString(number)));
         out.close();the text of the php file, "writeFromFile.php" is below.
    <HTML>
    <BODY>
    <?php
    print "BOB";
    $File=$_POST["File"];
    $text=$_POST["text"];
    $filename=$File;
    $fp=fopen($filename,"w");
    $string=$text;
    $write=fputs($fp,$string);
    fclose($fp);
    ?>
    </BODY>
    </HTML>The file writing works fine when I have a separate file with a form to fill out in HTML. But when I run the java applet it gives no errors, but the file writing doesn't work.

    have made a php file what will display a number,
    <?
    $brush_price = 5;
    $counter = 10;
    echo "<table border=\"1\" >"."\n";
    echo "<tr><th>Quantity</th>"."\n";
    echo "<th>Price</th></tr>"."\n";
    while ( $counter <= 100 ) {
        echo "<tr><td>"."\n";
        echo $counter;
        echo "</td><td>"."\n";
        echo $brush_price * $counter;
        echo "</td></tr>"."\n";
        $counter = $counter + 10;
    echo "</table>"."\n";
    ?>no i want to get the tables with java
    import java.io.*;
    import java.net.*;
    class URLConnect
       void connection()
         try
         int taken;
         String fileName = "C:/abhishek/connected.txt";
         FileWriter fileWriter = new FileWriter( fileName );
          BufferedWriter bufferedWriter = new BufferedWriter( fileWriter );
          URL url = new URL"http://192.168.1.102/rapidclaims/httpsdocs/test/abhishek/abhi/while.php");
          URLConnection urlconnection = url.openConnection();
          System.out.println("url is: " + url+"\n");
          System.out.println("Type is: " + urlconnection.getContentType()+"\n");
            int length = urlconnection.getContentLength();
            System.out.println("Length is: " + length+"\n");
            InputStream in = urlconnection.getInputStream();
            int i=0;
            while ((taken = in.read()) != -1)
              System.out.print((char) taken);
              bufferedWriter.write(taken );
            bufferedWriter.close();
          catch (Exception ee)
           System.err.println("Got an exception!!!! ");
           ee.printStackTrace();
    class display
      public static void main (String[] args)
        try
           URLConnect test1= new URLConnect();
            test1.connection();
        catch (Exception ee)
        System.err.println("Got an exception!!!! ");
         ee.printStackTrace();
    }but no success . earlier it was working to extract out the strings
    plesase anybody know help with a suitable source code[/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Send a request using Http(s)URLConnection through proxy issue

    Hi all,
    Here are system environment,
    OS: Ubuntu 12.04
    Java version: 1.6.0_27
    OpenJDK Runtime Environment (IcedTea6 1.12.4) (6b27-1.12.4-1ubuntu1)
    OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
    There are 3 roles introduction as below:
    1. A https client: It can not direct connect to https server. Because it is restricted in a enclosed network environment just like intranet(ip is 10.100.11.8).The only way out is proxy server.
    2. A proxy server: Locate between https client and https server. It have two network interfaces(ip are 10.100.11.10 and 192.168.11.10)
    3. A https server: It is on extranet(ip is 192.168.11.123) and it also cannot connect to https client directly.
    The other network environment setup is: There is no DNS server on https client network environment.
    The following is part of https client code section:
            public static void main(String args[]){
               String proxyIp ="10.100.11.10";// proxy server IP
               testConn(proxyIp);
            private static void testConn(String proxyIp){
                    String httpsURL="https://192.168.11.123:8443/httpsServices";
                    setSSLContext();// I thought this is not root cause so I do not post on
                    try{
                      InetAddress intIPAdd= InetAddress.getByAddress(convStrToByte(proxyIp));
                      InetSocketAddress proxyInetAddr = new InetSocketAddress(intIPAdd,80);
                      Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyInetAddr);
                      URL httpsUrl = new URL(httpsURL);
                      HttpsURLConnection httpsCon = (HttpsURLConnection) httpsUrl.openConnection(proxy);
                      httpsCon.setDoOutput(true);
                      httpsCon.setDoInput(true);
                      httpsCon.setRequestMethod("POST");
                      httpsCon.setDefaultUseCaches(true);   
                      httpsCon.setUseCaches(true);
                      System.out.println("Get OutPutStream start!");
                      OutputStream out = httpsCon.getOutputStream(); // or httpsCon.connect();
                      System.out.println("Get OutPutStream done!");
                      OutputStreamWriter owriter = new OutputStreamWriter(out);
                      owriter.write("<request>test</request>");
                      owriter.flush();
                      owriter.close();
            private static byte[]  convStrToByte(String ip){
            String str[] = ip.split("\\.");
            byte[] ipAry = new byte[str.length];
              for(int i=0;i<str.length;i++){
                ipAry[i] = (byte) Integer.parseInt(str, 10);
    return ipAry;
    All right, my problem is, while print out "Get OutPutStream start" untill "Get OutPutStream done", it always takes about 5 secs.
    No Error or exception. It was just hanging there approx 5 secs.
    I observed the packets flow with wireshark.
    Found out that hang time is to send a multicast to ask MDNS the proxy IP. No one reply this message. It would ask 3 times and then send request to proxy.
    About https trust and authentication issue. I use *All Trust* solution. because https server use self-signed CA by myself.
    If need, I would update this post with code section of setSSLContext() part.
    I wondering to know that I create proxy object using *InetSocketAddress(InetAddress addr, int port)*, or I create proxy ip instance using *public static InetAddress getByAddress(byte[] addr)* why it would ask to MDNS for proxy ip?
    On normal concept, I give an ip address and it do not need to resolve this ip for domain name.
    Check InetAddress getByAddress(byte[] addr) of JAVA SE6 API:
    It says: 'This method doesn't block, i.e. no reverse name service lookup is performed.'
    What can I do to let https client don't need to ask MDNS?
    Thank you guys so much.
    Edited by: 1002346 on 2013/4/29 上午 12:05                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Java does reverse DNS lookups for security reasons. Not sure you can disable it but if you can it will be described on the Networking Properties page.

  • How to send Array data using Post Method?

    Var array = $_POST['myData'];
    array[0] => 'ABC'
    array[1] => 'DEF'
    how to improve this code to support send array data...?
    String url ="http://xxxxx/test.php";
    String[] arraystr={"ABC", "DEF", "EDFF"}
    String parameter = "myData=" +arraystr;    // no support this
    Strint str = postMrthod(url, parameter );
    public static String postMethod(String url, String parameter) {
            StringBuffer b = new StringBuffer("");
            HttpConnection hc = null;
            InputStream in = null;
            OutputStream out = null;
            try {
                hc = (HttpConnection) Connector.open(url);
                hc.setRequestMethod(HttpConnection.POST);
                hc.setRequestProperty("CONTENT-TYPE", "application/x-www-form-urlencoded");
                hc.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
                out = hc.openOutputStream();
                byte postmsg[] = parameter.getBytes();
                for (int i = 0; i < postmsg.length; i++) {
                    out.write(postmsg);
    out.flush();
    in = hc.openInputStream();
    int ch;
    while ((ch = in.read()) != -1) {
    b.append((char) ch);
    } catch (IOException e) {
    e.printStackTrace();
    try {
    if (in != null) {
    in.close();
    if (hc != null) {
    hc.close();
    } catch (IOException e) {
    e.printStackTrace();
    return b.toString().trim();

    yes, you can send integer value like this. But I think you have to put quotes around <%= TAMID%> i.e.
    <input type="hidden" id="HTTP_CVHTAMID"
    name="HTTP_CVHTAMID" value= "<%= TAMID%>" >

  • Why can't I send game request using this browser as the main browser on my phone?

    Every time I try to send a life on candy crush it doesn't send .

    Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    The Firefox cache temporarily stores images, scripts, and other parts of websites while you are browsing. <br>
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies, do the following:
    #Tap the menu icon located at the top right corner. This is the icon with 3 bars. On older Android devices you'll have to press the hardware menu key and then tap More.
    #Tap '''Settings'''.
    #After that, you will be taken to the settings screen. In the settings screen, look under the section '''''Privacy & Security''''' and select '''Clear private data'''.
    #You will then be taken to a list of what can be cleared. Select the following 2 for deletion:
    #*Cookies & active logins
    #*Cache
    #After those have been selected, tap the '''Clear data''' button to actually clear the cache and cookies.
    Did this help you with your problems? Please let us know!

  • Help: send unicode text using sockets

    Hi,
    I am trying to send unicode text to a native app using sockets. My test code looks like this
    Socket socket = new Socket(m_serverHost, m_hostPort);
    OutputStreamWriter out = new OutputStreamWriter(socket.getOutputStream(), "UTF-8");
    InputStreamReader reader = new InputStreamReader(socket.getInputStream(), "UTF-8");
    BufferedReader in = new BufferedReader(reader);
    // receive response to connect
    byte[] rc = new byte[4];
    int i = 0;
    while (i < 4)
    rc[i++] = (byte) in.read();
    String text = new String("Hello");
    out.write(text);
    // receive response to "hello"
    i = 0;
    while (i < 4)
    rc[i++] = (byte) in.read();
    My test program is connecting to the server socket but the server does not seem to understand the text that I send.
    Please comment if I am doing anything wrong or advice if you have any different ideas.
    Thanks,
    nallamos

    Try using the following output and input streams.
    out = new DataOutputStream(
    new BufferedOutputStream(
    s.getOutputStream()));
    in = new DataInputStream(
    new BufferedInputStream(
    s.getInputStream()));
    When you send the data send it using
    out.WriteBytes(message)

  • Help : Sending Jar file using bluetooth.

    Hi
    I have done till below...
    Midlet will search available bluetooth device in range.
    I want to do below.
    1. Search available bluetooth device in range
    2. User will see list of devices.
    3. when user will select a device, i want to send the jar file itself ( i have stored jar file inside resources)
    4. on file sent to bluetooth devices, it should tell file sent successfully.
    More :
    I am confused with Bluetooth server and client terminology.
    Here my program is client or server ? Infact the whole pupose is we have made some Java program and we want to make it viral, easy for our users to send it to their friends via bluetooth
    Any pointers ?
    Raxit
    www.m4mum.com

    Hi,
    You might wanna look take a look in the JSR 82 Specifications. There is a method like agent.startInquiry(); that starts a search for nearby BT devices. All you have to do is place each found device in an array of type Vector.
    It would have been easier if your code or a snippet of it was available to see what the problem was.
    Rambo.
    PS: A client application application starts a connection on a server application. Where you put them is up to you.

  • How to send file as a parameter to php script

    Hi,
    Can any body help me to send the file as a parameter to php script. I am using the HttpURLConnection method.
    Thank

    String msg= "name=" + strName + "&surname=" + strSurname;
                   byte[] msgAsBytes = msg.getBytes();
    I am able to pass the string to the php script as
    URLConnection con = url.openConnection();          
              ((HttpURLConnection) con).setRequestMethod("POST");
              con.setDoOutput(true);
              con.setDoInput(true);
              con.setUseCaches(false);     
    OutputStream oStream = con.getOutputStream();
                   oStream.write(msgAsBytes);
                   oStream.flush();and in php, i store into the global variable and it work fine
    if(isset($_POST['name' ]&&isset($_POST[' surname'])it works fine for me. But problem is with the file. How can I send the file to php. Please help me. Thanks

  • Multiple post requests using a single HttpConnection

    Hi,
    is it possible to send multiple post requests using a single Http connection.
    i am currently trying to simulate the preformance overhead because of creating HttpURLConnection to talk to my servlet. But, that made me wonder, if is there a way to send multiple post requests using a single HttpURLConnection.
    can anyone help me with this.
    thanks in advance

    Hi
    I found this article through Google. I hope it helps a little
    http://www.developer.com/tech/article.php/761521
    D

Maybe you are looking for