XML String to XML Document - weblogic.developer.interest.webservices.databinding(Archived)

I need help on pushing the XMLString value to XMLDocument.
String outputXML = "<FL_RESPONSE><DATAFLOW_ID>D20070524_154003818</DATAFLOW_ID><DataSet><Record><name1>Mr. Suresh Jawahar Md Sr.</name1><name2></name2><name3></name3><firm1></firm1><firm2></firm2><firm3></firm3><email1></email1><email2></email2><email3></email3><phone1>(919)549-0270</phone1><phone2></phone2><phone3></phone3><date1></date1><date2></date2><date3></date3><ssn1></ssn1><ssn2></ssn2><ssn3></ssn3><address>2525 Meridian Pkwy Ste 150</address><city>Durham</city><state>NC</state><zip>27713-5244</zip><country>United States</country><unparsed1></unparsed1><unparsed2></unparsed2><unparsed3></unparsed3><unparsed4></unparsed4><unparsed5></unparsed5><unparsed6></unparsed6><unparsed7></unparsed7><unparsed8></unparsed8><unparsed9></unparsed9><unparsed10></unparsed10></Record></DataSet></FL_RESPONSE> "
I am trying to push this value to the FLRESPONSEDocument I have created with the elements and attributes specified above.
Code...
FLRESPONSEDocument flrd = FLRESPONSEDocument.Factory.newInstance();
FLRESPONSE flr = flrd.addNewFLRESPONSE();
byte[] byteArray = outputXML.getBytes();
ByteArrayOutputStream out = new ByteArrayOutputStream(byteArray.length);
try{
out.write(byteArray);
} catch (Exception e)
{ System.out.println("Error");}
try{
flr.save((OutputStream) out);
} catch (Exception e)
{System.out.println("ERRROR");
}
But all I get in "flr" at the end is just ""<FL_RESPONSE> </FL_RESPONSE>" nothing else, what I am doing wrong?

Related

CLOB Data Read

