HTTP POST 411 Error
I am sending data from a MIDlet to a PHP script. The MIDlet code is:
private static HttpConnection connection;
private static OutputStream outS = null;
String theUrl = "http://www. ..... abc.php";
String dataMsg = "data=" + ... etc. ;
int rc;
byte[] dataBytes = dataMsg.getBytes();
connection = (HttpConnection)Connector.open(theUrl);
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", Integer.toString( dataBytes.length ) );
outS = connection.openOutputStream();
outS.write(dataBytes);
outS.flush();
rc = connection.getResponseCode();
I have MIDlet-Permissions: javax.microedition.io.Connector.http set up, and configuration is set to MIDP-1.0 and CLDC-1.0 in WTK 2.0. I'd like people to be able to download this onto any Java phone, hence the lowest common demoninator approach.
The PHP code is pretty basic:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
$putname = "superglobals";
$data = $_POST['data'];
echo "$putname,$data";
$fp = fopen('abc/data.txt', 'a');
fwrite($fp, "$data\n");
fclose($fp);
?>
</body>
</html>
This works fine on Nokia 6310i, 3510i and LG B2100. But on SonyEricsson k750 and 800 and Motorola L6 I get a 411 error code "Length Required" returned in rc.
Any ideas what's going wrong here?
Thanks
before you send data, the server must know how many bytes you are about to send! -> Length required
Try:
c.setRequestProperty ( "Content-Length" ,
Integer.toString (postmsg.length));
please give feedback!
Similar Messages
-
ERROR request POST returns a 411 error
I have some problems sending a POST request from my midlet:
if i send from 1 to 1448 the servlet takes the content and stores it on a local file
if i send from 1449 to 2000 the servlet takes the content and stores it on a local file up to only 1.41 k (1449 characters) and the emulator takes really long before it returns a "file saved succesfully" message.
if i send above about 2000 characters the servlet returns a 411 error ..
The midlet code is divided in two classes ... the HttpMidlet implements midlet and GUIs classes... whereas the Download class connects in a separate thread
HttpMidlet code
* HttpMidlet.java
* Created on October 23, 2001, 11:19 AM
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
* @author kgabhart
* @version
public class HttpMidlet extends MIDlet implements CommandListener {
// A default URL is used. User can change it from the GUI
private static String defaultURL = "someURL";
// Main MIDP display
private Display myDisplay = null;
// GUI component for entering a URL
private Form requestScreen;
private TextField requestField;
// GUI component for submitting request
private List list;
private String[] menuItems;
// GUI component for displaying server responses
private Form resultScreen;
private StringItem resultField;
String result;
// the "send" button used on requestScreen
Command sendCommand;
// the "exit" button used on the requestScreen
Command exitCommand;
// the "back" button used on resultScreen
Command backCommand;
public HttpMidlet(){
// initialize the GUI components
myDisplay = Display.getDisplay( this );
sendCommand = new Command( "SEND", Command.OK, 1 );
exitCommand = new Command( "EXIT", Command.OK, 1 );
backCommand = new Command( "BACK", Command.OK, 1 );
// display the request URL
requestScreen = new Form( "Type in a URL:" );
requestField = new TextField( null, defaultURL, 100, TextField.URL );
requestScreen.append( requestField );
requestScreen.addCommand( sendCommand );
requestScreen.addCommand( exitCommand );
requestScreen.setCommandListener( this );
// select the HTTP request method desired
menuItems = new String[] {"GET Request", "POST Request"};
list = new List( "Select an HTTP method:", List.IMPLICIT, menuItems, null );
list.setCommandListener( this );
// display the message received from server
resultScreen = new Form( "Server Response:" );
resultScreen.addCommand( backCommand );
resultScreen.setCommandListener( this );
}//end HttpMidlet()
public void startApp() {
myDisplay.setCurrent( requestScreen );
}//end startApp()
public void commandAction( Command com, Displayable disp ) {
// when user clicks on the "send" button
if ( com == sendCommand ) {
myDisplay.setCurrent( list );
} else if ( com == backCommand ) {
// do it all over again
requestField.setString( defaultURL );
myDisplay.setCurrent( requestScreen );
} else if ( com == exitCommand ) {
destroyApp( true );
notifyDestroyed();
}//end if ( com == sendCommand )
if ( disp == list && com == List.SELECT_COMMAND ) {
if ( list.getSelectedIndex() == 0 ) // send a GET request to server
result = sendHttpGet( requestField.getString() );
else // send a POST request to server
//result = sendHttpPost( requestField.getString() );
this.sendHttpPost( requestField.getString() );
//resultField = new StringItem( null, result );
//resultScreen.append( resultField );
//resultScreen.append( result);
//myDisplay.setCurrent( resultScreen );
}//end if ( dis == list && com == List.SELECT_COMMAND )
}//end commandAction( Command, Displayable )
private String sendHttpGet( String url )
HttpConnection hcon = null;
DataInputStream dis = null;
StringBuffer responseMessage = new StringBuffer();
try {
// a standard HttpConnection with READ access
hcon = ( HttpConnection )Connector.open( url );
// obtain a DataInputStream from the HttpConnection
dis = new DataInputStream( hcon.openInputStream() );
// retrieve the response from the server
int ch;
while ( ( ch = dis.read() ) != -1 ) {
responseMessage.append( (char) ch );
}//end while ( ( ch = dis.read() ) != -1 )
catch( Exception e )
e.printStackTrace();
responseMessage.append( "ERROR" );
} finally {
try {
if ( hcon != null ) hcon.close();
if ( dis != null ) dis.close();
} catch ( IOException ioe ) {
ioe.printStackTrace();
}//end try/catch
}//end try/catch/finally
return responseMessage.toString();
}//end sendHttpGet( String )
private void sendHttpPost( String url )
//adding code to run thread call
String contenT = "4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444";//String tempURL = url /*+ "?filename=" + filename */;
Download download = new Download (url, this, contenT);
download.start ();
}//end sendHttpPost( String )
public void setOutput (String result)
result = result.toString();
resultScreen.append( result);
myDisplay.setCurrent( resultScreen );
public void pauseApp() {
}//end pauseApp()
public void destroyApp( boolean unconditional ) {
// help Garbage Collector
myDisplay = null;
requestScreen = null;
requestField = null;
resultScreen = null;
resultField = null;
}//end destroyApp( boolean )
}//end HttpMidletThe Download class:
//class modified by Diego Gullo to implement multi-threaded connections in MIDP
//importing packages
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.midlet.*;
class Download implements Runnable
private String url;
private String contenT;
private HttpMidlet MIDlet;
//private String imageName = null;
private boolean downloadSuccess = false;
//private String downloadResult;
public Download (String url, HttpMidlet MIDlet, String content) //, String imageName)
this.contenT = content;
this.url = url;
this.MIDlet = MIDlet;
//this.imageName = imageName;
* Download the image
public void run ()
try
sendContent (url);
catch (Exception e)
System.err.println ("Msg: " + e.toString ());
* Create and start the new thread
public void start ()
Thread thread = new Thread (this);
try
thread.start ();
catch (Exception e)
* Open connection and download png into a byte array.
private void sendContent (String url) throws IOException
HttpConnection hcon = null;
DataInputStream dis = null;
DataOutputStream dos = null;
StringBuffer responseMessage = new StringBuffer();
// the request body
String requeststring = contenT;
try {
// an HttpConnection with both read and write access
hcon = ( HttpConnection )Connector.open( url, Connector.READ_WRITE );
// set the request method to POST
hcon.setRequestMethod( HttpConnection.POST );
// obtain DataOutputStream for sending the request string
dos = hcon.openDataOutputStream();
byte[] request_body = requeststring.getBytes();
// send request string to server
for( int i = 0; i < request_body.length; i++ ) {
dos.writeByte( request_body[i] );
}//end for( int i = 0; i < request_body.length; i++ )
// obtain DataInputStream for receiving server response
dis = new DataInputStream( hcon.openInputStream() );
// retrieve the response from server
int ch;
while( ( ch = dis.read() ) != -1 ) {
responseMessage.append( (char)ch );
}//end while( ( ch = dis.read() ) != -1 ) {
catch( Exception e )
e.printStackTrace();
responseMessage.append( "ERROR" );
finally {
// free up i/o streams and http connection
try {
if( hcon != null ) hcon.close();
if( dis != null ) dis.close();
if( dos != null ) dos.close();
} catch ( IOException ioe ) {
ioe.printStackTrace();
}//end try/catch
}//end try/catch/finally
// Return to the caller the status of the content
if (responseMessage == null)
//*MIDlet.*/this.setResult ("No content received!");
while (responseMessage == null)
this.sendContent (url);
else
//MIDlet.im = result;
//MIDlet.result = result;
MIDlet.setOutput (responseMessage.toString());
//*MIDlet.*/this.setResult (result);
}Any suggestions to solve the problem???
Thankswe've only deployed on 10.1.3.0.0 so i have not been able to confirm that this is not an issue in 10.1.3.1.0.
even if this has been fixed in 10.1.3.1.0, upgrading may not be an option for us, so we prefer a fix for this in 10.1.3.0.0.
thanks,
ted -
HTTP Post Outbound scenario - Error 110 - Timeouts in SMICM Tracefile
HI There
We have a scenario where we do a HTTP post using the HTTP Plain Adapter to a SMS service provider from a message received from a BW system via RFC, It works perfectly in our development system but we cannot get it working in our production system
In SXI_MONITOR the message fails with the error
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <!-- Call Adapter
-->
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
<SAP:Category>XIAdapter</SAP:Category>
<SAP:Code area="PLAINHTTP_ADAPTER">ATTRIBUTE_CLIENT</SAP:Code>
<SAP:P1>110</SAP:P1>
<SAP:P2 />
<SAP:P3 />
<SAP:P4 />
<SAP:AdditionalText />
<SAP:ApplicationFaultMessage namespace="" />
<SAP:Stack>HTTP client code 110 reason</SAP:Stack>
<SAP:Retry>A</SAP:Retry>
</SAP:Error>
Running a trace in SMICM shows the following in the tracelog
[Thr 4632] IcmConnRollInWP: no need to roll in WP status: ROLLED IN
[Thr 4632] IcmReadFromConn(id=9/140033): request new MPI (0/0)
[Thr 4632] MPI<3018f>19#4 GetOutbuf -1 cb2250 65536 (0) -> 0DE122B0 0
[Thr 4632] NiIRead: hdl 43 recv would block (errno=EAGAIN)
[Thr 4632] NiIPeek: peek for hdl 43 timed out (r; 500ms)
[Thr 4632] NiIRead: raw read for hdl 43 timed out (500ms)
[Thr 4632] IcmReadFromConn: read failed with timeout: 500 -> roll out
[Thr 4632] MPI<3018f>19#5 WriteOOB 00000000 02000000 09000000 01
[Thr 4632] MPI<30190>15#11 ReadOOB 01000000 01000000 2D000000 00 -> 0
[Thr 4632] IcmHandleOOBData: Received data on 1st MPI (seqno: 1, type=1, reason=1): 45/14512/0
[Thr 4632] MPI<3018f>19#10 ReadOOB 01000000 01000000 2D000000 00 -> 0
[Thr 4632] IcmHandleOOBData: Received data on 2nd MPI (seqno: 1, type=1, reason=1): 45/14512/0
[Thr 4632] IcmHandleOOBData: Received context key (type=1, reason=1): 45/14512/0
[Thr 4632] NiWakeupExec: send wakeup signal to 64997 (sock 16992)
[Thr 4632] IcmConnRollOut: connection (id=9/140033) rolled out:
[Thr 4632] CONNECTION (id=9/140033):
used: 1, type: 1, role: 2, stateful: 0
NI_HDL: 43, protocol: HTTP(1)
local host: 200.1.1.100:3405 ()
remote host: 196.30.220.242:80 ()
status: READ_RESPONSE
connect time: 23.07.2008 07:13:10
WP-status: ROLLED OUT (Context: 9, Role: 2)
tid: 45, mode: 0, uid: 14512, roll-reason: ICM_ROLL_NETTIMEOUT
With the following 2 lines ir differs from our development system - this is the point where it goes wrong
[Thr 4632] NiIRead: raw read for hdl 43 timed out (500ms)
[Thr 4632] IcmReadFromConn: read failed with timeout: 500 -> roll out
We have already checked the following between the 2 systems
1. Configuration in Netweaver Administrator is Consistent
2. Communication channel and Mapping is consistent
3. Profile parameters for ICM are consistent
Any ideas as to what this problem could be
Many ThanksHi
after you download the html client.
go to view -> source
and enter the present xiusername & pwd which you using and save.
Enter the below details in http client.
Servername : XIServername
Port : 80<instancenumber>
Client : XI server client number
Server : Sender service (business service or busienss system or integration process...when it comes to the HTTP adapter you need to create the business service that business service name you need to enter )
Interface name : outbound interface name
namespace : name for interface.
If you doing Party scenario enter the Party, Agency and Schema details also else optional.
Enter the Input xml data while enter the input data remove the first xml version line and paste the other data.
click on send message.
check the exchange profile set the httpport or not
check these links
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/66dadc6e-0a01-0010-9ea9-bb6d8ca48cc8
The specified item was not found.
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/http%2bto%2brfc%2bsynchronous%2bscenario%2b-%2bfaqs
HTTP to RFC - A Starter Kit
/people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping
Regards,
Suryanarayana -
Applicatio​n using Http Post... getting error response
Im from Ecuador, and me and other 4 people from the same country are getting this error response when a native java application is trying to make a http post to mydomain.com
The requested URL could not be retrieved:
While trying to process the request:
POST /somedir/more?var1=abc&var2=xyz& HTTP/1.1
Expect: 100-continue
Host: mydomain.com
Content-Length: 40
Content-Type: text/plain; charset=utf-8
Accept: */*
Connection: close
Invalid request. Some aspect of the HTTP Request is nivalid. Possible problems:
Missing or unknwon request method
Missing URL
Missing HTTP Identifier (HTTP/1.0)
Request is too large
Content-Length missing for POST or PUT request
Generated by Blackberry.Internet.Browsing.Service (squd/2.7.STABLE6)
This issue is only happening in my country (Ecuador). I have some friends in Argentina and they have no problems at all. What are the posible causes for this problem?
Message Edited by andufo on 07-09-2009 08:43 PMHi again,
im attaching all the info you request:
What does the program actually do?
Social network (because of the TOS of this forum im not allowed to post project names or urls)
What is it trying to send when you submit a request?
What url is it posting the information to?
Im attaching all this at the end of the post.
Is it the 'exact' same application that works in other countries?
Yeap, the exact same one...
Is it supposed to be useing the Internet Browser?
No, it is a native app. The Browser is not used at all.
Are you on a BlackBerry Enterprise Server?
Im on BIS, all the users use BIS.
Technical details:
1) The app makes an Http Connection (POST) to:
http://mydomain.com/api/call?param1=abc¶m2=xyz
2) This is the Http connection configuration:
httpConnection = (HttpConnection) Connector.open(url);
HttpConnection.POST;
("Content-Type", "text/plain; charset=utf-8");
("Host", 'mydomain.com');
("Content-Length", 100); //depends on sent data
("User-Agent", 'BlackBerry8300... etc');
("Expect", "100-continue");
3) On every country it works fine... on my country i get this error:
The requested URL could not be retrieved while trying to process the request:
POST /app/llamada?param1=abc¶m2=xyz& HTTP/1.1
- Expect: 100-continue
- Host: mydomain.com
- Content-Length: 100
- Content-Type: text/plain; charset=utf-8
- Accept: */*
- Connection: close
Invalid request. Some aspect of the HTTP Request is invalid. Possible problems:
- Missing or unknwon request method
- Missing URL
- Missing HTTP Identifier (HTTP/1.0)
- Request is too large
- Content-Length missing for POST or PUT request
Generated by Blackberry.Internet.Browsing.Service (squid/2.7.STABLE6) -
Error in http post submit in Acrobat 8 and Reader 8
I am having an error when using the submit button via http post in Adobe 8 and Reader 8.
The http post is not properly formed and only submits the name of the first field and all of the values of the form. All the remaining fields names are not submitted.
It works fine however if I use Adobe 7 or Reader 7.
Anyone else have this error.
QuintenI have the same problem with Reader 8. It's a bug. In http request ampersand is missing. Reaser 8 sends:
PAR1=value_of_par1PAR2=value_of_par2PAR3=value_of_par3
but it may be:
PAR1=value_of_par1&PAR2=value_of_par2&PAR3=value_of_par3
Michal -
I am using WebLogic Server 7.0 SP1 with the iPlanet 4.1 WebLogic Plugin. When
I do a HTTP Post from my java applet using URLConnection, I am getting the following
error from the plugin:
[20/May/2003:11:19:13] failure ( 860): for host 199.228.131.177 trying to POST
/WebLogicServer/DSSServer/DSSServlet, wl-proxy reports: IO error reading client
POST data at line
[20/May/2003:11:19:13] failure ( 860): for host 199.228.131.177 trying to POST
/WebLogicServer/DSSServer/DSSServlet, wl-proxy reports: exception occurred: 'READ_ERROR
[os error=0, line 534 of proxy.cpp]: reading client POST data failed'
The applet code is as follows:
URLConnection con = toFetch.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setDefaultUseCaches(false);
con.setUseCaches(false);
con.setRequestProperty("Accept","text/html");
con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
prout = new DataOutputStream (con.getOutputStream ());
prout.writeBytes(postdata);
prout.flush();
prout.close();
The iPlanet access log shows a POST request was received but when the request
is proxied to the WebLogic plugin, the error occurs. I can't tell if this is
a HTTP header problem or a data problem.
Any help would be greatly appreciated.
Thanks,
Ken
I have exactly the same problem when using a URLConnection to post
data. Here's the error I get.
wl-proxy reports: exception occurred: 'READ_ERROR [os error=11, line
534 of proxy.cpp]: reading client POST data failed'
Any advices would be appreciated.
Thanks
CS
"Ken Sands" <[email protected]> wrote in message news:<[email protected]>...
> I am using WebLogic Server 7.0 SP1 with the iPlanet 4.1 WebLogic Plugin. When
> I do a HTTP Post from my java applet using URLConnection, I am getting the following
> error from the plugin:
>
> [20/May/2003:11:19:13] failure ( 860): for host 199.228.131.177 trying to POST
> /WebLogicServer/DSSServer/DSSServlet, wl-proxy reports: IO error reading client
> POST data at line
> [20/May/2003:11:19:13] failure ( 860): for host 199.228.131.177 trying to POST
> /WebLogicServer/DSSServer/DSSServlet, wl-proxy reports: exception occurred: 'READ_ERROR
> [os error=0, line 534 of proxy.cpp]: reading client POST data failed'
>
> The applet code is as follows:
>
> URLConnection con = toFetch.openConnection();
> con.setDoInput(true);
> con.setDoOutput(true);
> con.setDefaultUseCaches(false);
> con.setUseCaches(false);
> con.setRequestProperty("Accept","text/html");
> con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
> prout = new DataOutputStream (con.getOutputStream ());
> prout.writeBytes(postdata);
> prout.flush();
> prout.close();
>
> The iPlanet access log shows a POST request was received but when the request
> is proxied to the WebLogic plugin, the error occurs. I can't tell if this is
> a HTTP header problem or a data problem.
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Ken
-
Error Unexpected end of file from server with HTTP POST
Hi everyone,
I'm coding a simple client to download some information from a local machine in my LAN.
I have to do this with an http post request.
When i try to parse the http response the program catch an exception, this one:
java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(...)
the parameter is a JSON request, and of course the response is a JSON formatted.
i put the http request code:
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpDownloaderThread extends Thread{
private String url;
private String param;
private HttpDownloadListener listener;
private HttpURLConnection connection=null;
private InputStream is;
private OutputStreamWriter wr;
public HttpDownloaderThread(String _url,String param, HttpDownloadListener _listener){
url = _url;
listener = _listener;
this.param=param;
public void run(){
try{
connection=(HttpURLConnection)new URL(url).openConnection();
connection.setRequestMethod("POST");
connection.setReadTimeout(5000);
connection.setRequestProperty("Content-Type", "application/jsonrequest");
connection.setDoOutput(true);
wr = new OutputStreamWriter(connection.getOutputStream());
wr.write(param, 0, param.length());
wr.flush();
int responseCode=0;
System.out.println();
try{
responseCode= connection.getResponseCode();
}catch(Exception e){
e.printStackTrace();
if (responseCode == HttpURLConnection.HTTP_OK){
is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = rd.readLine()) != null) {
System.out.println(line);
closeHttpConnection();
listener.resourceDownloaded(url, null);
else{
closeHttpConnection();
listener.downloadFailed(url, new Exception("Http error: " + Integer.toString(responseCode)));
}catch(Exception e){
e.printStackTrace();
listener.downloadFailed(url, e);
}finally{
public void closeHttpConnection(){
if (is != null){
try{
is.close();
wr.close();
}catch (Exception e){
}finally{
is = null;
wr=null;
if (connection != null){
try{
connection.disconnect();
}catch (Exception e){
}finally{
connection = null;
}there's someone who know's why??
Thanks to everyone :)
Thomas.jole_star wrote:
this problem also happen to me,.So since you provided actually no information about your problem you are going to get exactly the same response.
Please don't hijack old threads. Start your own and provide much much much more information.
I shall lock this thread. -
Error while trying to get an HTTP POST response
Hi everyone,
I'm coding a simple client to download some information from a local machine in my LAN.
I have to do this with an http post request.
When i try to parse the http response the program catch an exception, this one:
java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(...)
the parameter is a JSON request, and of course the response is a JSON formatted.
i put the http request code:
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpDownloaderThread extends Thread{
private String url;
private String param;
private HttpDownloadListener listener;
private HttpURLConnection connection=null;
private InputStream is;
private OutputStreamWriter wr;
public HttpDownloaderThread(String _url,String param, HttpDownloadListener _listener){
url = _url;
listener = _listener;
this.param=param;
public void run(){
try{
connection=(HttpURLConnection)new URL(url).openConnection();
connection.setRequestMethod("POST");
connection.setReadTimeout(5000);
connection.setRequestProperty("Content-Type", "application/jsonrequest");
connection.setDoOutput(true);
wr = new OutputStreamWriter(connection.getOutputStream());
wr.write(param, 0, param.length());
wr.flush();
int responseCode=0;
System.out.println();
try{
responseCode= connection.getResponseCode();
}catch(Exception e){
e.printStackTrace();
if (responseCode == HttpURLConnection.HTTP_OK){
is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = rd.readLine()) != null) {
System.out.println(line);
closeHttpConnection();
listener.resourceDownloaded(url, null);
else{
closeHttpConnection();
listener.downloadFailed(url, new Exception("Http error: " + Integer.toString(responseCode)));
}catch(Exception e){
e.printStackTrace();
listener.downloadFailed(url, e);
}finally{
public void closeHttpConnection(){
if (is != null){
try{
is.close();
wr.close();
}catch (Exception e){
}finally{
is = null;
wr=null;
if (connection != null){
try{
connection.disconnect();
}catch (Exception e){
}finally{
connection = null;
}there's someone who know's why??
Thanks to everyone :)
Thomas.Hi Vincent,
according to your script,it seems like you are trying to connect to Exchange Online?
If so these as to be installed on your computer:
http://go.microsoft.com/fwlink/?LinkId=286152
http://go.microsoft.com/fwlink/p/?linkid=236297
Reboot and run this command as one line:
Set-ExecutionPolicy RemoteSigned
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $LiveCred -Authentication Basic -AllowRedirection
$Import = Import-Pssession $Session -AllowClobber
Import-Module MSOnline -verbose
Connect-MSOLservice -Credential $LiveCred
Hope this helped
Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you. Thank you! Off2work -
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?
thxthis 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. -
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&MessageName=ABC_ORD_UPDORDER&MessageType=sync&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
-
Hi,
for some reason unknown to me whenever I try to send a dom via http Post I get the following error:
org.xml.sax.SAXParseException: The root element is required in a well-formed document.
This is the source code:
package com.cyberrein.payunion.transaction;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
//xml lib
import org.w3c.dom.Document;
import org.w3c.dom.Element;
//weblogic xml lib
import weblogic.apache.xerces.dom.DocumentImpl;
import weblogic.apache.xml.serialize.DOMSerializer;
import weblogic.apache.xml.serialize.XMLSerializer;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
public class Xmltest extends HttpServlet {
//Initialize global variables
public void init(ServletConfig config) throws ServletException {
super.init(config);
//Process the HTTP Request
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Retrieve transaction data from HttpServletRequest.
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
DocumentBuilder db = dbf.newDocumentBuilder();
Document docIn = db.parse(request.getInputStream());
String code = "XX";
String tranID = "000000";
String message = "This Card Is Invalid. Transaction Discontinued";
//Output dom
Document docOut = new DocumentImpl();
Element e = (Element)docOut.createElement("TransactionResponseData");
e.setAttribute("Code", code);
e.setAttribute("TransactionID", tranID);
e.setAttribute("Message", message);
docOut.appendChild(e);
FileOutputStream fos;
fos = new FileOutputStream("/victory");
DOMSerializer serX = new XMLSerializer(fos,null);
serX.serialize(docIn);
DOMSerializer ser = new XMLSerializer(response.getOutputStream(), null);
ser.serialize(docOut);
} catch (Throwable e) {e.printStackTrace();}
//Get Servlet information
public String getServletInfo() {
return "com.cyberrein.payunion.transaction.Xmltest Information";
package com.cyberrein.payunion.transaction;
import org.w3c.dom.*;
import org.apache.xerces.*;
import org.apache.xerces.dom.*;
import org.apache.xerces.parsers.*;
import org.apache.xml.serialize.*;
import org.xml.sax.*;
import java.net.*;
import java.io.*;
public class CardClient {
private String sURI;
public BufferedReader in
= new BufferedReader(new InputStreamReader(System.in));
public CardClient(String serverURI) {
sURI = serverURI;
public Document test(){
Document docIn = null;
try
//XML Document impl
docIn = new DocumentImpl();
//Create the root element
Element t = docIn.createElement("TransactionData");
Element k = docIn.createElement("Payunion.com");
k.appendChild( docIn.createTextNode("North American server") );
t.appendChild(k);
//Set attributes
t.setAttribute("cardnumber", "4444444444444444");
t.setAttribute("amount", "3000.67");
t.setAttribute("name", "tolu agbeja");
t.setAttribute("cvv2", "001");
t.setAttribute("pu_number", "ejs:pupk:23456");
t.setAttribute("expirydate", "0903");
t.setAttribute("address", "100 peachtree industrial");
t.setAttribute("zipcode", "30329");
docIn.appendChild(t);
catch (Throwable te)
te.printStackTrace();
return docIn;
public Document sendRequest(Document doc) {
Document docOut = null;
try {
URL url = new URL("http://" + sURI);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
OutputStream out = conn.getOutputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
XMLSerializer ser = new XMLSerializer( out, new OutputFormat("xml", "UTF-8", false) );
ser.serialize(doc);
while(!br.ready()){}
DOMParser parser = new DOMParser();
parser.parse(new InputSource(br));
docOut = parser.getDocument();
catch (Throwable et)
et.printStackTrace();
return docOut;
public static void main(String []args)
CardClient c = new CardClient("cyber1:7001/xmltest");
try
Document doc = c.sendRequest(c.test());
Element responseMessage = (Element)doc.getElementsByTagName("TransactionResponseData").item(0);
String message = responseMessage.getAttribute("Message");
String tranID = responseMessage.getAttribute("TransactionID");
String code = responseMessage.getAttribute("Code");
System.out.println(message);
System.out.println("");
System.out.println("The Response Code Is: "+code);
System.out.println("");
System.out.println("The Transaction ID Is: "+tranID);
catch(Exception ex)
ex.printStackTrace();
All comments will be appreciated!!Hi, thanks for your reply i knew the FileUplaod was the way forward.
I read topics advising to use the FileUpload and tried the following but it did not seem to work ( i get an HTTP Internal Server error when i try that):
try
DiskFileUpload upload = new DiskFileUpload();
boolean isMultipart = FileUpload.isMultipartContent(request);
if( isMultipart )
List items = upload.parseRequest( request );
Iterator iter = items.iterator();
while( iter.hasNext() )
FileItem fileItem = ( FileItem ) iter.next();
File uploadedFile = new File("myreceivedfile.zip");
fileItem.write( uploadedFile );
}catch (Exception e)
System.out.println("RECEIVER: " + e.getMessage());
Also DiskFileUpload,isMultipartContent and parseRequest have a line going through the middle (horizontal middle).
Edited by: Overmars08 on Jun 23, 2009 5:35 AM
Edited by: Overmars08 on Jun 23, 2009 5:36 AM -
Http post to a url from a WebDynpro (Java) application
Hi,
I want to send http post parameters to a url from a WebDynpro (Java) component. I need to do this to send OCI catalog data back to SAP SRM.
I found this thread:
HTTP Post
which suggests to use the the Suspend plug for this purpose.
<quote>
Sending POST parameters with Web Dynpro Suspend Plugs
1) Define a an additional Suspend Plug parameter (besides 'Url' of type String) with name 'postParams' and of type Map
</quote>
After adding the postParams parameter of type java.util.Map to the Suspend-plug the WebDynpro gives the following error during build:
Outbound plug (of type 'Suspend') 'suspend_plug' may have at most two parameters: 'url' of type 'string' and 'postParams' of type 'Map'.
I use SAP NetWeaver Developer Studio version 7.0.16.
Does someone know a solution? I would highly appreciate it.
Thanks in advance.
EricHi,
Please have a look at this thread,
Pass Table as Input to Adaptive RFC
Regards,
Saravanan K -
POSTING PERIOD ERROR WHILE DOING GR
Dear All,
I am facing error in posting period while doing GR -
1) Posting period 007 2010 is not open - For current date GR
2) Posting only lies in periods 2010/07 and 2010/06 in Company Code - For future date in 2010-08
3) Posting period 006 2010 is not open - For back date GR in 2010-06
Checked T Code MMRV - Ticked - Allow posting in previous per. (Still facing the same error)
Also as per MMRV -
Current period 07 2010
Previous period 06 2010
Last period in prev. year 12 2009
Please guide
VikasHi,
Check on it:-
COGI Posting period error
Re: Error in Opening the Posting Period.
http://www.sap-img.com/sap-sd/movement-type-posting-error-in-delivery.htm
pherasath -
File upload using http-post in OSB
Hi All,
I am trying to upload a file using http-post method in OSB.
I have created a business service pointing to the service url, with http method post.
and calling this business service from a proxy service.
I am unable to send the form data to the business service.
Please let me know how to send trhe form data and the file information.
The error given by Business Service is-
the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is text/plain
Thanks in advance.
Seemant
Edited by: Seemant Srivastava on Oct 12, 2010 12:28 PMHi Anuj,
A sample HTML form code for. Post HTTP service-
<html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>CSV File</title>
</head>
<body>
<form method="post" enctype="multipart/form-data" action="http://xyz/UploadFile">
<table>
<tr>
<td> Feed id </td>
<td><input type="text" name="refid" value="" size="20"></td>
</tr>
<tr>
<td> Username (optional)</td>
<td><input type="text" name="username" value="" size="20"></td>
</tr>
<tr>
<td> Password (optional)</td>
<td><input type="password" name="password" value="" size="20"></td>
</tr>
<tr><td> Select CSV File </td>
<td> <input type="file" name="upload" value="" width="30"/></td>
</tr>
<tr>
<td><input type="submit" name="Ok" value="Go"> <input type="reset" name="reset" value="Reset"> </td>
</tr>
</table>
</form>
</body>
</html>
I need to pass all these information to OSB business service. -
Not able to send message - http post from MII 12.1.4.53 to PI 7.1
Hi ,
Question
u2022 Is there any configuration to set up in MII and PI to do posting to PI as a web service? If YES, please guide.
Situation
u2022 We are with MII version 12.1.4.53 and trying to send message through http post to PI 7.1 server.
u2022 We are getting the following error HTTP 500 Internal Error Issue.
u2022 However we are able to post messages from SOAPUI through the same URL and with the MII system which is running on version 12.1.6.91 and 12.1.9.116
u2022 HTTP Response received as below points to PI Configuration issue.
Error
<SOAP:Fault>
<faultcode>SOAP:Server</faultcode>
<faultstring>Server Error</faultstring>
<detail>
<s:SystemError xmlns:s="http://sap.com/xi/WebService/xi2.0">
<context>XIAdapter</context>
<code>ADAPTER.JAVA_EXCEPTION</code>
<text><![CDATA[
com.sap.aii.af.service.cpa.CPAObjectNotFoundException: Couldn't retrieve inbound binding for the given P/S/A values: FP=senderService;TP=;FS=null;TS=;AN=null;ANS=null;
thanks
RajeshHi Anudeep,
The question isNOT ABOUT the format of the URL which MII should use.
Using the same URL we are able to post the message from other MII versions with in the landscape( MII version 12.1.6 and MII version12.1.9) and through SOAP UI.
500 Internal server error Problem arises when the message is sent through the same URL from MII 12,1.4 Build(53) to PI 7.1 ( we tried https Post, XI Webservice, WebService action blocks)
Question:
Are thre any configuration settings specific to MII version12.1.4 Build 53 which needds to be set in MII to communicate to PI 7.1.
Thanks
Rajesh
Maybe you are looking for
-
TS1389 Manage devices in iTunes -how to add a device to iCloud?
I accidentally removed my laptop from "iCloud - Manage devices in iTunes" in my iTunes account and cannot add it again.
-
A problem with initiating a BPEL process through its web service interface
hi, i am trying to initiate the helloWorld BPEL process through its web service interface. i use a proxy class that i wrote and i use it from J#.net. this is the relevant code part: hello.HelloWorldBinding wsProxy = new hello.HelloWorldBinding(); wsP
-
Material number are same but attribute of materials are different.
What if we have two system connected with APO with similar material numbers but in fact different material in description. I mean, numbers are same but attribute of materials are different. How to address it in APO.....? Regards
-
ORA-00932 (Inconsistent datatype) on BLOB field in a view using Forms 6i
Hi I created a table having a BLOB column and populate it with images and also make queries on that table using form 6i but when I use a view to build a form which built on that table when I try to query I receive the following error : ORA-00932:Inco
-
I wanted to upload some of my photos to costco.. they are MY photos.. I edited with photoshop elements 11... and i cant up load.. HELP... did i do something.. can I even print them.? am i too dang dumb to figure it out.? im frusterated... can you