HTTP POST PHP

Dear J2me people,
I'm writing an app for midp 1.0 /2.0. It posts data via http post to a php file on a server. It works in emulators and many actual devices.
However, I've got this problem on Nokia 6230i and Nokia 6101. The data sends OK (HTTP code 200) but doesn't write to database.
It seems people have come across similar problems on the forums,
although haven't posted the solution.
Thank you very much for your time,
Mark
code follows::::::::::::::::::::::
httpConnection = (HttpConnection)Connector.open(url);
             httpConnection.setRequestProperty("User-Agent","Profile/MIDP-  1.0 Configuration/CLDC-1.0");
             httpConnection.setRequestProperty("Content-Language", "en-CA");
   httpConnection.setRequestProperty("CONTENT-TYPE", "application/x-www-form-urlencoded");
              httpConnection.setRequestProperty( "Connection", "close" );
                      httpConnection.setRequestMethod( httpConnection.POST);
String req = 4&entries=1&date0=2/12&label0=WriteHere&age0=Write%20Here&wagescale0=8" ;               
        httpConnection.setRequestProperty("Content-Length", Integer.toString( req.length()));
          out = httpConnection.openOutputStream();
            int rlength = req.length();
            for ( int i = 0; i < rlength; i++ )
                out.write( req.charAt(i));
            in = httpConnection.openInputStream();
                  