Hi,
We have a table in our oracle database having CLOB datatype as column.This column gets populated from Java application wherein the application reads an excel file from front end into CLOB column.
My requirement is to read this CLOB column from database and insert data into some file(CSV Format). say if excel was read into CLOB with 3 column and 10 rows, then I should also be able to read this column and insert into some file(CSV Format) that has same structure as of excel file.
For this i call the JavaConcurrentProgram.
Can anyone tell me what will i do for this? Any help would be appreciated.
Thanks in advance 
Hi,
Create a VO based on the data base table. In OAF page create table based on the VO. Make data type of item to CLOB for which CLOB view attribute is attached.
Create a button to export data to excel. Refer Developer guide for this.
-Anand 
hi,
i want to store the excel file into Database,that column datatype is CLOB.
For this i write the code like this:
protected String streamToString(String mimeType, InputStream inputStream) throws IOException
{
String result;
System.out.println("mime type is "+mimeType);
// check if this is an Excel spreadsheet
if ("application/vnd.ms-excel".equalsIgnoreCase(mimeType))
{
try {
result = xlsToString(inputStream);
} catch (jxl.read.biff.BiffException ex)
{ // if not, then assume this is an ASCII stream
System.out.println("catch blockk");
inputStream.reset();
result = inputStream.toString();
}
} else
{        
result =inputStream.toString();
}
return result;
}
private final static String CSV_SEPARATOR = ",";
private String xlsToString(InputStream stream)
throws jxl.read.biff.BiffException
{
StringWriter stringWriter = new StringWriter();
BufferedWriter bufferedWriter = new BufferedWriter(stringWriter);
try {
WorkbookSettings ws = new WorkbookSettings();
ws.setLocale(new Locale("en", "EN"));
Workbook w = Workbook.getWorkbook(stream, ws);
// Gets the sheets from workbook
for (int sheet = 0; sheet < w.getNumberOfSheets(); sheet++)
{
Sheet s = w.getSheet(sheet);
Cell[] row = null;
// Gets the cells from sheet
for (int i = 0 ; i < s.getRows() ; i++)
{
row = s.getRow(i);
if (row.length > 0)
{
bufferedWriter.write(formatExcelCell(row[0]));
for (int j = 1; j < row.length; j++)
{
bufferedWriter.write(CSV_SEPARATOR);
bufferedWriter.write(formatExcelCell(row[j]));
}
}
bufferedWriter.newLine();
}
}
bufferedWriter.flush();
}
catch(jxl.read.biff.BiffException ex)
{
throw ex;
}
catch (Exception ex)
{
throw OAException.wrapperException(ex);
}
return stringWriter.toString();
}
suppose i upload the .xlsx file then it stored in database.whenever i want to extract the clob data content that time also it gives the same(ascii string what ever stored in clob data) data.
suppose i upload the .xls file then it gives the error.
error:classcastexception
invalid class :jxl.read.biff.BiffException
please any one can help me
Thanks in advance 
Hi,
file upload in to a table ....
for this your need to create Entity based VO. map to viewinstance and view attribute
write below code in process reqest
FileUploadAMImpl oaapplicationmodule =(FileUploadAMImpl)pageContext.getApplicationModule(webBean);
XXQfeqCustomTestsEOViewVOImpl oav =
(XXQfeqCustomTestsEOViewVOImpl)oaapplicationmodule.findViewObject("XXQfeqCustomTestsEOViewVO1");
oav.executeQuery();
oav.insertRow(oav.createRow());
after file upload user click on save button : write the code in process form request
if(pageContext.getParameter("SaveButton")!=null)
{
FileUploadAMImpl oaapplicationmodule =(FileUploadAMImpl)pageContext.getApplicationModule(webBean);
oaapplicationmodule.getTransaction().commit();
}
Regards,
Chandra 
Hi chandra,
Thanks for ur reply.
I create the EO and VO for file uploading.
I want to upload the file into data base when i clicked on the submit button.So i write the row creation code in PFR.
Actually my requirement is: whenever we upload the file into database(CLOB cloumn) by using the javaconcurrentprogram we convert the clob data content is stroed in .dat file certain path.
for this i write the code like this:
Actuall class+:*
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
if (pageContext.getParameter("go") != null)
{ processFileUpload(pageContext, webBean, am);
}
}
protected void processFileUpload(OAPageContext pageContext, OAWebBean webBean, OAApplicationModule am)
{
// Get hold of the binary fle contents
DataObject fleUploadData = (DataObject)pageContext.getNamedDataObject("fileupload");
if (fleUploadData == null) return;
String fleName = (String)fleUploadData.selectValue(null,"UPLOAD_FILE_NAME");
if (fleName == null) return;
String contentType =(String)fleUploadData.selectValue(null,"UPLOAD_FILE_MIME_TYPE");
BlobDomain uploadedByteStream = (BlobDomain)fleUploadData.selectValue(null,fleName);
if (uploadedByteStream == null) return;
// convert binary fle contents into an ASCII stream
System.out.println("after calling if block");
try {
String inputStream = streamToString(contentType, uploadedByteStream.getInputStream() );
String purposeCode = null;
System.out.println("after calling if block");
System.out.println("store the values in table");
// Store ASCII in the fle in the database
primaryKey = storeStream(inputStream , purposeCode, am);
System.out.println("after calling if block");
System.out.println("the orgid value iss "+(am.getOADBTransaction()).getOrgId());
int orgId = ((OADBTransactionImpl)am.getOADBTransaction()).getOrgId();
// submit the printing request
submitConcurrentProgram(primaryKey, purposeCode, orgId, am.getOADBTransaction().getJdbcConnection());
} catch (IOException ex) {
throw OAException.wrapperException(ex);
} catch (SQLException ex) {
throw OAException.wrapperException(ex);
} catch (RequestSubmissionException ex) {
throw OAException.wrapperException(ex);
}
}
protected String streamToString(String mimeType, InputStream inputStream) throws IOException
{
String result;
System.out.println("mime type is "+mimeType);
// check if this is an Excel spreadsheet
if ("application/vnd.ms-excel".equalsIgnoreCase(mimeType))
{
try {
result = xlsToString(inputStream);
} catch (jxl.read.biff.BiffException ex)
{ // if not, then assume this is an ASCII stream
System.out.println("catch blockk");
inputStream.reset();
result = inputStream.toString();//streamToString(mimeType,inputStream); ////streamToString("ASCII",inputStream);
}
} else
{ // otherwise an ASCII stream
result =inputStream.toString();//streamToString(mimeType,inputStream); ////streamToString("ASCII",inputStream);
}
return result;
}
private final static String CSV_SEPARATOR = ",";
private String xlsToString(InputStream stream)
throws jxl.read.biff.BiffException
{
StringWriter stringWriter = new StringWriter();
BufferedWriter bufferedWriter = new BufferedWriter(stringWriter);
try {
WorkbookSettings ws = new WorkbookSettings();
ws.setLocale(new Locale("en", "EN"));
Workbook w = Workbook.getWorkbook(stream, ws);
// Gets the sheets from workbook
for (int sheet = 0; sheet < w.getNumberOfSheets(); sheet++)
{
Sheet s = w.getSheet(sheet);
Cell[] row = null;
// Gets the cells from sheet
for (int i = 0 ; i < s.getRows() ; i++)
{
row = s.getRow(i);
if (row.length > 0)
{
bufferedWriter.write(formatExcelCell(row[0]));
for (int j = 1; j < row.length; j++)
{
bufferedWriter.write(CSV_SEPARATOR);
bufferedWriter.write(formatExcelCell(row[j]));
}
}
bufferedWriter.newLine();
}
}
bufferedWriter.flush();
}
catch(jxl.read.biff.BiffException ex)
{
throw ex;
}
catch (Exception ex)
{
throw OAException.wrapperException(ex);
}
return stringWriter.toString();
}
private final static String QUOTE_STRING ="\"";
private String formatExcelCell(Cell cell)
{
SimpleDateFormat dateFormatter = new SimpleDateFormat("d-MMM-yyyy");
if (cell == null) return null;
String rowCell = cell.getContents();
// format the date
if ( cell.getType().equals(cell.getType().DATE) )
{
rowCell = dateFormatter.format(((DateCell)cell).getDate());
}
// double each quote
String result = rowCell.replaceAll(QUOTE_STRING, QUOTE_STRING+QUOTE_STRING);
// surround with quotes if comma or quote is present
if (result.indexOf(CSV_SEPARATOR) >0 || result.indexOf(QUOTE_STRING) >0)
{
result = QUOTE_STRING + result + QUOTE_STRING;
}
return result;
}
protected Number generatePrimaryKey(OAApplicationModule am)
{
OAViewObject viewObject = (OAViewObject)am.findViewObject("FileUploadKeyVO1");
viewObject.setMaxFetchSize(1);
viewObject.executeQuery();
return (Number) (viewObject.first().getAttribute("Id"));
}
*public Number storeStream*(String inputStream, String purposeCode,OAApplicationModule am)
{
OAViewObject viewObject = (OAViewObject)am.findViewObject("xxcrmFileUploadVO1");
viewObject.setMaxFetchSize(0);
ClobDomain myClob = new ClobDomain();
myClob.setChars(inputStream.toCharArray());
OARow row = (OARow)viewObject.createRow();
row.setAttribute("FileContents",myClob);
primaryKey = generatePrimaryKey(am);
row.setAttribute("PurposeCode", purposeCode);
row.setAttribute("FileId", primaryKey);
viewObject.insertRow(row);
am.getTransaction().commit();
return primaryKey;
}
public void runProgram(CpContext cpcontext) {
try {
// read parameters
// execute business logic
cpcontext.getReqCompletion().setCompletion(ReqCompletion.NORMAL, "Request Completed Normal");
} catch (Exception ex) {
// report exception
cpcontext.getReqCompletion().setCompletion(ReqCompletion.ERROR, "Error building output fle");
} finally {
cpcontext.releaseJDBCConnection();
}
}
static public Map convertParameters(ParameterList parameterList)
{ Map result = new HashMap();
while( parameterList.hasMoreElements() ) {
NameValueType nameValueType = parameterList.nextParameter();
if (nameValueType.getValue() != null)
{
result.put(nameValueType.getName(), nameValueType.getValue());
}
}
return result;
}
protected void submitConcurrentProgram(Number primaryKey, String purposeCode, int orgId,
Connection connection) throws IOException, SQLException, RequestSubmissionException
{
System.out.println("before getting the output");
System.out.println("after getting the output");
ConcurrentRequest request = new ConcurrentRequest(connection);
Vector param = new Vector();
param.add(primaryKey.stringValue());
param.add(purposeCode);
param.add(String.valueOf(orgId));
int reqId = request.submitRequest("XXNC", "XXNC_FILEWRITE_JAVA", "Print CLOB",null, false, param);
connection.commit();
MessageToken[] tokens = { new MessageToken("REQUEST", String.valueOf(reqId)) };
OAException confrmMessage = new OAException("XXNC",
"XXNC_TEST_MSG",
tokens,
OAException.CONFIRMATION,
null);
throw confrmMessage;
}
}
_+*JavaconcurrentProgram class:*+_
/* for getting the clob data content stored into certain path*/
public String getOutput(Connection connection,
BigDecimal primaryKey) throws SQLException,
IOException
{
String statement =
"select file_contents from xxcrm_file_upload where file_id = :1";
String result;
PreparedStatement stmt = null;
ResultSet resultSet = null;
try
{
stmt = connection.prepareStatement(statement);
stmt.setBigDecimal(1, primaryKey);
resultSet = stmt.executeQuery();
resultSet.next();
result = //streamToString("application/vnd.ms-excel",resultSet.getAsciiStream(1));
resultSet.getAsciiStream(1).toString(); //streamToString("ASCII",resultSet.getAsciiStream(1) );
File data = new File("/u01/VIS/apps/apps_st/appl/xxnc/12.0.0/bin/TestClob.dat");
Reader reader = resultSet.getCharacterStream(1);
FileWriter writer = new FileWriter(data);
char[] buffer = new char[1];
while (reader.read(buffer) > 0) {
writer.write(buffer);
}
writer.close();
resultSet.close();
resultSet = null;
stmt.close();
stmt = null;
} finally
{
if (resultSet != null)
{
try
{
resultSet.close();
} catch (SQLException ex)
{
}
}
if (stmt != null)
{
try
{
stmt.close();
} catch (SQLException ex)
{
}
}
try
{
connection.commit();
} catch (SQLException ex)
{
}
}
return result;
}
public void runProgram(CpContext cpcontext)
{
Number primarykey = 0;
String s = cpcontext.getProfileStore().getProfile("APPS_FRAMEWORK_AGENT");
if (!s.endsWith("/"))
{
s = (new StringBuilder()).append(s).append("/").toString();
}
s = (new StringBuilder()).append(s).append("OA_MEDIA").toString();
Connection con = cpcontext.getJDBCConnection();
ReqCompletion lRC = cpcontext.getReqCompletion();
try
{
// Connection con = DriverManager.getConnection("jdbc:oracle:thin:#erpdb.nalsoft.net:1521:VIS","apps","visdb_234");
PreparedStatement st =
con.prepareStatement("select file_id from xxcrm_file_upload order by file_id desc");
ResultSet rs = st.executeQuery();
OutFile lOF = cpcontext.getOutFile();
LogFile lLF = cpcontext.getLogFile();
if (rs.next())
{
primarykey = rs.getBigDecimal(1);
}
BigDecimal primarybig = new BigDecimal(primarykey.toString());
s = getOutput(con, primarybig);
lOF.write(s);
lRC.setCompletion(ReqCompletion.NORMAL, "Request Completed Normal");
} catch (Exception e)
{ //Catch exception if any
System.err.println("Error: " + e.getMessage());
lRC.setCompletion(ReqCompletion.ERROR, e.toString());
} finally
{
cpcontext.releaseJDBCConnection();
}
}
Please give me the suggestion. 
Hi All,
Please any one can give me the suggestion urgently.I have some urgent requirement.

