Parse BufferedReader - urgent
I have been trying to figure out how to parse a String that I receive from a remote server. I receive the String as an InputStream which I then wrap in a BufferedReader.
//make URL connection
//populate requestString
//send requestString to URL connection
// Get response data.
BufferedReader input = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
I have tried the following two ways:
StringTokenizer: expecting a String as input, I cannot pass the BufferedReader.
StreamTokenizer: I can pass the BufferedReader however I have problems when trying to read it. For some reason it is only reading the separators ("=" and "&") and not the text. Here is the code:
StreamTokenizer st = new StreamTokenizer(input);
while (st.nextToken() != -1)
int temp = st.nextToken();
if (st.ttype == -3)
System.out.println(st.sval);
else if (st.ttype == -2)
System.out.println(st.nval);
else if (st.ttype == 10)
continue;
else
System.out.println("Next Token returned "+st.ttype);
Everytime it prints that nextToken() returns 61 and 38 (+ and &). What am I doing wrong? The String looks like "ResultCode=0&ResponseCode=00&AVSResponseCode=N" etc... The information that is important is everything between the & and =, not those symbols themselves.
This is really urgent - I appreciate your help.
OK, I think what is happening here is that my condition in teh while loop is causing the problem. I have:
while (st.nextToken() != -1)
int temp = st.nextToken();
//etc
Therefore the words that are missing are actually being parsed in the while condition, and when I enter the while loop the next Token is in fact the + or &.
How do I check if the StreamTokenizer has reached the end of the stream and there are no more tokens wihtout actually parsing a token?? There is no clear method as there is in StringTokenizer(hasMoreTokens()).
Appreciate any help.
Similar Messages
-
OracleJSP:oracle.jsp.parse.JspParseException Urgent please
Hai,
I deployed my application on OC4J and while i am accesing my application, I got this below mentioned error on browser.Can any body have any clues about this error. I am really struggling hard to get out it.If you have any suggessions,please let me know.
Request URI:/en_US/clubroster.jsp
Exception:
OracleJSP:oracle.jsp.parse.JspParseException: /en_US/roster.jsp: Line # 350, <mp:crresults summaryList="<%=summarylist%>" lang=en_US />
Error: Expecting quoted value, got character: e
Thanks!
Tracy.Hai qlin,
Thanks for you reply.I resolved the issue by putting en_us within quotes.
<mp:crre summaryList="<%=summarylist%>" lang="en_US" />.Thanks again.
Tracy. -
XML PARSING ERREOR (URGENT)
Hi,
i am parsing two xml files,
the parsing is good, no problems
but i want to copy a range from one to another
when i execute the part which copy the rage i get the error message :
org.w3c.dom.DOMException: DOM005 Wrong document at
org.apache.xerces.dom.ParentNode.internalInsertBefore(ParentNode.java:390) at
org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.java:322) at
org.apache.xerces.dom.NodeImpl.appendChild(NodeImpl.java:230) at
org.apache.xerces.dom.RangeImpl.traverseSameContainer(RangeImpl.java:1098) at
org.apache.xerces.dom
any one can help ?
thanksHi,
i am parsing two xml files,
the parsing is good, no problems
but i want to copy a range from one to another
when i execute the part which copy the rage i get the
error message :
org.w3c.dom.DOMException: DOM005 Wrong document at
org.apache.xerces.dom.ParentNode.internalInsertBefore(
ParentNode.java:390) at
org.apache.xerces.dom.ParentNode.insertBefore(ParentNo
de.java:322) at
org.apache.xerces.dom.NodeImpl.appendChild(NodeImpl.ja
va:230) at
org.apache.xerces.dom.RangeImpl.traverseSameContainer(
RangeImpl.java:1098) at
org.apache.xerces.dom
any one can help ?
thanksI'm getting this same error, anyone have any ideas? -
Parsing String(urgent)
I have a value of string type in one table column in database that look like this: a^b^c^d.
The length of every value of 'a', 'b', 'c' and etc are not fixed and is separated by '^'. When building the report,I want to separate the string and show in the report into the following form:
column 1 = a
column 2 = b
column 3 = c
How I can do this????I'm using oracle report builder 6.0.in my openion do this-
- first of all create a 'temp(field1 varchar2(50))' table for output filed.
- write down a pl*sql procedure in 'before report trigger'.
- then just select fields in your data block query from 'temp' table.
declare
xlength number(10);
loop_counter number(10);
xchar varchar2(1);
xnew_string temp.field1%type;
begin
xlength := length('your^string');
loop_counter := 1;
loop
xchar := substr('your^string',loop_counter, 1);
if xchar ='^' then -- this will insert string in table and make xnew_string null to store next string.
insert into temp values(xnew_string);
xnew_string := null;
else --this will store all char in xnew_string.
xnew_string := xnew_string || xchar;
end if;
if Loop_counter = xlength then
exit;
else
loop_counter := loop_counter + 1;
end if;
end loop;
end;
---data block query.
select field1 from temp;
and you will got result as you like. -
BufferedReader.read() probleam
Hi all,
I want to parse bufferedReader by read() method in some method about soket. Something is strange that I can not out the loop, When I use BufferedReader.read() method.
the code is ..
// wait for a connection
Socket remote = s.accept();
int ch;
BufferedReader in = new BufferedReader(new InputStreamReader( remote.getInputStream()));
while ((ch = in.read() > 0)) {
then do something......
I think (ch = in.read() > 0) is not a correct query to out the loop.
but I can not use in.readLine(), because I want to parse xml in the buffer.
thank for any suggestion !I have solved this problem.It's impossible to directly solved it .So use another way to check the xml file. ^--^
-
Need help parsing and large file reading-urgent please
import java.io.*;
import java.lang.String.*;
import java.util.*;
public class ReadFile {
//--------------------------------------------------< main >--------//
public static void main (String[] args) {
ReadFile t = new ReadFile();
t.readMyFile();
//--------------------------------------------< readMyFile >--------//
void readMyFile() {
String line = null;
String dcn = null;
String pfn = null;
String pln = null;
String pdob = null;
String ssd = null;
try {
FileReader fr = new FileReader("C:\\ClaimsData\\ClaimsExtract.txt");
BufferedReader br = new BufferedReader(fr);
line = new String();
while ((line = br.readLine()) != null) {
//A00002314376A5272201102300000000MASARU OKUDA 1933012520050722B101 20051001
//Each line of ClaimsExtract.txt is exactly in above form
// and there are about 1000 such lines
dcn = new String();
pfn = new String();
pln = new String();
pdob = new String();
ssd = new String();
dcn = line.substring(13,24);
pfn = line.substring(32,42);
pln = line.substring(42,57);
pdob = line.substring(57,65);
ssd = line.substring(65,73);
//System.out.println(dcn+" "+pfn+" "+pln+" "+pdob+" "+ssd);
fr.close();
} catch (IOException e) {
// catch possible io errors from readLine()
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
} // end of readMyFile()
} // end of class
java.io.IOException: Stream closed
at sun.nio.cs.StreamDecoder.ensureOpen(StreamDecoder.java:37)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:152)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at ReadFile.readMyFile(ReadFile.java:32)
at ReadFile.main(ReadFile.java:14)
Uh oh, got an IOException error!
I also tried using Tokenizer but some other errors, Please suggest a better approach
urgent , Thanks in Advancei think your while loop has the problem. It's keep continuing to read the next line in the file and doesn't exit even when it reaches the end of file. Therefore it gives you that error. Since you're using variable line as string object hence for the while loop you should've something like this and i would also move the reading next line part just before ending the while loopwhile ( ! line.equals(null) ) {
line = br.readLine();
}//end of while because string object doesn't work for comparing operators == or != so you always have to use string.equlas()
I'm sure that's the reason you're encountering this error, otherwise please specify the line where you're encountring the problem. Next time please use the tags for your code becuase it formats the code nicely and it's easy to read it. Cheers
Message was edited by:
salubadsha -
DOM parsing In Applet (URgent)
Is it possible to implement DOM parsing in Applet?
I am getting classnotfoundException .
I am giving the code below. pl read the code.
Applet.(parserapplet.java)
=========================
import java.io.*;
import java.awt.*;
import java.net.*;
import java.util.*;
import java.applet.*;
import com.security.*;
// for DOM parsing ....
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
public class parserapplet extends Applet
public void init()
public void start()
try
if (Class.forName("com.ms.security.PolicyEngine") != null)
{ // required for IE
PolicyEngine.assertPermission( PermissionID.SYSTEM );
catch (Throwable cnfe)
System.out.println("Policy Engine Exception: " + cnfe);
try
String str = "<?xml
version=\"1.0\"?><html><body></body></html>";
ByteArrayInputStream bis = new
ByteArrayInputStream(str.getBytes());
System.out.println("After creating input stream");
BufferedInputStream bufIn = new BufferedInputStream(new
DataInputStream(bis));
parseXMLMessage (bufIn);
catch(Exception e){}
// Actual DOM parsing goes here.....
public void parseXMLMessage(InputStream xmlMessage)
Document document = null;
DocumentBuilder documentBuilder = null;
DocumentBuilderFactory documentBuilderFactory = null;
try
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilder = documentBuilderFactory.newDocumentBuilder();
document = documentBuilder.parse(xmlMessage);
System.out.println("Document node: " + document);
catch(FactoryConfigurationError fce)
System.out.println("Exception Factory configuration error " + fce);
catch(ParserConfigurationException pce)
System.out.println("Exception Parser configuration Exception " pce);
catch(SAXException saxe)
System.out.println("Exception SAX error " + saxe);
catch(Exception e)
System.out.println("Exception " + e);
Html code:
=========
<html>
<body>
<APPLET code="parserapplet.class" archive = "xalan.jar" width=0
height=0
MAYSCRIPT>
<param name=cabbase value=MyApplet.cab>
</APPLET>
</body>
</html>
I have signed the Applet using signcode utility and i have put the
parserapplet.class in the MyApplet cab file and signed it. On invoking
the html file, it request for permission, and after clicking yes, the
applet loads.Fine.
No problem upto this stage.
But after loading of the applet the following exception is thrown in
Javaconsole.
Exception:
=========
com.ms.security.SecurityExceptionEx[Host]: cannot access file
C:\WINNT\Java\lib\jaxp.properties
at com/ms/security/permissions/FileIOPermission.check
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.checkRead
at java/io/File.exists
at javax/xml/parsers/DocumentBuilderFactory.findFactory
at javax/xml/parsers/DocumentBuilderFactory.newInstance
at parserapplet.parseXMLMessage
at parserapplet.init
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
javax.xml.parsers.FactoryConfigurationError:
java.lang.ClassNotFoundException:
org/apache/crimson/jaxp/DocumentBuilderFactoryImpl
at javax/xml/parsers/DocumentBuilderFactory.newInstance
at parserapplet.parseXMLMessage
at parserapplet.init
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
I dont know which .jar file to archive (i tried xalan,crimson, jaxp
but which of no use). I was surprised why the security Exception is
thrown , when parsing.
I have not accessed the System files!( but it searches for
jaxp.properties file!). I think the jar file is not downloaded. How to
verify that it is downloaded in applet?
The above code is only for sample.
If anybody who knows how to correct it please mail me at:
"[email protected]" with corrected code. I want this very
urgently.
Help meeeeeeeeeeeeeeeeeeee!!!!!
Prasanna.Have you found the answer to this problem? I am having a similar problem when running the parser in an ActiveX Bean.
THanks -
Hi folks,
I have an urgent parsing problem. I developed an app with JDK1.4 and now it needs to run on JDK1.3.1. The problem is this:
If I use the DocumentBuilder.parse() method shipped with JDK1.4 it will parse a document containing namespaces WITHOUT a namespace declaration in the root element. However, since XML support doesn't ship with JDK1.3.1 I need to use JAXP. If I try this with the DocumentBuilder.parse() version shipped with JAXP (latest version) the parse method throws a NullPointerException. If I put the namespace declaration in the document it will parse fine. I tried setting the DocumentBuilderFactory.setNamespaceAware() explicitly to false (should be the default) but no luck. Any ideas other than adding the declaration (long story why I don't want it there...)
thanksexample, with declaration of namespace:
<?xml version="1.0" encoding="UTF-8"?>
<pre:root xmlns:inn="http://blablabla/inn/version/1.0/">
<pre:metadata>
<pre:dublin-core>
<pre:title>mytitle</pre:title>
<pre:description>mydesc</pre:description>
<pre:creator>bjmann</pre:creator>
</inn:dublin-core>
</pre:root>
example, without declaration:
<?xml version="1.0" encoding="UTF-8"?>
<pre:root>
<pre:metadata>
<pre:dublin-core>
<pre:title>mytitle</pre:title>
<pre:description>mydesc</pre:description>
<pre:creator>bjmann</pre:creator>
</inn:dublin-core>
</pre:root>
this may help... -
Javax.xml.parsers Parser Failes at URGENT..URGENT.
Hai,
I am using JAVA PARSER to parse my xml file. My XML file is :
<QUERY>SELECT * FROM EMP WHERE EMP_DATE > 18/10/2000</QUERY>.
My Sample Code is:
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.DOMException;
factory = DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
fistream = new FileInputStream(fileName);
document = builder.parse(fistream);
e=document.getDocumentElement();
curElm = (Element)nodeList.item(0);
return_Value =((Text)curElm.getFirstChild()).getData().trim();
Giving wrong output:
SELECT * FROM EMP WHERE EMP_DATE
Activally, I had to get
SELECT * FROM EMP WHERE EMP_DATE > 18/10/2000.
I do not know what's went wrong ?
Please help me. It is very urgent to my project.
Thanks a lot
Regards
Sureshhi,
<, >, &, " and ' are XML control characters and do not belong to the data an XML document reflects. if you want to use these special characters, try a different notation, i.e. < > & " or ' as in
<element>this is an <element> tag</element>
sincerely, Michael -
Next release date for C++ Parser- URGENT-
What is the next release date for the C++ Parser??
The bug in 2.0.3.0.0 regarding broken DOS filenames is preventing us from shipping a build to Apps that is required next week.
Otherwise what is the most recent C++ build that offers:
a) A fix for entity reference parsing(&apos,")correctly.
b) DOS filename compatibility(i.e c:\cleo.xml).
This is very urgent so your response is much appreciated.
nullIt is scheduled to be released by the end of this week.
Oracle XML Team
null -
Urgently need help for parsing IP header
Hi, could anyone tell which class I should use to parsing the IP header of a packet?
Thanks many many times!> Hi, could anyone tell which class I should use to
parsing the IP header of a packet?
DatagramPacket?
> Urgently need help for parsing IP header
Don't flag your question as urgent, even if it is for you.
* We all answer questions here voluntarily, in our leisure time. We do that because doing so is fun for us, because we enjoy helping people and having interesting discussions. Guess what, it is much less fun if it gets stressful. So the last thing you want to do to get us to answer your question is to pass your stress over to us.
* People who are stressed and want a fast answer often don't even find the time to do the necessary research or to formulate their question in an easy to comprehend way. That's even less fun to work with. So you really don't want us to feel your stress. Instead you want to take your time to write a well formulated post that is fun to answer. The less likely it is for us to know that your question is urgent, the more likely you are to get a fast answer!
* The simple notion that you want your post to be answered faster than those of the other members might feel rather unfair to some of us. Doubly so because often "urgent" questions actually are homework questions. Yours might be different, but someone who had bad experiences with this type of question might not read far enough to notice. -
Very urgent - Parsing stored procedure error !!!
Hi,
We tried to migrate a SQL server 7 database to an Oracle 8.1.7 database using the migration workbench. We had successfully captured the SQL server source model. But
when we tried to create the Oracle model,
the following error occurred for some stored procedure :
"failed to parse procedure text: procedurexxx:
java.lang.StringIndexOutOfBoundsException: String Index out of
range: 0"
This error occured even when we reparse the
stored procedure. What does that mean and what can I do to solve it? As we have to solve this error urgently, your prompt reply
will be highly appreciated.
Thanks
Ivan HuiIvan, we really need a bit more information.
Mail one of the stored procedures to [email protected] and we shall track down the error and, where possible, find a workaround to the problem.
null -
Parsing notepad content separated by pipes...urgent!!
Hi there,
I really need your help guys, I need to read the content of a notepad file and then parse it, specifically it's a string just like this one,
AAA_AAAA.01 | BBB_BBBB.01 BBB_BBBB.02 | BBB_BBBB.03 | CCC_CCCC.01 | DDD_DDDD.01 | DDD_DDDD.02 | DDD_DDDD.03 | DDD_DDDD.04....and so on,
and so far I've got only this code
package tokenizer;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
* @author Henz
public class ThreadParser {
public ThreadParser() {
// Auto-generated constructor stub
* @param args
public static void main(String[] args) {
// Auto-generated method stub
String line;
try {
System.out.print("Enter the path: ");
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String file = stdin.readLine();
BufferedReader sfile = new BufferedReader(new FileReader(file));
File myFile = new File(file);
if (myFile.exists()) {
System.out.println("File founded, preparing parsing...");
} else {
System.out.println("File not founded, verify path...");
while ((( line = sfile.readLine())!= null))
System.out.println(line);
StringTokenizer st = new StringTokenizer(line)//Exactly here I need the string so I can parse it but it returns me a NullPointerEx
while(st.hasMoreTokens())
System.out.println(st.nextToken());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
But I've got only this output
Enter the path: C:\Test.txt
File founded, preparing parsing...
Exception in thread "main" java.lang.NullPointerException
at java.util.StringTokenizer.<init>(StringTokenizer.java.182)
at java.util.StringTokenizer.<init>(StringTokenizer.java.219)
at tokenizer.ThreadParser.main(ThreadParser.java:54)
The question is, what else do I need so I can get this output ,
AAA_AAAA.01
BBB_BBBB.01 BBB_BBBB.02 BBB_BBBB.03
CCC_CCCC.01
DDD_DDDD.01 DDD_DDDD.02 DDD_DDDD.03 DDD_DDDD.04
The main objective is to parse the string above eliminating its pipes and in each line having just the same type prefix words
Regards!I will post the bad part of your code, indented correctly:while ((( line = sfile.readLine())!= null))
System.out.println(line);
StringTokenizer st = new StringTokenizer(line);The first two lines read through the file and copy it to standard output. After they are finished, the "line" variable is null (that's what the "while" does) and then you proceed to try and use it in the third line of code.
In other words, you should surround the code that you want controlled by that "while" by braces. Like this:while ((( line = sfile.readLine())!= null)) {
System.out.println(line);
StringTokenizer st = new StringTokenizer(line);
... and so on
}If you don't do that then only the single line of code after the "while" statement is in the while-loop. -
Urgent: SAX parser bean is not working in JSP page
Hi All,
I have created a bean "ReadAtts" and included into a jsp file using
"useBean", It is not working. I tried all possibilities. But Failed Plz Help me.
Below are the details:
Java Bean: ReadAtts.java
package sax;
import java.io.*;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.util.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.ParserConfigurationException;
public class ReadAtts extends DefaultHandler implements java.io.Serializable
private Vector attNames = new Vector(); //Stores all the att names from the XML
private Vector attValues = new Vector();
private Vector att = new Vector();
private Locator locator;
private static String start="",end="",QueryString="",QString1="",QString2="";
private static boolean start_collecting=false;
public ReadAtts()
public Vector parse(String filename,String xpath) throws Exception
QueryString=xpath;
StringTokenizer QueryString_ST = new StringTokenizer(QueryString,"/");
int stLen = QueryString_ST.countTokens();
while(QueryString_ST.hasMoreTokens())
if((QueryString_ST.countTokens())>1)
QString1 = QueryString_ST.nextToken();
else if((QueryString_ST.countTokens())>0)
QString2 = QueryString_ST.nextToken();
SAXParserFactory spf =
SAXParserFactory.newInstance();
spf.setValidating(false);
SAXParser saxParser = spf.newSAXParser();
// create an XML reader
XMLReader reader = saxParser.getXMLReader();
FileReader file = new FileReader(filename);
// set handler
reader.setContentHandler(this);
// call parse on an input source
reader.parse(new InputSource(file));
att.add("This is now added");
//return attNames;
return att;
public void setDocumentLocator(Locator locator)
this.locator = locator;
public void startDocument() { }
public void endDocument() { }
public void startPrefixMapping(String prefix, String uri) { }
public void endPrefixMapping(String prefix) { }
/** The opening tag of an element. */
public void startElement(String namespaceURI, String localName,String qName, Attributes atts)
start=localName;
if(start.equals(QString2))
start_collecting=true; //start collecting nodes
if(start_collecting)
if((atts.getLength())>0)
for(int i=0;i<=(atts.getLength()-1);i++)
attNames.add((String)atts.getLocalName(i));
attValues.add((String)atts.getValue(i));
/** The closing tag of an element. */
public void endElement(String namespaceURI, String localName, String qName)
end = localName;
if(end.equals(QString2))
start_collecting=false; //stop colelcting nodes
/** Character data. */
public void characters(char[] ch, int start, int length) { }
/** Ignorable whitespace character data. */
public void ignorableWhitespace(char[] ch, int start, int length){ }
/** Processing Instruction */
public void processingInstruction(String target, String data) { }
/** A skipped entity. */
public void skippedEntity(String name) { }
public static void main(String[] args)
String fname=args[0];
String Xpath=args[1];
System.out.println("\n from main() "+(new ReadAtts().parse(fname,Xpath)));
//System.out.println("\n from main() "+new ReadAtts().attNames());
//System.out.println("\n from main() "+new ReadAtts().attValues());
JSP File:
<%@ page import="sax.*,java.io.*,java.util.*,java.lang.*,java.text.*;" %>
<jsp:useBean id="p" class="sax.ReadAtts"/>
Data after Parsing is.....
<%=p.parse"E:/Log.xml","/acq/service/metrics/system/stackUsage")%>
Expected Output:
The jsp file should print all the vector objects from the "ReadAtts" bean
Actual Output:
Data after Parsing.......[]
Thanks for your time.....
Newton
Bangalore. INDIAthe problem is not because of java code insdie jsp page
I have removed all things but the form and it is still not working
here is the modified code:
<!-- add news-->
<%
if(request.getParameter("addBTN") != null){
out.print("addBTN");
%>
<!-- end of add news-->
<form action="" method="post" enctype="multipart/form-data" name="upform" >
<table width="99%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2" align="right" bgcolor="#EAEAEA" class="borderdTable"><p>'6'A) .(1 ,/J/</p></td>
</tr>
<tr>
<td width="87%" align="right"><label>
<input name="title" type="text" class="rightText" id="title">
</label></td>
<td width="13%" align="right">9FH'F 'D.(1</td>
</tr>
<tr>
<td align="right"><textarea name="elm1" cols="50" rows="10" id="elm1" style="direction:rtl" >
</textarea></td>
<td align="right">*A'5JD 'D.(1</td>
</tr>
<tr>
<td align="right"><label>
<input type="file" name="filename" id="filename">
</label></td>
<td align="right">5H1)</td>
</tr>
<tr>
<td align="right"><label>
<input name="addBTN" type="submit" class="btn" id="addBTN" value=" '6'A) .(1 ">
</label></td>
<td align="right"> </td>
</tr>
</table>
</form>
<!-- TinyMCE -->
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple",
directionality : "rtl"
</script>
<!--end of TinyMCE --> -
Urgent: Calling web service from PL/SQl fails with XML parsing
Hi,
I am trying to call a web service from PL/SQL (using SOAP protocol and UTL_HTTP built in Package).I am using Oracle 9i .I am calling from pl/sql block invoking web service method created in java.
I am getting the below response object as a SOAP protocol, but i couldn't able to parse the SOAP.
Could you please provide the values of FirstName, LastName and ErrorDescription
declare
request_env varchar2(32767);
v_xml XMLTYPE;
l_user_first_name varchar2(100);
l_user_last_name varchar2(100);
l_error_value varchar2(100);
begin
response_env:='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<UserInfoObjResponse xmlns:axis2ns1="http://www.test.com/services">
<axis2ns1:FirstName >First Name Output</axis2ns1:FirstName>
<axis2ns1:LastName>Last Name Output</axis2ns1:LastName>
<axis2ns1:ErrorDescription />
</UserInfoObjResponse>
</soapenv:Body>
</soapenv:Envelope>';
dbms_output.put_line('Length of Request:' || length(response_env));
dbms_output.put_line ('Request: ' || response_env);
v_xml := XMLTYPE(response_env);
-- SELECT EXTRACTVALUE(v_xml, '//UserInfoObjResponse/FirstName') INTO l_user_fast_name varchar2(100); FROM DUAL;
dbms_output.put_line ('l_user_first_name: ' || l_user_first_name);
dbms_output.put_line ('l_user_last_name : ' || l_user_last_name);
dbms_output.put_line ('l_error_value: ' || l_error_value);
end;In Oracle 9i:
SQL> declare
2 response_env varchar2(32767);
3 v_xml XMLTYPE;
4 l_user_first_name varchar2(100);
5 l_user_last_name varchar2(100);
6 l_error_value varchar2(100);
7 begin
8 response_env:='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
9 <soapenv:Body>
10 <UserInfoObjResponse xmlns:axis2ns1="http://www.test.com/services">
11 <axis2ns1:FirstName >First Name Output</axis2ns1:FirstName>
12 <axis2ns1:LastName>Last Name Output</axis2ns1:LastName>
13 <axis2ns1:ErrorDescription />
14 </UserInfoObjResponse>
15 </soapenv:Body>
16 </soapenv:Envelope>';
17
18 dbms_output.put_line('Length of Request:' || length(response_env));
19 -- dbms_output.put_line ('Request: ' || response_env);
20
21 v_xml := XMLTYPE(response_env);
22
23 select EXTRACTVALUE(v_xml,'/*:Envelope/*:Body/*:UserInfoObjResponse/*:FirstName/text()') first_name,
24 EXTRACTVALUE(v_xml,'/*:Envelope/*:Body/*:UserInfoObjResponse/*:LastName/text()') last_name,
25 EXTRACTVALUE(v_xml,'/*:Envelope/*:Body/*:UserInfoObjResponse/*:ErrorDescription/text()') error_description
26 into l_user_first_name, l_user_last_name, l_error_value
27 from dual;
28
29 dbms_output.put_line ('l_user_first_name: ' || l_user_first_name);
30 dbms_output.put_line ('l_user_last_name : ' || l_user_last_name);
31 dbms_output.put_line ('l_error_value: ' || l_error_value);
32 end;
33 /
Length of Request:530
l_user_first_name: First Name Output
l_user_last_name : Last Name Output
l_error_value:
PL/SQL procedure successfully completed.In Oracle 10g:
SQL> declare
2 response_env varchar2(32767);
3 v_xml XMLTYPE;
4 l_user_first_name varchar2(100);
5 l_user_last_name varchar2(100);
6 l_error_value varchar2(100);
7 begin
8 response_env:='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
9 <soapenv:Body>
10 <UserInfoObjResponse xmlns:axis2ns1="http://www.test.com/services">
11 <axis2ns1:FirstName >First Name Output</axis2ns1:FirstName>
12 <axis2ns1:LastName>Last Name Output</axis2ns1:LastName>
13 <axis2ns1:ErrorDescription />
14 </UserInfoObjResponse>
15 </soapenv:Body>
16 </soapenv:Envelope>';
17
18 dbms_output.put_line('Length of Request:' || length(response_env));
19 -- dbms_output.put_line ('Request: ' || response_env);
20
21 v_xml := XMLTYPE(response_env);
22
23 select r.*
24 into l_user_first_name, l_user_last_name, l_error_value
25 from XMLTABLE('/' PASSING v_xml
26 COLUMNS
27 first_name varchar2(30) PATH '/*:Envelope/*:Body/*:UserInfoObjResponse/*:FirstName/text()',
28 last_name varchar2(30) PATH '/*:Envelope/*:Body/*:UserInfoObjResponse/*:LastName/text()',
29 error_description varchar2(30) PATH '/*:Envelope/*:Body/*:UserInfoObjResponse/*:ErrorDescrition/text()'
30 ) r;
31
32 dbms_output.put_line ('l_user_first_name: ' || l_user_first_name);
33 dbms_output.put_line ('l_user_last_name : ' || l_user_last_name);
34 dbms_output.put_line ('l_error_value: ' || l_error_value);
35 end;
36 /
Length of Request:530
l_user_first_name: First Name Output
l_user_last_name : Last Name Output
l_error_value:
PL/SQL procedure successfully completed.Max
http://oracleitalia.wordpress.com
Edited by: Massimo Ruocchio on Feb 14, 2010 11:55 PM
Added the first one.
Maybe you are looking for
-
Error in Installing the Oracle 10g RDBMS on linux installed on Vmware
Hi, I am trying to install the Oracle 10g RDBMS software. I have created all the required users and groups, created directories and updaates the sysctl.conf file. When I run the installer ./runInstaller it is giving the following error. [oracle@aasim
-
any way to import text to put in a title?
-
How to use a formula for dynamic New Page After?
There is a formula for dynamic New Page After. How do I get value of formula? I am using RAS and the ReportClientDocument.
-
Best Practice to Migrate from XI R2 to 2008
Hello, We currently have a server which is running Crystal Reports Server XI R2. I have a new server which I have installed Crystal Reports 2008 on and want to migrate our reports to that server. Ideally though, I want to get everything working and
-
Jdeveloper : Creating data bindings for dynamically rendered form
In Jdeveloper application, I've created data controls using web service(WSDL). In my application, I have a form which is rendered at run time. How can I set the form da ta to the parameters inside the data control? Any help will be greatly appreciate