hi mark....
by any chance could you help me with audio streaming via bluetooth from a handset?
eventually i would like to mount the application onto a dell axim PDA.
i hav a bit of code you can look @ which has a about 3/4 errors of which i dont know. im sure there is a truck load of imports to add to this code but im not sure as to which ones.
please please help if u can, thanks.
package javax.bluetooth;
import java.io.DataOutputStream;
public class firstone {
public void transfer(DataOutputStream output) {
try{
int i = 0;
int auglis = 50058; //chunk size
//if it is wav file, we need to edit header:
// audio[4] = (byte)0x8A;
// audio[5] = (byte)0xC3;
// audio[6] = (byte)0x00;
// audio[7] = (byte)0x00;
// audio[54] = (byte)0x50;
// audio[55] = (byte)0xC3;
// audio[56] = (byte)0x00;
// audio[57] = (byte)0x00;
byte[] tmp = new byte[50058];
int countBytes= 0;
int headerup = 32; //mp3 header is 32 bytes.
while(i<50058){
tmp[i] = audio; //byte array audio is byte array from mp3 file
i++;
countBytes++;
output.writeInt(50058); //write to midlet, that chunk size will be 50058
output.write(tmp); //write chunk itself
boolean varam = true; //booleand that will become false, when file ends
while(varam){
int tmplen = garums - countBytes; //check if it is not last chunk
int o=50058;
if(tmplen>50058){           //if it is not last chunk
o = 50058;
} else{
o = tmplen+headerup; // if it is last chunk
tmp = new byte[o];
varam = false; //out while loop will end
int z = 0;
while(z<32){                 //write 32 byte header to chunk
tmp[z] = audio[z];
z++;
countBytes++;
while(z<o){                  //white chunk it self
tmp[z] = audio[i];
z++;
i++;
countBytes++;
headerup = headerup +32;
output.writeInt(o); //white size of chunk (typically 50058)
output.write(tmp); //white chunk itself
} catch (Exception e) {}

Similar Messages

  • HTTP POST to PHP server problem

    Hi, im trying post a long string to php from a MIDLET, but i have some problems. When i send the whole String, my php server cant receive the request (i have not any response), but, if the string that i send is 1/5 from the original, the process is successful correctly. have somebody any idea?
    thx

    this is my problem, extracted from another topic on this forum:
    "Hi everyone.
    I have a problem, and hope someone may help me.
    My midlet is uploading sizeable data via http POST.
    I'm using WTK104, since i need MIDP1.0
    The code have been tried on DefaultGrayPhone emulator
    and add-on Nokia's Series 60 Emulator.
    Both emulators chunck data, however in different ways.
    Deafult one simply produces wrong chunk length (possibly a bug),
    Nokia's one always chunks by equal offsets of 2016 bytes.
    I'm not using flushing, just close. All the data is being send
    at once by one output stream write call.
    So I believe (after proper investigation) that MIDP will use chunked Transfer-Encoding method whatever
    on such sizeable a data as mine is (up to 50KB) and there's no way to override this behaviour.
    Here the main problem appears - Apache refuses to accept chunked encoding in request. The corresposnding message is given in error log
    *chunked transfer encoding forbidden*. The returned code is 411 - Content-Length requred. I see no way to override this behaviour of Apache. I was trying to upload my data into Zope web-server, which is my primary goal, but it doesn't handle chunked request either.
    Has anyone faced the same problem? Who has managed to POST sizeable data from midlet? Which web servers did you use for that?
    Any inputs are highly appreciated!
    Anton"
    Another:
    "> So I believe (after proper investigation) that MIDP
    will use chunked Transfer-Encoding method whatever
    on such sizeable a data as mine is (up to 50KB) and
    there's no way to override this behaviour.Is this true? When I try to set the content-length headers and then write a large byte[] to the output stream I got from an HttpConnection, the HttpConnection appears to remove the content-length header altogether and automatically sets the transfer-encoding to chunked.
    Note- I am not calling flush on the outputstream, but I am calling httpconnection.getResponseCode, which I believe calls flush on the outputstream.
    Abraham"
    I have the identical problem.

  • Retrieve data/files fro HTTP POST request in On-Demand process

    Hello,
    I would like to integrate https://github.com/blueimp/jQuery-File-Upload to my APEX 4.2 application inside XE11g. I would like to use this kind of jQuery component, multiple file upload, use Drag & Drop, image resize, size limit, filter extensions etc...
    This jQuery component and also others javascript uploaders sends data files to some defined URL. Developer need to build some servlet, php script or something on server side that will read files from HTTP request and stores it somewhere.
    Do you know how to do it in APEX? How can I read data from HTTP POST request in PL/SQL? Now I can only call my On-Demand application process from javascript, but I am not able to read any data from HTTP POST in it.
    Can I do it in APEX, or using MOD_PLSQL?
    I would like to implement this:
    1) some javascript uploader will call some URL of my application and sends HTTP POST with data files
    2) I will read data files from HTTP POST and store them into database
    3) I will create some HTTP response for javascript uploader
    Thank you for some tips

    I know about that existing plugin " Item Plugin - Multiple File Upload"
    But I doesn't work in IE and has only basic features. Licence for commercial use is also needed. I would like to use some existing jQuery plugin. There are many of these plugins with nice features. And only one problem is that I need to create some server side process/servlet/script.. that can recieve HTTP request, get files from it and stores them into DB.

  • Java HTTP Post Raw Data

    Hi All,
    I'm looking to make an HTTP post request given the raw data that I have. I've spent a while looking for the solution, made a handful of attempts and I'm looking for a little bit of help. The PHP code for what I'm looking to do looks like this:
    <?
    $url="http://localhost:3009";
    $postdata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
    <hi></hi>";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    $result = curl_exec($ch);
    curl_close($ch);
    echo($result);
    ?>
    My attempt was this:
         private String setXmlPostHeader(Document doc, PostMethod postMethod) throws java.io.IOException, java.io.UnsupportedEncodingException, javax.xml.transform.TransformerException
              ByteArrayOutputStream xmlBytes = new ByteArrayOutputStream();
              XML.serialize( doc, xmlBytes );
              final byte[] ba = xmlBytes.toByteArray();
              String data = new String(ba, "utf-8");
              InputStreamRequestEntity re = new InputStreamRequestEntity(new ByteArrayInputStream(ba));
              postMethod.setRequestEntity(re);
              postMethod.setRequestHeader("Content-type", MediaType.XML.toString() + "; charset=UTF-8");
              return data;
    And then executing the postMethod, but this simply is a post containing no data. Does anyone see anything wrong that I'm doing? Is there an easy way to set the raw http post data in java like there is in php? Thanks.
    -Ken

    Look at the PostMethod documentation. You need to set the multipart request.

  • Working with HTTP-POST Submit Button

    I've created a form that uses a submit button with HTTP-POST.   I've tested this against a script that displays the fields, however, I'd like to table the posted data to SQL.   Can someone show me some code to parse this data with CGI, or PHP?

    Yes. At some point you will need to prarse the requests and treat them differently - because a POST is NOT the same as a GET.
    Anyway, just place the variables or script-links to the variables in an HTML Form.
    Very easy stuff.

  • CL_HTTP_CLIENT, HTTP POST of XML as a form field, encoding

    I am working on a couple of interfaces between a SAPsystem (NetWeaver 2004s, ABAP stack) and another system.
    On the SAP side we are using the built-in HTTP-client (CL_HTTP_CLIENT).
    For the interface from SAP to the other system, the other system expects an XML as the value of a form field in an HTTP POST request.
    In fact, it was described as doing the equivalent to this HTML-fragment in a web-browser:
    <form action="http://over.there.com/interface/import.php" method="post">
      <p>Please enter your xml data:
        <textarea name="data" cols="50" rows="10"></textarea>
        <input type="submit" value="submit">
      </p>
    </form>
    I assume I will have to do a SET_METHOD in order to get the POST method (as opposed to GET) and a SET_FORM_FIELD (for field "data").
    According to the reference I found at W3C ( http://www.w3.org/TR/html4/interact/forms.html ), the default encoding method for a POST is "application/x-www-form-urlencoded". Does this mean I have to do this encoding myself?
    Could I opt for another encoding - "text/xml" for example? If so, how? With a SET_HEADER_FIELD?

    Thank you.
    This is how we set the context-type:
        call method client->request->if_http_entity~set_content_type
            exporting
              content_type = p_contyp.
    where p_contyp contained 'text/xml'.
    This is how we set the form-field data:
    call method client->request->if_http_entity~set_form_field
            exporting
              name  = p_formfd
              value = xmlstring.
    where p_formfd contained 'data' - the name that was specified.
    This is how we make the request a POST:
    call method client->request->set_method
          exporting
            method = 'POST'.

  • How to receive XML from Flex HTTP POST

    Hi,
    We curreontly have a setup where we have a FLEX frontend send an XML through a HTTP POST and awaiting a response also in XML. On the backend this is handled relatively simply by a PHP script that basically does the following:
    read data (in XML)from FlEX HTTP POST into a new temp XML file.
    execute a c++ program with the XML file as one of the parameter.
    return the result to FLEX
    We have decided to move to BlazeDS for various reasons.
    Looking at the examples bundled with BlazeDS they have a jsp example that returns an XML result to FLEX so that part is fine. I am trying to find an example of JSP (or Servlet) that is able to read the XML data from FLEX and write it into a temp XML file. I would then try to use runtime.exec to invoke a local C++ program to process the XML file the result of which will be sent back to FLEX.
    Any help will be very much appreciated!

    <div class=Section1><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'>I&#8217;d avoid calling an executable just to process XML &#8211;your<br />application server would provide enough support for reading and writing XML, no?<br />Also, if you&#8217;re only planning on working with XML then even BlazeDS might<br />be overkill because its focus is on sending strongly typed ActionScript data efficiently<br />to and from a client (it&#8217;s true that it does have a proxy service, but<br />that is not involved with processing the actual XML data).<o:p></o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'><o:p> </o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'>How complex is your XML? Do you need to resolve ids and<br />references or can you parse it top down in a single pass? There are several<br />well known libraries in Java for dealing with XML &#8211; the choice depends on<br />how you need to interact with the XML. Most of them take an InputStream as a<br />source for reading XML and you can get the InputStream from the servlet<br />request. Googling should turn up numerous examples.<o:p></o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'><o:p> </o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'>Pete<o:p></o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'><o:p> </o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'><o:p> </o:p></span></p><br /><br /><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><br /><br /><div><br /><br /><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><br /><br /><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span<br />style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> khwong<br />[mailto:[email protected]] <br><br /><b>Sent:</b> Sunday, September 28, 2008 12:09 PM<br><br /><b>To:</b> [email protected]<br><br /><b>Subject:</b> How to receive XML from Flex HTTP POST<o:p></o:p></span></p><br /><br /></div><br /><br /></div><br /><br /><p class=MsoNormal><o:p> </o:p></p><br /><br /><p class=MsoNormal style='margin-bottom:12.0pt'>A new discussion was started by<br />khwong in <br><br /><br><br /><b>General Discussion</b> --<br><br />  How to receive XML from Flex HTTP POST<br><br /><br><br />Hi, <br><br /><br><br />We curreontly have a setup where we have a FLEX frontend send an XML through a<br />HTTP POST and awaiting a response also in XML. On the backend this is handled<br />relatively simply by a PHP script that basically does the following: <br><br /><br><br />read data (in XML)from FlEX HTTP POST into a new temp XML file. <br><br />execute a c++ program with the XML file as one of the parameter. <br><br />return the result to FLEX <br><br /><br><br />We have decided to move to BlazeDS for various reasons. <br><br /><br><br />Looking at the examples bundled with BlazeDS they have a jsp example that<br />returns an XML result to FLEX so that part is fine. I am trying to find an<br />example of JSP (or Servlet) that is able to read the XML data from FLEX and<br />write it into a temp XML file. I would then try to use runtime.exec to invoke a<br />local C++ program to process the XML file the result of which will be sent back<br />to FLEX. <br><br /><br><br />Any help will be very much appreciated! <o:p></o:p></p><br /><br /><div class=MsoNormal><br /><br /><hr size=2 width=200 style='width:150.0pt' align=left><br /><br /></div><br /><br /><p class=MsoNormal style='margin-bottom:12.0pt'>View/reply at <a<br />href="http://www.adobeforums.com/webx?13@@.59b69b23">How to receive XML from<br />Flex HTTP POST</a><br><br />Replies by email are OK.<br><br />Use the <a<br />href="http://www.adobeforums.com/webx?280@@.59b69b23!folder=.3c061a83">unsubscribe</a>< br />form to cancel your email subscription.<o:p></o:p></p><br /><br /></div><br /><br /></div>

  • HTTP POST is killing me, please help ...

    Hello,
    I am trying to send an XML file to a php script sitting on a server. I want to do this by HTTP POST through a Java Application.
    I have the following code developed and haven't an iota why the php script won't pick up the XML file.
    If anyone has any idea, suggestions, I will be glad to hear them.
    Random random = new Random();
    final String CONTENT_BOUNDARY = "------------------------" + random.nextInt();
    public String postInvoice(String strFilePathName) {
    HttpURLConnection httpsUrlConnection = null;
    StringBuffer strBuffer = new StringBuffer();
    try {
    // Using the File name passed in, setup FileInputStream Object
    // to be used to get data to write to URL
    File fileToPost = new File(strFilePathName);
    //FileInputStream fis1 = new FileInputStream(fileToPost);
    // Get the actual filename for setting in the form
    String strFileName = fileToPost.getName();
    URL urlPostTo = new URL("http://server/some.php");
    httpsUrlConnection = (HttpURLConnection)urlPostTo.openConnection();
    // Setup RandomAccessFile
    RandomAccessFile rafXML = new RandomAccessFile(strFilePathName, "r");
    httpsUrlConnection.setRequestProperty("REQUEST_METHOD", "POST");
    httpsUrlConnection.setRequestProperty("Accept", "text/xml");
    httpsUrlConnection.setDoOutput(true);
    httpsUrlConnection.setUseCaches(false);
    httpsUrlConnection.setRequestProperty("Content-Type",
    "multipart/form-data");
    Long longTemp = new Long(rafXML.length());
    httpsUrlConnection.setRequestProperty("Content-Length", longTemp.toString());
    PrintWriter pwOut = new PrintWriter (httpsUrlConnection.getOutputStream());
    // Setup a form field
    pwOut.print(CONTENT_BOUNDARY + "\r\n" +
    "Content-Disposition: form-data; name=\"Filename\"; filename=\"" +
    strFileName + "\"\r\nContent-Type: text/xml\r\n\r\n");
    // Send XML contents
    StringBuffer strBufferFile = new StringBuffer();
    long lngFilePointer = 0;
    long lngFileLength = rafXML.length();
    while (lngFilePointer < lngFileLength) {
    String strTemp = rafXML.readLine();
    strBufferFile.append(strTemp);
    lngFilePointer = rafXML.getFilePointer();
    // Write out File Contents
    pwOut.print(strBufferFile.toString());
    pwOut.print("\r\n\r\n" + CONTENT_BOUNDARY + "--\r\n");
    pwOut.flush();
    pwOut.close(); pwOut = null;
    // Once everything is written, call the connect method
    httpsUrlConnection.connect();
    System.out.println("Connected to " + httpsUrlConnection.getURL().getHost());
    BufferedReader br = new BufferedReader(new InputStreamReader(httpsUrlConnection.getInputStream()));
    String strLine;
    while ((strLine = br.readLine()) != null)
    strBuffer.append (strLine);
    strBuffer.append ("\r\n");
    br.close(); br = null;
    System.out.println(strBuffer.toString());
    catch(FileNotFoundException fnfe) {
    System.out.println("FileNotFoundException in HttpPostInvoice : " + fnfe);
    catch (Exception e) {
    System.out.println("Exception in HttpPostInvoice : " + e);
    finally {     
    if (httpsUrlConnection != null) {
    httpsUrlConnection.disconnect();
    return strBuffer.toString();
    }

    Have that application installed and it makes for interesting reading, not sure I understand it all but anyway ..
    Using the code you supplied, this is what is picked up
    POST /some.php HTTP/1.1
    Content-Length: 4844
    User-Agent: Java1.4.0_03
    Host: www.host.com
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-alive
    Content-type: application/x-www-form-urlencoded
    POST http://server/some.php HTTP/1.0
    Content-Type: multipart/form-data; boundary=-------------------------1736247667
    Accept: text/xml
    Connection: keep-alive
    Content-Length: 4595
    Cache-Control: no-cache
    Pragma: no-cache
    -------------------------1736247667
    Content-Disposition: form-data; name="Filename"; filename="3000001193.xml"
    Content-Type: text/xml
    <?xml version="1.0"?><Order> ... </Order>
    -------------------------1736247667--
    Using my original code this is what the app picked up ...
    POST /some.php HTTP/1.1
    Accept: text/xml
    Content-Type: multipart/form-data; boundary=------------------------1514140045
    Content-Length: 4557
    User-Agent: Java1.4.0_03
    Host: www.host.com
    Connection: keep-alive
    ------------------------1514140045
    Content-Disposition: form-data; name="Filename"; filename="3000001193.xml"
    Content-Type: text/xml
    <?xml version="1.0"?><Order> ... <Order>
    ------------------------1514140045--
    I really don't know what to make of it, as far as I can see the request header is ok, with the response being 200. That means the request is ok, but shouldn't the response be 201 indicating that the file was created?
    Am going to look at what a POST through a HTML form sends and match up that way ...

  • HTTP POST Request with XML file in

    Hi @ all,
    I would like to send an HTTP Request with an XML File in the body to an SAP System
    I have the target URL and the a XML File.
    Now the question is. Is it possible to use something like the HTTP_POST FuBa to send an url post request with an xml file?
    If yes can anybody give me a hint?
    I have a php script which exactly do this coding. But to integrate it all in one system it is necessary to transform it into ABAP and call it there.
    // compose url and request and call send function
    function test($productID, $categoryID) {
         // create url
         $PIhost = "XXX.wdf.sap.corp";
         $PIport = "50080";
         $PIurl = "/sap/xi/adapter_plain";
         $PIurl .= "?sap-client=800";
         $PIurl .= "&service=XXX";
         $PIurl .= "&namespace=XXX";
         $PIurl .= "&interface=Frontend_Interface";
         $PIurl .= "&qos=EO";
         $PIurl .= "&sap-user=XXX";
         $PIurl .= "&sap-password=XXX";
         // create xml
         $request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
         $request .="<n1:FrontendInbound_MessageType xmlns:n1=\"http://crmpiebay.com\">\n";
         $request .= "\t<FrontendInbound>\n";
         $request .= "\t\t<ProductName/>\n";
         $request .= "\t\t<ProductCategory>".$categoryID."</ProductCategory>\n";
         $request .= "\t\t<ProductID>".$productID."</ProductID>\n";
         $request .= "\t\t<MessageID/>\n";
         $request .= "\t</FrontendInbound>\n";
         $request .= "</n1:FrontendInbound_MessageType>";
         // send http request
         postToHost($PIhost, $PIport, $PIurl, $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]."/".$_SERVER["PHP_SELF"], $request);
    // send post request to PI server
    function postToHost($host, $port, $path, $referer, $data_to_send) {
      $fp = fsockopen($host, $port);
      if($fp) {
           $res="";
           fputs($fp, "POST $path HTTP/1.1\r\n");
           fputs($fp, "Host: $host\r\n");
           fputs($fp, "Referer: $referer\r\n");
           fputs($fp, "Content-type: text/plain\r\n");
           fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
           fputs($fp, "Connection: close\r\n\r\n");
           fputs($fp, $data_to_send);
           while(!feof($fp)) {
               $res .= fgets($fp, 128);
           fclose($fp);
           return $res;
    Would be great if anybody could give me a hint how to solve such a HTTP Post request with XML body data.
    Thanks in advance.
    Chris
    Edited by: Christian Kuehne on Feb 26, 2009 4:32 PM

    hi friend could you please share your solution regarding this query if u got it already?

  • How to submit both HTTP post and a PDF

    I would like to know how to submit HTTP post and a PDF to a HTTPS web server that will have a php code to parse. Any ideas would be great.
    -Dev

    If you drop a regular button on the form and make it a submit button. In teh Submit panel you can control what is being submitted. One of the options is a PDF and another is an XDP (XML Data Package) where you can control what is in th epackage. One of the options for the package is the completed PDF (base64 encoded). If you use the XDP option you will get all of your data in XML and you will get the completed PDF in a separate node. I believe the node is Chunk. Then you can get the Chunk node an decode it and voila there is your data and completed PDF in a single transmission.

  • One  last try... emulating HTTP POST with applet

    I am trying emulate the HTTP POST method for file uploading using an applet. More specifically, I am trying to upload raw data to a PHP script by making the PHP script think it is receiving a file when in reality all it is receiving is a series of headers, some other necessary info, the data, and a closer. The PHP is then supposed to save the data into a file.
    I have looked at eight or ten threads, explanations, and sample code in this and other forums that deal with this exact same thing, some even specific to PHP, read various documents on and explanations of HTTP headers and so forth, corrected every code error and possible code error I could find, and tried a gazillion variations, but still can't get the PHP script to think that it is receiving a file.
    As far as I can tell, communication with the server is being established, the server is receiving info and sending responses back, the PHP script is defrinitely being activated to do its thing, but the PHP is not recognizing anything that looks like a file or even a file name to it.
    The following information may be relevant:
    The PHP works perfectly with real files uploaded from real HTML pages.
    The server uses Apache.
    The server has no Java support (shouldn't matter, but otherwise I would be using servlets at that end instead of PHP).
    the applet is in a signed jar, and is trying to store information in the same directory that it came from.
    I am using the Firefox browser (shouldn't matter?) .
    I am hoping that someone knowegeable about this can look at the code below and point our any errors. I've also included the response I get from the server, and the PHP code. If there are no obvious errors, can you think of anything else tthat might be going wrong besides the code itsef?
    Please don't suggest I try alternate means of doing this or grab some working code from somewhere. I may very well wind up doing that, but I'm a stubborn bastard and want to find out what the #^%R$($ is going wrong here!!!
    Here is the latest incarnation of the applet code: All it does is immediately try to send some text to the PHP script in such a way that the script thinks it is uploading text within a file. it also displays the responses it gets from the server, including what the PHP script sends back.
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    public class test1 extends Applet{
    DataOutputStream osToServer;
    DataInputStream isFromServer;
    HttpURLConnection uc;
    String content = "This is a test upload";
    public void init(){
    try
    URL url = new URL( "http://www.mywebpage.com/handleapplet.php" );
    uc = (HttpURLConnection)url.openConnection();
    uc.setRequestMethod("POST");
    uc.setDoOutput(true);
    uc.setDoInput(true);
    uc.setUseCaches(false);
    uc.setAllowUserInteraction(false);
    uc.setRequestProperty("Connection", "Keep-Alive");
    //uc.setRequestProperty("HTTP_REFERER", "http://applet.getcodebase");
    uc.setRequestProperty("Content-Type","multipart/form-data; boundary=7d1234cf4353");
    uc.setRequestProperty( "Content-length", ( Integer.toString( content.length() ) ) );
    osToServer = new DataOutputStream(uc.getOutputStream());
    isFromServer = new DataInputStream(uc.getInputStream());
    catch(IOException e)
    System.out.println ("Error etc. etc.");
    return;
    try{
    osToServer.writeBytes("------------------------7d1234cf4353\r\nContent-Disposition: form-data; name=\"testfile\"; filename=\"C:testfile.txt\"\r\nContent-Type: text/plain\r\n\r\n");
    osToServer.writeBytes(content);
    osToServer.writeBytes("\r\n------------------------7d1234cf4353--\r\n");
    osToServer.flush();
    osToServer.close();
    catch (Exception e) {
    System.out.println(e);
    System.out.println("did not sucessfully connect or write to server");
    System.exit(0);
    }//end catch
    try{
    String fieldName="",fieldValue="";
    for ( int i=0; i<15; i++ )
    fieldName = uc.getHeaderFieldKey(i);
    System.out.print (" " + fieldName +": ");
    fieldValue = uc.getHeaderField(fieldName);
    System.out.println (fieldValue);
    }catch(Exception e){
    System.out.println ("Didn't get any headers");
         try{        
    String sIn = isFromServer.readLine();
                        for ( int j=0; j<20; j++ )
                             if(sIn!=null)
    System.out.println(sIn);
                             sIn = isFromServer.readLine();
    isFromServer.close();
    }catch(Exception e){
              e.printStackTrace();
    }//end AudioUp.java
    Here's the response I get back from the server:
    null: HTTP/1.1 200 OK
    Date: Sun, 03 Apr 2005 18:40:04 GMT
    Server: Apache
    Connection: close
    Transfer-Encoding: chunked
    Content-Type: text/html
    null: HTTP/1.1 200 OK
    null: HTTP/1.1 200 OK
    null: HTTP/1.1 200 OK
    null: HTTP/1.1 200 OK
    null: HTTP/1.1 200 OK
    null: HTTP/1.1 200 OK
    null: HTTP/1.1 200 OK
    null: HTTP/1.1 200 OK
    null: HTTP/1.1 200 OK
    <html>
    <head>
    <title>Handling uploaded files from an applet, etc.</title>
    </head>
    <body>
    No file was uploaded.
    </body>
    </html>
    The <html> and the "No file uploaded" message is simply what the PHP script sends back when it does not detect any uploaded file.
    Here is the PHP code on the server:
    <html>
    <head>
    <title>Handling uploaded files from an applet, etc.</title>
    </head>
    <body>
    <?php
    if ($testfile)
    print "The temporary name of the test file is: $testfile<br />";
    $uplfile=$testfile_name;
    $uplfile=trim($uplfile);
    print "The filename is: $uplfile<br />";
    if ($uplfile)
    copy ($testfile, "$testfile_name");
    unlink ($testfile);
    }else{
    print "No file was uploaded.";
    ?>
    </body>
    </html>

    xyz's sample code didn't work - PHP doesn't like the getallheaders line at all. I'm going back to the manual now.
    I had another thought. When I first started using PHP, I had problems with ordinary text field uploads from web pages because somewhere in the process, extra blank lines or spurious carriage returns were being inserted into the strings. For example, if I had a place where people could enter their name, password, and brief message, and tried to store the incoming strings in an array, I'd wind up with some thing like:
    name
    password
    brief message
    instead of:
    name
    password
    brief message
    Which played havoc when trying to read out information by counting lines.
    Anyway, the problem was solved by using the trim($string) function on all incoming strings, which I now do as a matter of course. I never could figure out why it was happening though.
    Do you think something like that could be happening here?? I mean, if spurious blank lines or carriage returns were being inserted where they shouldn't be, could that be screwing things up in this way? HTTP seems to insist on having new lines and blank lines inserted in just the right places.

  • Cargar datos servidor HTTP POST

    Hola,
    Estoy intentando añadir datos a un web, pero no tengo experiencia en estos temas en labview.
    Me han comentado que tengo que ingresar los datos asi:
    http://www.optimalfix.com/control/control.php?variable1=1111&variable2=2222&otravariable=cccccc
    He intentando hacerlo con HTTP POST pero no logro que funcione.
    ¿Alguna ayuda?. Gracias.
    ¡Resuelto!
    Ir a solución.

    Haciendo click en el link que indicas, muestra lo siguiente en el internet explorer:
    Las variables enviadas a la base de datos son:
    variable1=1111
    variable2=2222
    otravariable=cccccc
    si esto significa que ya mando los datos, entonces no necesitas hacer un post, cambialo a un GET y en la pagina que tienes que accesar ingresa el link tal como lo indicas ( con los nuevos valores)
    Saludos

  • PHP Shoutbox : stop users posting php code

    hi guys/girls
    can anyone give me an easy way to stop users on my site
    posting php code into a shoutbox.
    i have a shoutbox made up of a normal html form that posts
    their shouts to a mysql database using php.
    at the moment the only validation i have in place is the
    built in form validation dreamweaver8 has which stops
    users posting a blank post. however a user can post php code
    if they know how, which could cause problems.
    thanks
    ted.

    tedrodgers wrote:
    > i dont see how the highlight file function helps me in
    this case? please explain alittle more.
    That suggestion came from "Pro PHP Security". However,
    looking at the
    PHP manual, it should be highlight_string(), not
    highlight_file().
    http://www.php.net/manual/en/function.highlight-string.php
    How would it help? highlight_string() converts PHP code to
    HTML for
    display purposes. Once converted to HTML, it cannot be
    executed or do
    any harm to your website.
    > and what other validation do you suggest?
    Without knowing the details of your application, it's hard to
    say; but
    just checking that the text area isn't blank is no protection
    at all.
    Attackers could post spam or hot link to pornographic images.
    Two simple
    measures would be to pass the content to strip_tags() and/or
    htmlentities().
    http://www.php.net/manual/en/function.strip-tags.php
    http://www.php.net/manual/en/function.htmlentities.php
    David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "Foundation PHP 5 for Flash" (friends of ED)
    http://foundationphp.com/

  • Where does firefox cache the form parameters to be used in the reload event of a page that was the resposne of a HTTP POST request?

    Suppose there is form in a web page and it submits data in HTTP POST method. After submitting the form, if I reload the page [either by the refresh button or back button; whichever applicable], firefox asks permission to resend the form data by saying "To display this page, Firefox must send information that will repeat any action...". Now if the user clicks on the resend, firefox resubmits the form data.
    So where does firefox store this from data for such future resending/resubmission?
    Is it possible to retrieve/manipulate those stored form data?

    I thought I'd tried that, as tried lots of other things like encoding URL, but obviously not as this works.
    Thanks for the quick reply.
    We also have an issue with the people results not being able to be refined by Department or Job Title now we have connected the SP2010 farm to use the service applications from a SP2013 farm.
    Any ideas on this?  I've started a new thread as its unrelated though:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/c89d5463-4531-4a28-9586-1f690c7b580d/can-you-refine-people-search-results-using-a-sharepoint-2013-search-service-application-connected-in?forum=sharepointsearch

  • Http post issue in soa suite 11g  with 10g wsdl

    I have 10g process that has http post wsdl as below. When I'm trying to create a project in 11g 11.1.1.4 with same wsdl, getting the following error at building the project. "Error(12,61): Parse of component type files failed, check the adf-config.xml file : "Error at line 34 char 64: Malformed WS Binding port. Missing # between namespace URI and service/port names."
    I'm sure that http post mechanism is changed in 11g, but can you please help what exactly is wrong ?
    <?xml version="1.0"?>
    <definitions name="HTTPPostService"
    targetNamespace="http://services.otn.com"
    xmlns:tns="http://services.otn.com"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
              xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
              xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    >
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    TYPE DEFINITION - List of types participating in this BPEL process
    The BPEL Designer will generate default request and response types
    but you can define or import any XML Schema type and use them as part
    of the message types.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <types>
    <schema attributeFormDefault="qualified" elementFormDefault="qualified"
    targetNamespace="http://services.otn.com"
    xmlns="http://www.w3.org/2001/XMLSchema">
    <element name="Postreq">
    <complexType>
    <sequence>
    <element name="Order_Update_Request">
    <complexType>
    <sequence>
    <element name="ORD_ID" type="string"/>
    <element name="E_MAIL" type="string"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    </element>
    <element name="Postresp">
    <complexType>
    <sequence>
    <element name="Order_Update_Response">
    <complexType>
    <sequence>
    <element name="RETURN_STATUS" type="string"/>
    <element name="MESSAGE_TEXT" type="string"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    </element>
    </schema>
    </types>
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    MESSAGE TYPE DEFINITION - Definition of the message types used as
    part of the port type defintions
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <message name="HTTPPostServiceRequestMessage">
    <part name="payload" element="tns:Postreq"/>
    </message>
    <message name="HTTPPostServiceResponseMessage">
    <part name="payload" element="tns:Postresp"/>
    </message>
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PORT TYPE DEFINITION - A port type groups a set of operations into
    a logical service unit.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- portType implemented by the HTTPPostService BPEL process -->
    <portType name="HTTPPostService">
    <operation name="IScript_Update_Order">
    <input message="tns:HTTPPostServiceRequestMessage" />
    <output message="tns:HTTPPostServiceResponseMessage"/>
    </operation>
    </portType>
    <binding name="HTTPPost" type="tns:HTTPPostService">
    <http:binding verb="POST"/>
    <operation name="IScript_Update_Order">
    <http:operation location="/PSIG/HttpConnector?From=PSFT_XINBOUND&amp;MessageName=ABC_ORD_UPDORDER&amp;MessageType=sync&amp;MessageVersion=v1"/>
    <input>
    <mime:mimeXml part="payload"/>
    <mime:content type="text/xml"/>
    </input>
    <output>
    <mime:mimeXml part="payload"/>
              <mime:content type="text/xml"/>
    </output>
    </operation>
    </binding>
    <service name="HTTPPostService">
    <port name="HTTPPost" binding="tns:HTTPPost">
    <http:address location="http://myserver.mycompany.com"/>
    </port>
    </service>
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PARTNER LINK TYPE DEFINITION
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <plnk:partnerLinkType name="HTTPPostService">
    <plnk:role name="HTTPPostServiceProvider">
    <plnk:portType name="tns:HTTPPostService"/>
    </plnk:role>
    </plnk:partnerLinkType>
    </definitions>

    Can you make sure your helloworld is using adf bindings as mentioned in thread Re: Urgent :: 11g Invoking Composite from Java/From Webservice Proxy

Maybe you are looking for

  • Data loaded in Infocube is not visible in the Reporting

    Hi all, In the info cube, the data is not visible for reporting, How can i make it available for reporting, When i select the Manage option from the context menu of the cube and select the Requests Tab, i get a pop up message that tells " There is an

  • Name of the method.

    Good day, Within a class, the name of the class can bet determined via a call to the "getClass().getName()" method, right ? How do we get the name of the method itself ? ================ class magic { magician () { xx = getClass().getName(); // --> W

  • SETTLEMENT RULE FOR AN ORDER

    How will i know settlement rule for an order is created and assigned to an order type?

  • Download links from AIR app... ?

    I wanted to let users browse my site as a desktop application, but didn't have the time to write an application from scratch. SO tried following trick. Created a simple Adobe AIR application with a single page.  This page redirects to my website and

  • Missing serial number for Photoshop CS2 to complete installation.

    I just downloaded a free copy of Photoshop CS2 and I now need the serial number to be able to complete the installation. Where can I find it?