Use custom properties for User object- How To?

Hi everyone, I have created "Full Name" property and I have added it to User object. Unfortunately I don't know it's property ID to obtain it. Is there anyone who have any idea or code fragment?
I have made the following Query:
<pre>
......
               new Object[]{new Integer(PT_PROPIDS.PT_PROPID_NAME)},
               new Object[]{new Integer(PT_FILTEROPS.PT_FILTEROP_CONTAINS)},
               new Object[]{searchText}};
.....
IPTQueryResult queryResult = userManager.Query(PT_PROPIDS.PT_PROPID_ALL, folder, PT_PROPIDS.PT_PROPID_NAME, 0, maxresults, vQueryFilter);
          int[] properties = queryResult.Columns();
          
          for(int i =0,length = queryResult.RowCount();i<length;i++){
               htmlElements.AddInnerHTMLString("<tr>");
               
               htmlElements.AddInnerHTMLString("<td>");
               htmlElements.AddInnerHTMLEncodedString(""+i);
               htmlElements.AddInnerHTMLString("</td>");
               for(int j=0;j<properties.length;j++){
                    
                    htmlElements.AddInnerHTMLString("<td>");
                    htmlElements.AddInnerHTMLString(queryResult.ItemAsString(i, properties[j]));
                    htmlElements.AddInnerHTMLString("</td>");
               }
               htmlElements.AddInnerHTMLString("</tr>");
               //listProp.add(LookupProperty(-1, "Full Name", queryResult));
//               htmlElements.AddInnerHTMLString("<br>"+LookupProperty(properties, "", queryResult));
          }
