Multipart HTTP Post
Dear All,
I need to forward a text file (without any conversion or mapping) to the HTTP receiver adapter and create a HTTP POST to an external server. Now the problem is that the HTTP Post is supposed to be a multipart message with 3 different content-types, content-lengths and all of them have to be delimited by a "--BOUNDARY" constant.
I read through a lot of SDN Blogs and HTTP forum post, even setup TCPGATEWAY in order to trace my HTTP output, but just can't come even close to producing this sample HTTP Post:
"POST /hapld/tos/kdwhapltos HTTP/1.1
Host: www.xxx.com
Content-type: multipart/mixed; boundary=BOUNDARY
Content-length: 1040
--BOUNDARY
Content-type: application/x-www-form-urlencoded
Content-length: 140
AppVersion=1.0&AcceptUPSLicenseAgreement=Yes&ResponseType=application/x-xxx-pld&VersionNumber=
V4R1&UserId=useridvalue&Password=passwordvalue
--BOUNDARY
Content-type: application/x-xxx-binary
Content-length: 719
020082 2.0 2002101700000000000010500 000000001*AA0A1754 US
1234567002000001*BA1z1234560100002352 00001+0000000000000010 +000
0000000000000LBS01PRE10 3INUSD000001*CA18ATTENTION
DELIVERY 234 SOME LOCAL ST SO
ME CITY NJ 07652 US12015551212 *PA1z1234560100002352
02+0000010 +0000010
*SA000004
BOUNDARY"
1. Is it even possible to produce that kind of multipart post, using the HTTP adapter with it's header filed, prolog or epilog possibilities? How to insert a "new line" within the prolog string for example?
2. Can anyone who was required to develop a similar complex HTTP post, please provide his solution or any useful tips and links. I've read the SAP Help sites...
Thanks in advance!
Michael
Hi again,
I am using the file adapter and a virtual Inbound Interface and namespace, so that I don't need to define any object within the Repository, but in order to use the java mapping, I need to create an interface-mapping. The interface mapping requires an inbound and outbound interface though.
What I want to achive is polling a text file from a local network folder via the file adapter and forwarding this file without any conversion as an HTTP Post to an external HTTP service. As this receiver service requires a multipart HTTP message, I'm forced to figure out another way to foward the original payload, but modify the HTTP buildup.
Regards
Michael
Similar Messages
-
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. -
Uploading big files via http post to XDB table
Hello,
I ve created a web form for to upload files as blobs to the database using XML DB, DBPS_EPG package and preconfigured DAD.
The issue is that small files (~10kb) are being uploaded ok, but file which is 100K during http post returns connection reset from the server side.
To my opinion there might be some max file size parameter for oracle server to accept during oracle listener tcp connection (as apach has maxrequestlimit).
Is there any workaround for to load large files to the XDB table via webform?
Here is a piece of code:
CREATE USER web IDENTIFIED BY web_upload;
ALTER USER web DEFAULT TABLESPACE XML_DATA;
ALTER USER web QUOTA UNLIMITED ON XML_DATA;
ALTER USER web TEMPORARY TABLESPACE TEMP;
GRANT CONNECT, ALTER SESSION TO web;
GRANT CREATE TABLE, CREATE PROCEDURE TO web;
ALTER SESSION SET CURRENT_SCHEMA = XDB;
BEGIN DBMS_EPG.CREATE_DAD('WEB', '/upload/*'); END;
BEGIN
DBMS_EPG.SET_DAD_ATTRIBUTE('WEB', 'database-username', 'WEB');
DBMS_EPG.SET_DAD_ATTRIBUTE('WEB', 'document-table-name', 'uploads');
DBMS_EPG.SET_DAD_ATTRIBUTE('WEB', 'nls-language', '.al32utf8');
DBMS_EPG.SET_DAD_ATTRIBUTE('WEB', 'default-page', 'upload');
COMMIT;
END;
ALTER SESSION SET CURRENT_SCHEMA = SYS;
CREATE TABLE web.uploads (
name VARCHAR2(256) NOT NULL
CONSTRAINT pk_uploads PRIMARY KEY,
mime_type VARCHAR2(128),
doc_size NUMBER,
dad_charset VARCHAR2(128),
last_updated DATE,
content_type VARCHAR2(128) DEFAULT 'BLOB',
blob_content BLOB
CREATE OR REPLACE PROCEDURE web.upload
AS
url VARCHAR2(256) := 'http://demo.test.com:9090/upload/uploaded';
BEGIN
HTP.P('<html>');
HTP.P('<head>');
HTP.P(' <title>Upload</title>');
HTP.P('</head>');
HTP.P('<body>');
HTP.P(' <h1>Upload</h1>');
HTP.P(' <form method="post"');
HTP.P(' action="' || url || '"');
HTP.P(' enctype="multipart/form-data">');
HTP.P(' <p><input type="file" name="binaryfile" /></p>');
HTP.P(' <p><input type="file" name="binaryfile" /></p>');
HTP.P(' <p><button type="submit">Upload</button></p>');
HTP.P(' </form>');
HTP.P('</body>');
HTP.P('</html>');
END;
CREATE OR REPLACE PROCEDURE web.uploaded (
binaryfile OWA.VC_ARR
AS
BEGIN
HTP.P('<html>');
HTP.P('<head>');
HTP.P(' <title>Uploaded</title>');
HTP.P('</head>');
HTP.P('<body>');
HTP.P(' <h1>Uploaded</h1>');
FOR i IN 1 .. binaryfile.COUNT LOOP
IF binaryfile(i) IS NOT NULL THEN
HTP.P(' <p>File: ' || binaryfile(i) || '</p>');
END IF;
END LOOP;
HTP.P('</body>');
HTP.P('</html>');
END;
/帖子经 anatoly编辑过Welcome to Apple Discussions!
Much of what is available on Bittorrent is not legal, beta, or improperly labelled versions. If you want public domain software, see my FAQ*:
http://www.macmaps.com/macosxnative.html#NATIVE
for search engines of legitimate public domain sites.
http://www.rbrowser.com/ has a light mode that supports binary without SSH security.
http://rsug.itd.umich.edu/software/fugu/ has ssh secure FTP.
Both I find are quick and a lot more reliable than Fetch. I know Fetch used to be the staple FTP program, but it grew too big for my use.
- * Links to my pages may give me compensation. -
Http post from an application with file attachment
Hi ! I didn't know where else to post this message...
I'm trying to make a HTTP POST from an application and upload a file with it. I have no problems with the posting, just that I haven't got any ideas how to get the file uploaded as well. I've been reading loads of examples regarding the topic, and searching older posts the forum here, without any help.
Here's the method i'm using:
// open connections
URL url = new URL ("TheURL");
URLConnection urlConn = url.openConnection();
// We do input & output, without caching
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
// multipart/form-data because we want to upload a file
urlConn.setRequestProperty ("Content-Type", "multipart/form-data");
// Open output stream
DataOutputStream printout = new DataOutputStream (urlConn.getOutputStream ());
// Set the actual content
String content = "upfile=" + System.getProperty("user.dir") + "\\file.ext&";
content += "other_key-value_pairs";
// write the data to stream, and flush it.
printout.writeBytes (URLEncoder.encode(content));
printout.flush ();
printout.close ();
// Get the response.
DataInputStream input = new DataInputStream (urlConn.getInputStream());
FileOutputStream fos=new FileOutputStream("postto.txt");
String str;
BufferedReader bufr = new BufferedReader(new InputStreamReader(input));
// Write response to outputfile
while (null != ((str = bufr.readLine()))) {
if (str.length() >0) {
fos.write(str.getBytes());
fos.write(new String("\n").getBytes());
input.close ();Now, the response here I get from the url i'm posting to is "Failure, no data-file". I've tried many diff methods of writing the file to the stream, but always get the same result.
I need to file attached like it would be when using a HTML form's <input type="file">.
Please help ! This is getting really urgent !String content = "upfile=" + System.getProperty("user.dir") + "\\file.ext&";
content += "other_key-value_pairs";
printout.writeBytes (URLEncoder.encode(content));
printout.flush ();
printout.close ();Actually, what this does is create a request like:
GET /path/to/file/script.language?upfile=/home/user/file.ext&other=params HTTP/1.1
Content-Type: multipart/form-data
-- And other HTTP params --
The file is not actually appended to the request.
I really don't know how Java handles the file upload, but you could do it by hand, like so:
public static void doFileUpload(String url, String filename, Hashtable params) throws IOException {
// Construct the request
String boundary = "----------------------mUlTiPaRtBoUnDaRy";
String request_head = "POST " + url + " HTTP/1.0\r\n" +
"Content-type: multipart/form-data; boundary=" + boundary + "\r\n";
String request_body = boundary + "\r\n\r\nContent-disposition: form-data; name=\"upload\"" +
"\r\n\r\n";
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
int b = -1;
while((b = in.read()) != -1) {
request_body += (char)b;
in.close();
Enumeration keys = params.keys();
while(keys.hasMoreElements()) {
String key = keys.nextElement();
requst_body += "\r\n" + boundary + "\r\n\r\nContent-type: form-data; name=\"key\"\r\n" +
(String)params.get(key);
request_body += "\r\n" + boundary + "--\r\n";
int length = request_head.length() + request_body.length() + "Content-length: \r\n";
String req_length = "Content-length: " + (length + new String("" + length).length()) + "\r\n";
Socket socket = new Socket(url,80);
PrintStream stream = socket.getOutputStream();
stream.print(request_head + req_length + req_body);
// And now an option to read the response, I will omit that...
}Note: I have not tested this code, just wrote it up out of memory. If it does not work, it will propably need some small fixes.
Tuomas Rinta -
Remove charset=utf-8 from HTTP POST
I'm trying to do a HTTP POST via ABAP. The application that I'm posting to does not like the "charset=utf-8" that is in the request. I've been told that I need to remove it. Does anyone know how to do this? I'm not setting this field. SAP is adding this charset automatically.
Here is the request:
POST /hapld/tos/kdwhapltos HTTP/1.1
content-type: multipart/mixed; boundary=BOUNDARY; charset=utf-8
content-length: 2018
host: www.pld-certify.ups.com
user-agent: SAP Web Application Server (1.0;700)
accept-encoding: gzip
sap-trace: 3
--BOUNDARY
Content-type: application/x-www-form-urlencoded
Content-length: 128
AppVersion=1.0&AcceptUPSLicenseAgreement=Yes&ResponseType=application/x-ups-pld&VersionNumber=V4R1&UserId=xxxxxx&Password=xxxxxx
--BOUNDARY
Content-type: application/x-ups-binary
Content-length: 1396
020093 2010071800000006852703500 000000002*AA296007......etc
BOUNDARY
Here is my code:
CALL METHOD cl_http_client=>create
EXPORTING
host = POST_HOST
service = '443'
scheme = '2'
ssl_id = 'ANONYM'
proxy_host = wf_proxy
proxy_service = wf_port
IMPORTING
client = http_client.
http_client->propertytype_logon_popup = http_client->co_disabled.
wf_user = '' .
wf_password = '' .
data: lv_value type string.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = '~request_protocol'
value = 'HTTP/1.1'.
CALL METHOD http_client->request->set_header_field( name = '~server_protocol' value = 'HTTP/1.1' ).
CALL METHOD http_client->request->set_header_field
EXPORTING
name = 'HOST'
value = POST_HOST.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = '~request_uri'
value = POST_URI.
CALL METHOD http_client->request->set_content_type
EXPORTING
content_type = 'multipart/mixed; boundary=BOUNDARY'.
CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
EXPORTING
NAME = 'Accept-Charset'
VALUE = 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'.
CALL METHOD http_client->request->SET_FORMFIELD_ENCODING
EXPORTING
FORMFIELD_ENCODING = http_client->request->CO_ENCODING_URL.
CALL METHOD http_client->request->set_cdata
EXPORTING
data = wf_string
offset = 0
length = rlength.
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CLEAR wf_string1 .
wf_string1 = http_client->response->get_cdata( ).Hi,
I had a similar problem and could resolve it by using APPEND_DATA instead of APPEND_CDATA. Likewise, SET_DATA instead of SET_CDATA might solve the issue for you. The data has to be provided as binary data then.
Regards,
Stefan -
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.
-KenLook at the PostMethod documentation. You need to set the multipart request.
-
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 ... -
How would I do a http post with a xml file
How would I do a http post with a xml file.
I have a url called https://localhost:8443/wss/WSS and the XML file is sent as part of the HTTP POST body.
How would I send this XML file when posting?most people just add feedback to the comments they've asked about already, rather than ignoring all the feedback and making a new post with the exact same information:
http://forum.java.sun.com/thread.jspa?threadID=5247331&messageID=10020973#10020973
If you want to add in an XML file to a POST command, you'd add it just like any other file you'd attach to a post request, especially (if you're request is the same as your last post) if you're just doing a jsp page. I'd do it something like this:
<form method=POST ENCTYPE="multipart/form-data" action="https://rcpdm.mnb.gd-ais.com/Windchill/servlet/IE/tasks/DJK/fcsAddContentComplete.xml">
<H3> File Name </H3>
<input type=file name=filename>
<input type=submit value="Do it!">
</form>Then again, this solution has literally nothing to do with java, and you still need to make sure that your servlet knows what to actually do with that information you're sending it. -
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. -
Upload XML data using XSQL and HTTP Post ?
Upload XML data using XSLQ and HTTP Post: is that possible ?
An xsql contains an <xsql:insert-request table="aTable">
The XML data file follows the ROWSET/ROW paradigm.
What is the HTML form to upload the xml file to the XSQL ?
I tried:
<form action="myXSQL.xsql" method="POST" ENCTYPE="multipart/form-data">
XML data file to upload: <input type="file">
<input type="submit">
</form>
But the answer of myXSQL is:
<xsql-status action="xsql:insert-request" result="No posted document to process" />
Where is the problem ?
Thank you.Hello,
You are posting your XML file as a parameter therefore you should use the <xsql:insert-params/> tag, not the <xsql:insert-request/>. The insert-request can only handle data not posted via a parameter.
Usage:
<form action="myXSQL.xsql" method="GET" ENCTYPE="multipart/form-data">
XML data file to upload: <input type="file" name="myXML">
<input type="submit">
</form>
in combination with
<xsql>
<xsql:insert-params name="myXML" table="your table"/>
</xsql>
2 remarks:
I was not able to succesfully POST the form. The answer was <xsql-status action="xsql:insert-request" result="No posted document to process" />. With GET is was succesfull.
Second, if you use MSInternet explorer 5 or higher use could post the XML directly (not aw parameter) using an ActiveX object.
Regards,
Harm Verschuren -
Interesting! JDeveloper deploy to remote server uses HTTP POST
The documentation clearly mentions that the bpelc ant task only deploys to local server using a file copy. I was wondering how JDeveloper is able to deploy to remote servers. Turns out is just does a HTTP POST of multipart/form-data to upload the BPEL suitcase jar file. Given below is the trace of the POST. Of course, it is all proprietary for now and is not documented. Maybe Oracle can wrap this as a custom ant task?
--Nizam
POST /integration/services/deploy/deployProcess.jsp HTTP/1.1
Host: bpel.server.com:9700
Connection: Keep-Alive, TE
TE: trailers, deflate, gzip, compress
User-Agent: RPT-HTTPClient/0.3-3
BPELDomain: default
BPELPassword: bpel
Accept-Language: en
Accept-Encoding: gzip, x-gzip, compress, x-compress
Content-type: multipart/form-data;boundary=*****
Content-length: 10690
Content-Disposition: form-data; name="upload";BPELDomain="default"; filename="E:\work\MyBPELWS\HelloWorld\output\bpel_HelloWorld_1.0.jar"
PK..
........3................META-INF/....PK..
........3...#............META-INF/MANIFEST.MFManifest-Version: 1.0
Process-GUID: MD5{9d2c0a4b850da042548cc6bdf1c04d68}
Created-By: 1.4.2_06 (Sun Microsystems Inc.)
Process-Id: HelloWorld
Timestamp: 1124360790893
Process-Class: BPEL
Implementation-Package: bpel.p0
Revision-Tag: 1.0
PK..
........3................BPEL-INF/PK..
........3.\.Z............bpel.xml<?xml version="1.0" encoding="UTF-8"?>
<BPELSuitcase guid="MD5{9d2c0a4b850da042548cc6bdf1c04d68}" timestamp="1124360790893" revision="1.0">
<BPELProcess process-impl="bpel.p0.BPEL_BIN" src="HelloWorld.bpel" id="HelloWorld">
<partnerLinkBindings>
<partnerLinkBinding name="client">
<property name="wsdlLocation">HelloWorld.wsdl</property>
</partnerLinkBinding>
</partnerLinkBindings>
</BPELProcess>
</BPELSuitcase>
PK..
........3[...5...5.......build.xml<?xml version="1.0" ?>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Run cxant on this file to build, package and deploy the
HelloWorld BPEL process
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<project name="HelloWorld" default="main" basedir=".">
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Name of the domain the generated BPEL suitcase will be deployed to
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<property name="deploy" value="default" />
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What version number should be used to tag the generated BPEL archive?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<property name="rev" value="1.0" />
<target name="main">
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
the bpelc task compiles and package BPEL processes into versioned BPEL
archives (bpel_...jar). See the "Programming BPEL" guide for more
information on the options of this task.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<bpelc input="${basedir}/bpel.xml" rev="${rev}" deploy="${deploy}" />
</target>
</project>PK..
........3,.JaZ...Z.......graphics.xml<?xml version = '1.0' encoding = 'UTF-8'?>
<graphics>
<partnerlink_locations>
<partnerlink name="client" x="15" y="215" side="left"/>
</partnerlink_locations>
<diagram popupeditor="false" centerzoom="true" validateonload="true" confirmbeforedelete="true" SELECTED_PARTNERLINK_COLOR="0,0,153" SWIMLANE_BACKGROUND="255,255,225" SWIMLANE_DIVIDER_BACKGROUND="236,233,216" GRAPH_BACKGROUND="255,255,255" SELECTED_BORDER_BACKGROUND="204,255,204" CONNECTED_PARTNERLINK_COLOR="204,204,255" CONNECTABLE_PARTNERLINK_COLOR="0,0,255" UNCONNECTED_PARTNERLINK_COLOR="192,192,192"/>
</graphics>
PK..
........3O ..............HelloService.wsdl<definitions
targetNamespace="http://tempuri.org/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:s0="http://tempuri.org/"
xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<import namespace="http://tempuri.org/" location="http://localhost/HelloEnglish/Service1.asmx?WSDL"/>
<plnk:partnerLinkType name="Service1Soap_PL">
<plnk:role name="Service1Soap_Role">
<plnk:portType name="s0:Service1Soap"/>
</plnk:role>
</plnk:partnerLinkType>
</definitions>
PK..
........3.....
......HelloWorld.bpel<!--
// Oracle JDeveloper BPEL Designer
// Created: Fri Aug 05 00:05:52 IST 2005
// Author: nizam
// Purpose: Synchronous BPEL Process
-->
<process name="HelloWorld" targetNamespace="http://xmlns.oracle.com/HelloWorld" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:client="http://xmlns.oracle.com/HelloWorld" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"><!-- ================================================================= --><!-- PARTNERLINKS --><!-- List of services participating in this BPEL process --><!-- ================================================================= -->
<partnerLinks><!--
The 'client' role represents the requester of this service. It is
used for callback. The location and correlation information associated
with the client role are automatically set using WS-Addressing.
-->
<partnerLink name="client" partnerLinkType="client:HelloWorld" myRole="HelloWorldProvider"/>
</partnerLinks><!-- ================================================================= --><!-- VARIABLES --><!-- List of messages and XML documents used within this BPEL process --><!-- ================================================================= -->
<variables><!-- Reference to the message passed as input during initiation -->
<variable name="inputVariable" messageType="client:HelloWorldRequestMessage"/><!--
Reference to the message that will be returned to the requester
-->
<variable name="outputVariable" messageType="client:HelloWorldResponseMessage"/>
</variables><!-- ================================================================= --><!-- ORCHESTRATION LOGIC --><!-- Set of activities coordinating the flow of messages across the --><!-- services integrated within this business process --><!-- ================================================================= -->
<sequence name="main"><!-- Receive input from requestor.
Note: This maps to operation defined in HelloWorld.wsdl
-->
<receive name="receiveInput" partnerLink="client" portType="client:HelloWorld" operation="process" variable="inputVariable" createInstance="yes"/><!-- Generate reply to synchronous request -->
<assign name="Assign_1">
<copy>
<from expression="concat("v1.1: Hello ", bpws:getVariableData('inputVariable','payload','/client:HelloWorldProcessRequest/client:input'))"/>
<to variable="outputVariable" part="payload" query="/client:HelloWorldProcessResponse/client:result"/>
</copy>
</assign>
<reply name="replyOutput" partnerLink="client" portType="client:HelloWorld" operation="process" variable="outputVariable"/>
</sequence>
</process>PK..
........3.....
......HelloWorld.wsdl<?xml version="1.0" encoding="UTF-8"?>
<definitions name="HelloWorld"
targetNamespace="http://xmlns.oracle.com/HelloWorld"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:client="http://xmlns.oracle.com/HelloWorld"
xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/">
.<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.TYPE DEFINITION - List of services participating in this BPEL process
.The default output of the BPEL designer uses strings as input and
.output to the BPEL Process. But you can define or import any XML
.Schema type and us them as part of the message types.
.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
.<types>
..<schema attributeFormDefault="qualified"
...elementFormDefault="qualified"
...targetNamespace="http://xmlns.oracle.com/HelloWorld"
...xmlns="http://www.w3.org/2001/XMLSchema">
...<element name="HelloWorldProcessRequest">
....<complexType>
.....<sequence>
......<element name="input" type="string"/>
.....</sequence>
....</complexType>
...</element>
...<element name="HelloWorldProcessResponse">
....<complexType>
.....<sequence>
......<element name="result" type="string"/>
.....</sequence>
....</complexType>
...</element>
..</schema>
.</types>
.<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.MESSAGE TYPE DEFINITION - Definition of the message types used as
.part of the port type defintions
.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
.<message name="HelloWorldRequestMessage">
..<part name="payload" element="client:HelloWorldProcessRequest"/>
.</message>
.<message name="HelloWorldResponseMessage">
..<part name="payload" element="client:HelloWorldProcessResponse"/>
.</message>
.<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.PORT TYPE DEFINITION - A port type groups a set of operations into
.a logical service unit.
.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
.<!-- portType implemented by the HelloWorld BPEL process -->
.<portType name="HelloWorld">
..<operation name="process">
...<input message="client:HelloWorldRequestMessage" />
...<output message="client:HelloWorldResponseMessage"/>
..</operation>
.</portType>
.<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.PARTNER LINK TYPE DEFINITION
.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
.<plnk:partnerLinkType name="HelloWorld">
..<plnk:role name="HelloWorldProvider">
...<plnk:portType name="client:HelloWorld"/>
..</plnk:role>
.</plnk:partnerLinkType>
</definitions>
PK..
........3..............................META-INF/....PK..
........3...#......................+...META-INF/MANIFEST.MFPK..
........3..........................T...BPEL-INF/PK..
........3.\.Z......................{...bpel.xmlPK..
........3[...5...5.................i...build.xmlPK..
........3,.JaZ...Z.....................graphics.xmlPK..
........3O ........................I...HelloService.wsdlPK..
........3.....
....................HelloWorld.bpelPK..
........3.....
....................HelloWorld.wsdlPK...............&....
*****If anyone is interested, I've created a custom ant taks to leverage this HTTP post for deploying the BPEL suitcase jar to remote servers. We didn't want to use FTP, as we'd have to change permissions on the files.
To do this, I've leveraged the oracle.tip.pc.infra.deploy.DeployRemote class. You just have to pass it the path the the jar, server url (http://host:port/deploy/deployProcess.jsp), domain, and password.
This seems to work fine for us.
-Mike -
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&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 -
Invoking http post from BPEL is not passing parameters
Hi,
I have a simple BPEL process where I am trying to send an xml string in a request
parameter to a servlet. Servlet is pretty simple. It just prints the request parameters and returns. But problem is that I am not getting any request
parameters when I am using http post but everything works fine when using
http get.
Enclosed is the wsdl that I am using.
Any information will be of great help
Thanks
Rajesh
<?xml version="1.0" encoding="utf-8"?>
<definitions
targetNamespace="http://xmlns.oracle.com/OISService"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:client="http://xmlns.oracle.com/OISService"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<types>
<xsd:schema elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/OISService"
xmlns="http://www.w3.org/2001/XMLSchema">
<xsd:element name="header">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="status" type="xsd:string"/>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="responsedata" type="xsd:string"/>
</xsd:schema>
</types>
<message name="SendDataToOISRequestMessage">
<part name="xmldata" element="client:responsedata"/>
</message>
<message name="SendDataToOISResponseMessage">
<part name="payload" element="client:header"/>
</message>
<portType name="SendDataToOIS">
<operation name="process">
<input message="client:SendDataToOISRequestMessage"/>
<output message="client:SendDataToOISResponseMessage"/>
</operation>
</portType>
<binding name="SendDataToOIS" type="client:SendDataToOIS">
<http:binding verb="POST"/>
<operation name="process">
<http:operation location="/Class1"/>
<input>
<mime:mimeXml part="xmldata"/>
<mime:content type="text/xml"/>
</input>
<output>
<mime:mimeXml part="payload"/>
<mime:content type="text/xml"/>
</output>
</operation>
</binding>
<service name="SendDataTOOISService">
<port name="SendDataToOIS" binding="client:SendDataToOIS">
<http:address location="http://localhost:8888/j2ee/servlet"/>
</port>
</service>
<plnk:partnerLinkType name="SendDataToOIS">
<plnk:role name="SendDataToOISProvider">
<plnk:portType name="client:SendDataToOIS"/>
</plnk:role>
</plnk:partnerLinkType>
</definitions>In the bpel you can make a http-binding instead of the default soap-binding.
Maybe this can help you making the call to the servlet/jsp.
Maybe you are looking for
-
I changed my email address for my Apple ID. When I want to use iCloud my iPhone doesn't seem to recognize my new email it keeps asking for my password for my old email. I can't update the new address it keeps defaulting to my old one.
-
Sometimes when I am in the middle of playing an app it closes out right in the middle of it.... that happens on the apps: Parking Mania Free, and also on Instagram... does it just have something to do with the apps or my iPod. I have a 2nd generation
-
Weird characters before the xml start tag on Host
When we load xml generated in Biztalk into an OS/400 Host environment, they always have some weird characters before the declaration (<?xml) causing the host program to fail. The characters look like gibberish from another planet (not really..look li
-
I recently changed my card info, and need to change it on my Creative Cloud membership. When I go to Manage Account, it tells me I have a free membership. I don't understand why, as the Adobe Applications Manager tells me I have 4 days left to update
-
Initilization in DTP's (How it works)
HI, I want to set Delta Loads to my Cube from PSA (PSA-->CUBE) Info Package is full load.... For Deltas i didn't find any Initilisation Option in DTP.... In order to set deltas...do i need to perform my first load to CUBE as Full and Later set it