</pre>
Unfortunately it does not display all custom properties I've made :(
I'll appreciate any help! 
BTW is there any chance to obtain all users' IDs from IPTQueryResult or not only via this class? 
Does PT_PROPIDS.PT_PROPID_ALL actually work in this as far as a props to return argument? I never thought of trying that... I've always tried throwing in an array of the exact properties I'm looking for.
Don't consider me a very good source of info on search, but I did have issues with the native api and the remote api when trying this. In specific cases I just couldn't figure out how to get them to behave as I wanted - specifically around intrinsic properties for remote and custom properties for the native api. Ala the issue you're having. Wound up doing something like this...
Dim customProperties As IExtendedData = queryObject.GetExtendedData()
Me.lblUserName.Text = customProperties.GetStringValue(ConfigurationSettings.AppSettings("USERFIRSTNAMEPROPERTY"))
where I had a setting to refer to the ALUI internal name for the property - ala ...
<add key="USERFIRSTNAMEPROPERTY" value="First Name" />
That's remote API, though.
Did you try the code share - check out the sample search code from that developer seminar a few months back? They had some nice examples in there. 
Well, what I'm exactly trying to do is to use Server API because in a adaptive tag there are difficulties using the EDK. I found that EOD example in UICI package has one method called
LookupProperty(int nPropID, String strPropertyName, IPTQueryResult _qr)
..which can obtain a property value by it's name. For instance
LookupProperty(-1, "Full Name", queryResult)
And in this case Full Name is custom property, which I have already made.
It is funny beacuse in EOD example when I try to retrieve this "Full Name" property it works, when I use LookupProperty method in my code , it does return null value all the time :( 
Hi,
Below are 2 Java methods to query all User properties and some particular property (include custom) through EDK 5.3.0 and G6:
     public void getAllUserProperties() {
          System.out.println("********* getAllUserProperties ********** ");
          IObjectManager objUserMgr = (IObjectManager) remoteSession
                    .getObjectManager(ObjectClass.User);
          IObjectQueryRow objectQueryRow = null;
          try {
               objectQueryRow = objUserMgr.querySingleObject(userId);
               Enumeration data = objectQueryRow.getExtendedData().getNames();
               String propertyName = "";
               String propertyValue = "";
               while (data.hasMoreElements()) {
                    propertyName = data.nextElement().toString();
                    try {
                         propertyValue = (String) objectQueryRow.getExtendedData()
                                   .getValue(propertyName);
                         System.out.println(propertyName + ":" + propertyValue);
                    } catch (Exception ex) {
                         System.out.println(propertyName + " is not a string");
                    }
               }
          } catch (PortalException e) {
               System.out.println(e.getMessage());
          } catch (MalformedURLException e) {
               System.out.println(e.getMessage());
          } catch (RemoteException e) {
               System.out.println(e.getMessage());
          }
     }
     public void getUserProperty() {
          System.out.println("********* getUserProperty ********** ");
          IObjectManager objUserMgr = (IObjectManager) remoteSession
                    .getObjectManager(ObjectClass.User);
          IObjectQueryRow objectQueryRow = null;
          try {
               objectQueryRow = objUserMgr.querySingleObject(userId);
               String propertyName = "Name";
               String propertyValue;
               Object propertyValue1 = null;
               propertyValue = objectQueryRow.getExtendedData().getStringValue(propertyName);
               System.out.println(propertyName + ":" + propertyValue);
               propertyName = "Created";
               propertyValue1 = objectQueryRow.getExtendedData().getValue(propertyName);
               System.out.println(propertyName + ":" + propertyValue1);
          } catch (PortalException e) {
               System.out.println(e.getMessage());
          } catch (MalformedURLException e) {
               System.out.println(e.getMessage());
          } catch (RemoteException e) {
               System.out.println(e.getMessage());
          }
     } 
These methods are similar to the example EOD, but the problem is that I don't wanna use SingleObject query, because I don't know users ID's. The problem is that I don't know my Custom property's ID to put it in a filter like the following one:
               vQueryFilter = new Object[][] {
                         new Object[] { new Integer(PT_PROPIDS.PT_PROPID_OFFICE)},
                         new Object[] { new Integer(PT_FILTEROPS.PT_FILTEROP_EQ_NOCASE)},
                         new Object[] { officeName} };
          
IPTQueryResult queryResult = userManager.Query(
                    PT_PROPIDS.PT_PROPID_OBJECTID, folder,
                    PT_PROPIDS.PT_PROPID_NAME, 0, -1, vQueryFilter);
So the problem comes from OFFICE property ID which I Don't know.

how to pass an array back to CO

hello
presently i have this in my Impl.java file that is called by my controller (narrowed down for space)
public void ZipDashConfirmMethod (String pZip1,String pLocation)
{  System.out.println("AM ZIP " + pZip1 );
Number z1number = null; Number z2number = null; Number z3number = null;
Number z4number = null; Number z5number = null; Number z6number = null;
Number z7number = null; Number z8number = null; Number z9number = null;
Number z10number = null;
ArrayList al= new ArrayList();
if ( pZip1.length() == 4)
{   String zc1_1  = pZip1.toString().substring(0,1); String zc2_1  = pZip1.toString().substring(1,2);       String zc3_1  = pZip1.toString().substring(2,3);
String zc4_1 = pZip1.toString().substring(3,4);
try{z1number  = new Number(zc1_1);} catch (Exception e) { al.add(new OAException("Invalid Dash Placement In " + pLocation + " Zip Code")); }
try{z2number  = new Number(zc2_1);} catch (Exception e) { al.add(new OAException("Invalid Dash Placement In " + pLocation + " Zip Code")); }
try{z3number  = new Number(zc3_1);} catch (Exception e) { al.add(new OAException("Invalid Dash Placement In " + pLocation + " Zip Code")); }
try{z4number  = new Number(zc4_1);} catch (Exception e) { al.add(new OAException("Invalid Dash Placement In " + pLocation + " Zip Code")); }
//OAException.raiseBundledOAException(al);
}
OAException.raiseBundledOAException(al);
}
This java class is called by my mainCO (this is called twice for zip1 and zip 2)
.....
if (z1.getValue(pageContext) !=null )
{
String zip1_d = z1.getValue(pageContext).toString();
String paramZip1DashConfirm = zip1_d;
Serializable zip1DashConfirmParamList[] = { paramZip1DashConfirm,"ORG RPT CODE"};
personam.invokeMethod("ZipDashConfirmMethod", zip1DashConfirmParamList);
}
........
what i am trying to do is have all my errors called at one time. so if i have 2 mistake in zip 1 and 1 in zip 2, i will get the first 2 error messages shown when i hit the commit button and then when i hit the commit button again i will get the 3rd err message calle then. i want all 3 to be shown at one time.
i understand that the void doesnt return a value back. i have tried to change the void and searched the internet, but can i change void to array, pass it back into a variable in the CO and then display them at one time. i have tried String Array but keep getting error when compiling
what is the best way accomplish this.
thanks
james 
Hi,
you can also call the Application module methods directly from the controller by type casting with your AMImpl
XXXAMImpl am = (XXXAMImpl)pageContext.getApplicationModule();
ArrayList al = am.ZipDashConfirmMethod(............);
// make your method return array list public ArrayList ZipDashConfirmMethod (String pZip1,String pLocation)
--Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

HTTPS Post not working in OAF Page

Hi All,
I have created one OAF Page, On clicking of button i am doing following,
//--------------------------------------------------------
private static String contactService(String xmlInputString) throws Exception{          
String outputStr = null;
OutputStream outputStream = null;
try {
URL url = new URL("https://wwwcie.ups.com/ups.app/xml/ShipConfirm");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
System.out.println("Client established connection with " + url.toString());
// Setup HTTP POST parameters
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
outputStream = connection.getOutputStream();
outputStream.write(xmlInputString.getBytes());
outputStream.flush();
outputStream.close();
System.out.println("Http status = " + connection.getResponseCode() + " " + connection.getResponseMessage());
outputStr = readURLConnection(connection);
System.out.println("Response..."+outputStr);
} catch (Exception e) {
System.out.println("Error sending data to server....."+e.getMessage());
throw e;
} finally {                                            
if(outputStream != null){
outputStream.close();
outputStream = null;
}
}
return outputStr;
}
//----------------------------------------------------
public static String readURLConnection(URLConnection uc) throws Exception {
StringBuffer buffer = new StringBuffer();
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(uc.getInputStream()));
int letter = 0;
reader.readLine();
while ((letter = reader.read()) != -1){
buffer.append((char) letter);
}
reader.close();
} catch (Exception e) {
System.out.println("Could not read from URL: " + e.toString());
throw e;
} finally {
if(reader != null){
reader.close();
reader = null;
}
}
return buffer.toString();
}
Now when i am running this from Local JDEVELOPER it is running fine, but when when depolyed on the server , then when i click on button then page gets hanged and it is not doing anything.
Is there any setting do i need to do in APPS environment. or anyone had did the same. any help will be appriciated.
Thanks,
Vijay Chavan 
any one has any idea? please 
Hi,
If your code works fine in JDev and it doesn't work on instance then you can raise SR with Oracle for Ptoduct JDeveloper.
Regards,
Reetesh Sharma

Uploading files to OCS Server from OAF page

Hi All,
My requirement is to upload files to OCS server from OAF page.
I am able to upload files to any folder in EBS using following code.
But i am not able to upload files to OCS server.
I tried to establish a webdav connection for that, but not working.
String fileuploadBeanId="fileUpload";
try{
davconnection = DAVConnectionManager.getUserDAVConnection(pageContext, "https://doc.ocsserver.com/dev/Intranet/ERP/PLM/Current");
}
catch(Exception e2)
{
e2.printStackTrace();
System.out.println("Error establishing connection");
}
String server_dir_path="https://doc.ocsserver.com/dev/Intranet/ERP/PLM/Current";
DataObject fileUploadData =
(DataObject) pageContext.getNamedDataObject(fileuploadBeanId);
if(fileUploadData!=null)
{
String uFileName =
(String) fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
String contentType =
(String) fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
File file = new File(server_dir_path, uFileName);
FileOutputStream output = null;
InputStream input = null;
try
{
output = new FileOutputStream(file);
BlobDomain uploadedByteStream =
(BlobDomain) fileUploadData.selectValue(null, uFileName);
input = uploadedByteStream.getInputStream();
for (int bytes = 0; bytes < uploadedByteStream.getLength(); bytes++)
{
output.write(input.read());
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (input != null)
{
input.close();
}
if (output != null)
{
output.close();
output.flush();
}
}
catch (Exception ez)
{
ez.printStackTrace();
}
}
}
Please share your thoughts.
Thanks
-jyothi- 
Hi Jyothi,
I worked on similar type of requirement three years ago so didn't remember exactly. To upload to server path, I used double slash (//) instead of one (//oracle//apps//po//..). For local machine one slash is enough between folders.
Try this, if it works then fine.
Thanks,
Venkat.Y

Categories

Resources