Oracle java XML API - extract

I am using XML oracle Java API, I need to extract tge DOC value, its not working for me
XMLTYPE xml ="
<PurchaseOrder>
<Reference>ADAMS-20011127121040988PST</Reference>
<DOC>SCOTT</DOC>
<Date>2002-03-31</Date>
</PurchaseOrder>";
System.out.println("Testing extract() ...");
try {
System.out.println(" length of text in DOC tag " + (xml.extract("/PurchaseOrder/Reference/DOC/text()",null).getStringVal()));
catch (SQLException e) {
System.out.println("Thin driver Expected exception: " + e);
Throwing java.sql.SQLException
any help please? is there anyother way to extract the value?

I guess this might help you..
Use XPATH if you are reading for a single value in xml .
It will be more cleaner...
String doc= "//PurchaseOrder/Reference/DOC/text()";
Call this in your class using some value
Suppose
setting_to_some_variable.setWhateverDoc(getNodeValueFromDocUsingXPath(doc));
          address
private String getNodeValueFromDocUsingXPath(String xpathString) {
          try {
               XPath xpath = xPathFactory.newXPath();
               XPathExpression expr = xpath.compile(xpathString);
               Node aNode = (Node) expr.evaluate(doc, XPathConstants.NODE);
               if (aNode != null) {
                    return aNode.getNodeValue();
          } catch (XPathExpressionException xpe) {
               xpe.printStackTrace(System.out);
          return null;
     }

Similar Messages

  • What is newest/best/simplest Java XML API for loading/saving/validating?

    Here's what I need to do:
    - Load XML files. Preferably validate using XSD validation referenced by "xsi:schemaLocation" hints.
    - Generate XML files. I'd like to be able to specify indentation (tabs?) and "xsi:schemaLocation" XSD hints
    - I'm working with fairly small configuration files, so I'd like to work with document-centric (and not streaming oriented) APIs.
    I've spent a full day reading articles showing different code snippets for different APIs. There are dozens of standards and APIs. Also, all the articles that I can find are several years old at the least.
    This is surprisingly complex for something so seemingly simple.
    What's the best XML API that fits my criteria? Any links for code snippets and up-to-date documentation?
    Thanks!

    Well, XML hasn't changed since it was formalized, and that was in 1999. So there's really no need for people to write new parsers every couple of years any more. And that's why you don't find new tutorials being written every year either. There's really not much need for that.
    Anyway, my recommendation would be to use the classes that are built into your current version of Java. Use them for a while. Once you have experience with them, all those tutorials about other products will start to make sense and you will be able to make an educated decision for yourself.

  • Oracle Java Mail API exception in Jdev 11.1.15

    we are using java mail api to send out emails. and wrap it in java embedding with in our webservice.
    we are using jdeveloper 11.1.1.5 for this and the Java API is failing with the below error, we have included all the java libraries. As code is working fine in Jdeveloper 11.1.2
    we tried different version of jdeveloper ( 11.1.1.5, 11.1.1.7 ) but its still the same. Can some one please suggest
    Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Can't send command to SMTP host;
      nested exception is:
        javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at bts.mail.SendMailTLS.main(SendMailTLS.java:50)
    Caused by: javax.mail.MessagingException: Can't send command to SMTP host;
      nested exception is:
        javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1420)
        at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1408)
        at com.sun.mail.smtp.SMTPTransport.ehlo(SMTPTransport.java:847)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:384)
        at javax.mail.Service.connect(Service.java:297)
        at javax.mail.Service.connect(Service.java:156)
        at javax.mail.Service.connect(Service.java:105)
        at javax.mail.Transport.send0(Transport.java:168)
        at javax.mail.Transport.send(Transport.java:98)
        at bts.mail.SendMailTLS.main(SendMailTLS.java:45)

    Can Some body help me with this please

  • Sizing DOM trees created by Oracle Java XML parser (v2)

    Hello,
    Has anyone seen/got any formulas that can be used to calculate the DOM tree memory requirements for a given XML document.
    My team has developed some software that, acts like an XSLT, and it runs out of memory for bigger documents. I am able to allocate more memory (usuing java -Xmx<larger figure>) to the process but it would be nice to go to my team leader and say that a file of a given structure would require so much memory.
    At the moment, we are guessing and using the Runtime.getRuntime().freeMemory() and Runtime.getRuntime().TotalMemory()
    to provide some very rough estimates.
    XSLTs wouldnt be able to do what we want. If I could give the team leader some figures then he may be able to justify converting the code to use JDOM instead of a DOM tree.
    Thanks in Advance.
    Mark Robbins

    Can you paste your java code here ? I assume, you must have tried type-casting.

  • Any Oracle/Java/XML developers in Houston, TX interested in getting together ?

    I was just looking for some new collegues and friends. I am currenlty working in Houston, TX and I am interested in getting together with other professionals. If anyone is interested email me at [EMAIL][email protected][EMAIL] .
    Jason Long
    Enterprise Web Developer
    BS Physics
    MS Chemical Engineering
    null

    Does anyone know of any oraganizations in Houston, TX where I can meet other developers? I am currenlty working for a company that only supports Microsoft products and I am trying to switch over. I am sick of Microsoft letting me debug their applications. I would like to develop using standards based products. If anyone on here is from Houston please get it touch with me.

  • Collecting plug-in metrics using XML API from Perl?

    Hi all,
    We are building a plug-in to retrieve metrics over an XML API.
    The QueryDescriptor of each metric will do a call to the Agent's Perl script. This Perl script will then do the actual XML API call, to retrieve the metric's values.
    Does anyone have experience with this? We needed to install a few extra Perl modules from CPAN, to provide the high-level HTTP(s) communication. These modules are not in the Perl that’s used by the Oracle Agent, so I’m not sure if this is going to work when called by the Agent.
    Did any of you use an XML API? Did you make this a prereq (installing modules) or is there an alternative solution?
    Many thanks,
    Ed

    Thank you, Ash. I read the example quickly, and found (quoted)from the paper - "the Applet was designed as compact as possible in order to limit download time and to fit in a 50K jar file. The JAXP XML Parsing API package, including the SAX parser from SUN Project X (approximately 150K) is one of the smallest implementations we were able to use. It is, however, still too large to be downloaded for each session; therefore, it was installed locally to keep the download time as low as possible."
    However, in my current design, I can not ask each customer to install the JAXP API locally, so it seems that the API needs to be downloaded during the run time (am I right?). So the same problem will occur as that stated in the paper - the jar file is still too large to be downloaded for each session. Is there any lightweight API to solve it?
    BTW, as you might see, the paper was published in year 2000, I don't think the JDK plugin supported XML at that time, so it is quite reasonable to download JAXP API in that paper. But my current question is - as I posted in my previous message - whether the newest JDK plugin (JDK1.4) support Java XML API?
    Many many thanks.
    - Sun

  • Java SDO API import bug

    There is a bug in the Oracle Java SDO API. It cannot import compound geometries which consist of either 3 or 4 sub-elements. e.g., the following geometry cannot be imported:
    SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 4, 4, 1, 2, 1, 9, 2, 2, 13
    , 2, 2, 17, 2, 1), SDO_ORDINATE_ARRAY(278222.37, 179102.519, 278222.37, 179111.223,
    278222.37, 179176.31, 278223.164, 179194.567, 278224.751, 179206.473, 278238.913,
    179237.143, 278262.587, 179261.242, 278288.15, 179273.083, 278316.033, 179277.117,
    278336.935, 179274.471, 278357.997, 179271.272))
    Apparently the API does not validate the SDO_ETYPE when checking the SDO_INTERPRETATION value in the geometry.
    SDO_INTERPRETATION values of 3 and 4 are assumed to be a rectangle and circle, respectively, independent of the SDO_ETYPE value. In fact, these SDO_INTERPRETATION should be handled such only for SDO_ETYPE value of 3.
    For an SDO_ETYPE value of 4 (as in the example above), the SDO_INTERPRETATION value indicates the number of sub-elements in the compound geometry element.
    Any ideas for a workaround or fix for this bug?

    Hi Sunil,
    This is a bug. There doesn't seem to be a workaround.
    Can you contact me via email or post your email?
    Thanks.

  • Oracle BPEL Java Client API: Reading Configurations dynamically

    We have a requirement to use Oracle BPEL Java client API to control the BPEL instances at the runtime, from an ADF BC Application. is there any possibility to read the configurations/properties that are required to look up (using 'oracle.soa.management.facade.Locator' ) the BPEL Process Manager/Server from connections.xml/adf-config.xml ?
    In other terms, as we need the details like the bpel server URL, security credentials..etc to lookup the BPEL server and instances using the BPEL java client API, how can we read these details from the ADF standard config files like Connections.xml/adf-config.xml instead of hard coding them in the Java program.
    Edited by: 899479 on Feb 4, 2013 6:02 AM

    The api's for BPEL / Workslow canbe found here:
    http://orasoa.blogspot.com/2007/05/newbie-getting-started-with-oracle-soa.html
    Marc

  • Sun JAXP / Oracle XML api conflicts?

    I have a number of packages which make use of Sun's JAXP XML processing API and reference implementation, but when I use them in JSPs from JDeveloper I get an error due to some conflict with Oracle's XML parser, which JDeveloper automatically places in the classpath before any libraries I define.
    I managed to circumvent this by creating a "Run.java" application which executes the webtogo server - this allows me to place Oracle's XML library AFTER Sun's version in the classpath. This seems to work.
    Any comments about this bit of arm-twisting? Are there any known issues etc?

    It's xmlparserv2.jar - xmlparser.jar is not even in the classpath. This error only occurs when xmlparserv2.jar is placed before jaxp.jar, xalan.jar and crimson.jar (which are supplied with the JAXP implementation).
    I highlighted the line which seems causes the actual exception. The line contains "DocumentBuilderImpl db = new DocumentBuilderImpl(this);".
    log3: sealing violation
    log3: java.lang.SecurityException: sealing violation
    log3: at java.net.URLClassLoader.defineClass(URLClassLoader.java:234)
    log3: at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    log3: at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    log3: at java.security.AccessController.doPrivileged(Native Method)
    log3: at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    log3: at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
    log3: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
    log3: at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
    log3: at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
    log3: at org.apache.crimson.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:88)
    log3: at net.megabyte.util.XmlUtil.toDocument(XmlUtil.java:66)
    log3: at net.megabyte.util.XmlUtil.toDocument(XmlUtil.java:92)
    log3: at net.megabyte.converter.WordHtml.prepare(WordHtml.java:65)
    log3: at net.megabyte.converter.WordHtml.<init>(WordHtml.java:57)
    log3: at mytests.upload_word._jspService(upload_word.jsp:47)
    ===== rest of dump snipped =====
    null

  • Java +XML (SAX) Parser for Oracle 8.1.5 EE

    Hi there :)
    I am looking java classes for SAX to parse XML. I cannot find a valid parser, cause after downloaded from Oracle XDK for java, when i try to load this calasses i get a messages that i alot of classes connot be resolved.
    If somebody have valid classes on Ora 8.1.5 please send me mail.
    Adam

    Have i possibilities to using some javatypes in oracle java stored procedure if this class is not loaded into db?
    Cause i would like to create a java stored procedure to parse and insert some data from xml. I was thinking to pass xml file name as a parameter to my java procedure.
    I must use Oracle 8.1.5 with jdk 1.1.7, and the best parser for me is SAX.
    Please help.
    Have i possobilities to use class inside oracle, which are placed outside oracle?
    Something like classpath, where can i modify value (but classpath inside oracle)?

  • Implementing XAdES in Java XML Digital Signature API

    Hi,
    I've got some problems with implementing XAdES standard with Java XML Digital Signature API. Below is a code (SignatureTest1), that produces a digital signature with some XAdES tags placed in <ds:Object> tag. The signature is later validated with a Validator class. Everything works fine, until I set a XAdES namespace (SignatureTest1.xadesNS="http://uri.etsi.org/01903/v1.3.2#"). In this case validation of XAdES elements fails.
    The reason of validation failture is a difference between arguments passed to a digest method when document is being signed and validated. When the document is being signed a log looks like this:
    FINER: Pre-digested input:
    2007-08-21 15:38:44 org.jcp.xml.dsig.internal.DigesterOutputStream write
    FINER: <SignedProperties xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SignP"></SignedProperties>
    2007-08-21 15:38:44 org.jcp.xml.dsig.internal.dom.DOMReference digest
    FINE: Reference object uri = #SignP
    2007-08-21 15:38:44 org.jcp.xml.dsig.internal.dom.DOMReference digest
    FINE: Reference digesting completed,but while validating:
    FINER: Pre-digested input:
    2007-08-21 15:38:44 org.jcp.xml.dsig.internal.DigesterOutputStream write
    FINER: <SignedProperties xmlns="http://uri.etsi.org/01903/v1.3.2#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SignP"></SignedProperties>
    2007-08-21 15:38:44 org.jcp.xml.dsig.internal.dom.DOMReference validate
    FINE: Expected digest: MAQ/vctdkyVHVzoQWnOnQdeBw8g=
    2007-08-21 15:38:44 org.jcp.xml.dsig.internal.dom.DOMReference validate
    FINE: Actual digest: D7WajkF0U5t1GnVJqj9g1IntLQg=
    2007-08-21 15:38:44 org.jcp.xml.dsig.internal.dom.DOMXMLSignature validate
    FINE: Reference[#SignP] is valid: falseHow can I fix this?
    Signer class:
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.OutputStream;
    import java.security.KeyPair;
    import java.security.KeyPairGenerator;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.crypto.dom.DOMStructure;
    import javax.xml.crypto.dsig.CanonicalizationMethod;
    import javax.xml.crypto.dsig.DigestMethod;
    import javax.xml.crypto.dsig.Reference;
    import javax.xml.crypto.dsig.SignatureMethod;
    import javax.xml.crypto.dsig.SignedInfo;
    import javax.xml.crypto.dsig.Transform;
    import javax.xml.crypto.dsig.XMLObject;
    import javax.xml.crypto.dsig.XMLSignature;
    import javax.xml.crypto.dsig.XMLSignatureFactory;
    import javax.xml.crypto.dsig.dom.DOMSignContext;
    import javax.xml.crypto.dsig.dom.DOMValidateContext;
    import javax.xml.crypto.dsig.keyinfo.KeyInfo;
    import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
    import javax.xml.crypto.dsig.keyinfo.KeyValue;
    import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
    import javax.xml.crypto.dsig.spec.TransformParameterSpec;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import com.sun.org.apache.xml.internal.security.utils.IdResolver;
    public class SignatureTest1 {
         public static String xadesNS=null;//"http://uri.etsi.org/01903/v1.3.2#";
         public static String signatureID="Sig1";
         public static String signedPropID="SignP";
         public static void main(String[] arg) {
            try{
              XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
              List<Reference> refs = new ArrayList<Reference>();
              Reference ref1 = fac.newReference
                  ("", fac.newDigestMethod(DigestMethod.SHA1, null),
                      Collections.singletonList
                    (fac.newTransform
                   (Transform.ENVELOPED, (TransformParameterSpec) null)),
                   null, null);
              refs.add(ref1);
              Reference ref2 = fac.newReference("#"+signedPropID,fac.newDigestMethod(DigestMethod.SHA1,null),null,"http://uri.etsi.org/01903/v1.3.2#SignedProperties",null);
              refs.add(ref2);
              SignedInfo si = fac.newSignedInfo
                  (fac.newCanonicalizationMethod
                   (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
                    (C14NMethodParameterSpec) null),
                   fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null),
                   refs);
             KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA");
              kpg.initialize(512);
              KeyPair kp = kpg.generateKeyPair();
              KeyInfoFactory kif = fac.getKeyInfoFactory();
              KeyValue kv = kif.newKeyValue(kp.getPublic());
             KeyInfo ki = kif.newKeyInfo(Collections.singletonList(kv));
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              dbf.setNamespaceAware(true);
              Document doc =
                  dbf.newDocumentBuilder().parse("purchaseOrder.xml");
              DOMSignContext dsc = new DOMSignContext
                  (kp.getPrivate(), doc.getDocumentElement());
              dsc.putNamespacePrefix(XMLSignature.XMLNS, "ds");
              Element QPElement = createElement(doc, "QualifyingProperties",null,xadesNS);
            QPElement.setAttributeNS(null, "Target", signatureID);
            Element SPElement = createElement(doc, "SignedProperties", null,xadesNS);
            SPElement.setAttributeNS(null, "Id", signedPropID);
            IdResolver.registerElementById(SPElement, signedPropID);
            QPElement.appendChild(SPElement);
            Element UPElement = createElement(doc, "UnsignedProperties", null,xadesNS);
            QPElement.appendChild(UPElement);
            DOMStructure qualifPropStruct = new DOMStructure(QPElement);
            List<DOMStructure> xmlObj = new ArrayList<DOMStructure>();
            xmlObj.add(qualifPropStruct);
            XMLObject object = fac.newXMLObject(xmlObj,"QualifyingInfos",null,null);
            List objects = Collections.singletonList(object);
            XMLSignature signature = fac.newXMLSignature(si, ki,objects,signatureID,null);
              signature.sign(dsc);
              OutputStream os = new FileOutputStream("signedPurchaseOrder.xml");
              TransformerFactory tf = TransformerFactory.newInstance();
              Transformer trans = tf.newTransformer();
              trans.transform(new DOMSource(doc), new StreamResult(os));
            }catch(Exception e){
                 e.printStackTrace();
            try{
            Validator.main(null);
            }catch(Exception e){
                 System.out.println("Validator exception");
                 e.printStackTrace();
         public static Element createElement(Document doc, String tag,String prefix, String nsURI) {
              String qName = prefix == null ? tag : prefix + ":" + tag;
             return doc.createElementNS(nsURI, qName);
    }Validator class:
    import javax.xml.crypto.*;
    import javax.xml.crypto.dsig.*;
    import javax.xml.crypto.dom.*;
    import javax.xml.crypto.dsig.dom.DOMValidateContext;
    import javax.xml.crypto.dsig.keyinfo.*;
    import java.io.FileInputStream;
    import java.security.*;
    import java.util.Collections;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    * This is a simple example of validating an XML
    * Signature using the JSR 105 API. It assumes the key needed to
    * validate the signature is contained in a KeyValue KeyInfo.
    public class Validator {
        // Synopsis: java Validate [document]
        //       where "document" is the name of a file containing the XML document
        //       to be validated.
        public static void main(String[] args) throws Exception {
         // Instantiate the document to be validated
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
         Document doc =
                dbf.newDocumentBuilder().parse(new FileInputStream("signedPurchaseOrder.xml"));
         // Find Signature element
         NodeList nl =
             doc.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature");
         if (nl.getLength() == 0) {
             throw new Exception("Cannot find Signature element");
         // Create a DOM XMLSignatureFactory that will be used to unmarshal the
         // document containing the XMLSignature
         XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
         // Create a DOMValidateContext and specify a KeyValue KeySelector
            // and document context
         DOMValidateContext valContext = new DOMValidateContext
             (new KeyValueKeySelector(), nl.item(0));
         // unmarshal the XMLSignature
         XMLSignature signature = fac.unmarshalXMLSignature(valContext);
         // Validate the XMLSignature (generated above)
         boolean coreValidity = signature.validate(valContext);
         // Check core validation status
         if (coreValidity == false) {
                 System.err.println("Signature failed core validation");
             boolean sv = signature.getSignatureValue().validate(valContext);
             System.out.println("signature validation status: " + sv);
             // check the validation status of each Reference
             Iterator i = signature.getSignedInfo().getReferences().iterator();
             for (int j=0; i.hasNext(); j++) {
              boolean refValid =
                  ((Reference) i.next()).validate(valContext);
              System.out.println("ref["+j+"] validity status: " + refValid);
         } else {
                 System.out.println("Signature passed core validation");
         * KeySelector which retrieves the public key out of the
         * KeyValue element and returns it.
         * NOTE: If the key algorithm doesn't match signature algorithm,
         * then the public key will be ignored.
        private static class KeyValueKeySelector extends KeySelector {
         public KeySelectorResult select(KeyInfo keyInfo,
                                            KeySelector.Purpose purpose,
                                            AlgorithmMethod method,
                                            XMLCryptoContext context)
                throws KeySelectorException {
                if (keyInfo == null) {
              throw new KeySelectorException("Null KeyInfo object!");
                SignatureMethod sm = (SignatureMethod) method;
                List list = keyInfo.getContent();
                for (int i = 0; i < list.size(); i++) {
              XMLStructure xmlStructure = (XMLStructure) list.get(i);
                     if (xmlStructure instanceof KeyValue) {
                        PublicKey pk = null;
                        try {
                            pk = ((KeyValue)xmlStructure).getPublicKey();
                        } catch (KeyException ke) {
                            throw new KeySelectorException(ke);
                        // make sure algorithm is compatible with method
                        if (algEquals(sm.getAlgorithm(), pk.getAlgorithm())) {
                            return new SimpleKeySelectorResult(pk);
                throw new KeySelectorException("No KeyValue element found!");
            //@@@FIXME: this should also work for key types other than DSA/RSA
         static boolean algEquals(String algURI, String algName) {
                if (algName.equalsIgnoreCase("DSA") &&
              algURI.equalsIgnoreCase(SignatureMethod.DSA_SHA1)) {
              return true;
                } else if (algName.equalsIgnoreCase("RSA") &&
                           algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA1)) {
              return true;
                } else {
              return false;
        private static class SimpleKeySelectorResult implements KeySelectorResult {
         private PublicKey pk;
         SimpleKeySelectorResult(PublicKey pk) {
             this.pk = pk;
         public Key getKey() { return pk; }
    }PurchaseOrder.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <PurchaseOrder>
    <Item number="130046593231">
      <Description>Video Game</Description>
      <Price>10.29</Price>
    </Item>
    <Buyer id="8492340">
      <Name>My Name</Name>
      <Address>
       <Street>One Network Drive</Street>
       <Town>Burlington</Town>
       <State>MA</State>
       <Country>United States</Country>
       <PostalCode>01803</PostalCode>
      </Address>
    </Buyer>
    </PurchaseOrder>signedPurchaseOrder.xml with XAdES namespace:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?><PurchaseOrder>
    <Item number="130046593231">
      <Description>Video Game</Description>
      <Price>10.29</Price>
    </Item>
    <Buyer id="8492340">
      <Name>My Name</Name>
      <Address>
       <Street>One Network Drive</Street>
       <Town>Burlington</Town>
       <State>MA</State>
       <Country>United States</Country>
       <PostalCode>01803</PostalCode>
      </Address>
    </Buyer>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Sig1"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>tVicGh6V+8cHbVYFIU91o5+L3OQ=</ds:DigestValue></ds:Reference><ds:Reference Type="http://uri.etsi.org/01903/v1.3.2#SignedProperties" URI="#SignP"><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>MAQ/vctdkyVHVzoQWnOnQdeBw8g=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>lSgzfZCRIlgrgr6YpNOdB3XWdF9P9TEiXfkNoqUpAru/I7IiyiFWJg==</ds:SignatureValue><ds:KeyInfo><ds:KeyValue><ds:DSAKeyValue><ds:P>/KaCzo4Syrom78z3EQ5SbbB4sF7ey80etKII864WF64B81uRpH5t9jQTxeEu0ImbzRMqzVDZkVG9
    xD7nN1kuFw==</ds:P><ds:Q>li7dzDacuo67Jg7mtqEm2TRuOMU=</ds:Q><ds:G>Z4Rxsnqc9E7pGknFFH2xqaryRPBaQ01khpMdLRQnG541Awtx/XPaF5Bpsy4pNWMOHCBiNU0Nogps
    QW5QvnlMpA==</ds:G><ds:Y>p48gU203NGPcs9UxEQQQzQ19KBtDRGfEs3BDt0cbCRJHMh3EoySpeqOnuTeKLXuFr96nzAPq4BEU
    dNAc7XpDvQ==</ds:Y></ds:DSAKeyValue></ds:KeyValue></ds:KeyInfo><ds:Object Id="QualifyingInfos"><QualifyingProperties Target="Sig1" xmlns="http://uri.etsi.org/01903/v1.3.2#"><SignedProperties Id="SignP"/><UnsignedProperties/></QualifyingProperties></ds:Object></ds:Signature></PurchaseOrder>

    I believe the problem is that you are not explicitly adding the xades namespace
    attribute to the SignedProperties element before generating the signature. Thus,
    the namespace attribute is not visible when canonicalizing, but when you serialize the
    DOM tree to an output stream, (for reasons I'm not entirely sure why), the namespace
    attribute is visible and is added to the SignedProperties element, which breaks the
    signature.
    You must always explicitly add namespace attributes using the Element.setAttributeNS
    method. Try changing the following code from:
    Element SPElement = createElement(doc, "SignedProperties", null,xadesNS);
    to:
    Element SPElement = createElement(doc, "SignedProperties", null,xadesNS);
    SPElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", xadesNS);

  • [METASOLV XML AP]devolop JAVA client using XML API for metasolv application

    Hi All,
    I am new in this group, and I need to help me to develop a java client to communicate with metasolv application using XML API.
    I read "XML API Developer’s Reference" document, but I still not understand how can I setup the cllient.
    I still need:
    1- What API needed(jar files) I must use to build the client
    2- A sample of source code using java.
    3- detailed guide to communicate with metasolv application using XML API.
    Thanks&Best Regards
    RADOUANE Mohamed

    any help please!!!!

  • What is the good voice xml api for java

    dear buddies,
    what is the best voice xml api for java? has somebody comeacross and work involving this, i would like to hear more about this
    thanks
    Kuha

    Maybe the VXML forum is a better place: http://www.voicexml.org/
    Good luck.

  • Java XML Digital Signature API, how to sign different files

    Hello,
    I need to sign several files: binary and/or xml (in some cases just part of xml), and to implement digitla signatures in xAdes standard. So I'm looking to use Java XML Digital signature API, but can't find any examples, that would cover issues I encountered:
    How to sign binary file?
    Just to sign some simple "aaa.png" file and have it's signature in XML. How in right way to create referece?
    (should it be something like: Reference ref = fac.newReference("aaa.png", fac.newDigestMethod(DigestMethod.SHA1, null), null, null, null); )
    And how to pass file for signing? what to add/change to this code:
    Document doc = dbf.newDocumentBuilder().parse(new FileInputStream("aaa.png"));
    DOMSignContext dsc = new DOMSignContext(keyEntry.getPrivateKey(), doc.getDocumentElement());
    (I have only found some information about needing to "dereference" or so - but no examples, how to make things work.)
    How to sing several different files?
    As I wrote before, several files needs to be signed, but in all examples, it's only one Document object (and only one file), how/where to add more files and if API will be capable to deal with such thing?
    In one of examples what I have to achive was such code:
    <Reference URI="aaa.png" xmlns="http://www.w3.org/2000/09/xmldsig#">
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
    <DigestValue>8rl/xzjAnE4yQQ2LTBvFTU2JH+c=</DigestValue>
    </Reference>
    If I do write code like: "fac.newReference("aaa.png", <...> );
    I'll get an error during signing: signature.sign(dsc);
    *"java.net.MalformedURLException: no protocol: aaa.png"*
    How to avoid this?
    Also, from exmaple (what to reach) above:
    <Reference URI="aaa.png" xmlns="http://www.w3.org/2000/09/xmldsig#">
    There is additional attribute "xmlns=<...>" - the question is if it is possible to add it by XMLSignatureFactory.newReference ?
    Java API adds a lot of prefixes "ds:" , like:
    <...>
    <ds:Reference URI="file:/D:/try5/SignableMetadata0.xml">
    <ds:Transforms>
    <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
    </ds:Transforms>
    <...>
    Is it possible to avoid them?
    Any help on any of these questions would be very appreciated

    Hi,
    I would like to sign a specific part of a xml message [Only the contents under the <Buyer> tag]. I have also pasted the code which i used to do this. I am getting an output xml after the xml is signed, but when I validate the xml , the xml is valid even after I change the xml contents. Could you pls tell me what I am doing wrong here. I want to know whether the xpath implementation which I have done is correct.
    <?xml version="1.0" encoding="UTF-8"?>
    <PurchaseOrder>
    <Item number="130046593231">
    <Description>Video Game</Description>
    <Price>10.29</Price>
    </Item>
    *<Buyer id="8492340">*
    *<Name>My Name</Name>*
    *<Address>*
    *<Street>One Network Drive</Street>*
    *<Town>Burlington</Town>*
    *<State>MA</State>*
    *<Country>United States</Country>*
    *<PostalCode>01803</PostalCode>*
    *</Address>*
    *</Buyer>*</PurchaseOrder>
    // The code which i have used to perform the xpath transformation.
              XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
         XPathFilterParameterSpec xpathFilter = new XPathFilterParameterSpec("PurchaseOrder/Buyer");
              javax.xml.crypto.dsig.Reference ref = fac.newReference
              ("", fac.newDigestMethod(DigestMethod.SHA1, null),
              Collections.singletonList
              (fac.newTransform
              (Transform.XPATH, xpathFilter)),
              null, null);
              SignedInfo si = fac.newSignedInfo
              (fac.newCanonicalizationMethod
              (CanonicalizationMethod.INCLUSIVE,
              (C14NMethodParameterSpec) null),
              fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null),
    Collections.singletonList(ref));
    // Load the KeyStore and get the signing key and certificate.
         KeyStore ks = KeyStore.getInstance("JKS");
         char[] password = "changeme".toCharArray();
         ks.load(new FileInputStream("c:\\KeyStore"), password);
         KeyStore.PrivateKeyEntry keyEntry =
         (KeyStore.PrivateKeyEntry) ks.getEntry
         ("EISKeys", new KeyStore.PasswordProtection(password));
         X509Certificate cert = (X509Certificate) keyEntry.getCertificate();
         // System.out.println("X509Certificate:"+cert);
         // Create the KeyInfo containing the X509Data.
         KeyInfoFactory kif = fac.getKeyInfoFactory();
         List x509Content = new ArrayList();
         x509Content.add(cert.getSubjectX500Principal().getName());
         x509Content.add(cert);
         X509Data xd = kif.newX509Data(x509Content);
         KeyInfo ki = kif.newKeyInfo(Collections.singletonList(xd));
         // Instantiate the document to be signed.
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
         Document doc = dbf.newDocumentBuilder().parse
         (new FileInputStream("C:\\Life2012\\DigSign\\ACORD_Request.xml"));
         NodeList rootChildList = doc.getDocumentElement().getChildNodes();
         Node bodyNode = null;
         for(int i=0;i<rootChildList.getLength();i++){
              if("Buyer".equalsIgnoreCase(rootChildList.item(i).getLocalName())){
                   bodyNode = rootChildList.item(i);
                   System.out.println("Body Node is obtained"+bodyNode);
                   break;
         // Create a DOMSignContext and specify the RSA PrivateKey and
         // location of the resulting XMLSignature's parent element.
         //DOMSignContext dsc = new DOMSignContext
         // (keyEntry.getPrivateKey(), doc.getDocumentElement());
              // Sign only the body node
         DOMSignContext dsc = new DOMSignContext
         (keyEntry.getPrivateKey(), bodyNode);
         // Create the XMLSignature, but don't sign it yet.
         XMLSignature signature = fac.newXMLSignature(si, ki);
         // Marshal, generate, and sign the enveloped signature.
         signature.sign(dsc);

  • Save Attachment from exchange server 2010 from oracle using java mail API

    Hello,
    I want to read email from microsoft exchangeserver 2010 and save attachement into a folder.I created an Java program to import attachments from a exchange server mailbox using "POP3S".It works fine when run as a java application.But when i put this inside Oracle11g R2 using load java and while executing from a procedure it gives an error at parsing message into Multipart
    Error at line : Multipart mp = (Multipart)m.getContent();
    Error:
    Content-Type: multipart/mixed;
    boundary="_002_A0C2E09A..................................."
    java.lang.ClassCastException
    at mailPop3.checkmail(mailPop3:71)
    My Java Class is as follows,
    import java.io.*;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.Date;
    The function i used to check for attachments is given below.
    public static boolean hasAttachments(Message m) throws java.io.IOException, MessagingException
    Boolean hasAttachments = false;
    try
    // if it is a plain/html text - no attachements
    if (m.isMimeType("text/*"))
    return hasAttachments;
    else if (m.isMimeType("multipart/alternative"))
    return hasAttachments;
    else if (m.isMimeType("multipart/*"))
    Multipart mp = (Multipart)m.getContent();
    if (mp.getCount() > 1)
    hasAttachments = true;
    return hasAttachments;
    catch (Exception e) {
    e.printStackTrace();
    } finally {
    return hasAttachments;
    My Java Details as follows
    java Version :1.5.0_10
    java.vm.specification.version:1.0
    java.vm.version :1.5.0_01
    java.specification.version:1.5
    java.class.version:48.0
    Java mail API:javamail-1.4.4
    Used Jars:mail.jar
    Could someone explain why I am getting this error? What can I do to resolve this error?
    Is any other Jar need other than mail.jar?
    Any help would be much appreciated.
    Regards,
    Nisanth

    Hai EJP,
    Thanks for your reply,
    My full java class as follows,
    import java.util.Properties;
    import javax.mail.Authenticator;
    import javax.mail.Folder;
    import javax.mail.Message;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Store;
    import javax.mail.Part;
    import javax.mail.Multipart;
    import javax.mail.internet.MimeMultipart;
    import javax.mail.internet.MimeMessage;
    public class Newmail
    public Newmail()
    super();
    public static int mailPOP3(String phost,
    String pusername,
    String ppassword)
    Folder inbox =null;
    Store store =null;
    int result = 1;
    try
    String host=phost;
    final String username=pusername;
    final String password=ppassword;
    System.out.println("Authenticator");
    Authenticator auth=new Authenticator()
    protected PasswordAuthentication getPasswordAuthentication()
    return new PasswordAuthentication(username, password);
    System.out.println("Certificate");
    String filename="D:\\Certi\\jssecacerts";
    String password2 = "changeit";
    System.setProperty("javax.net.ssl.trustStore",filename);
    System.setProperty("javax.net.ssl.trustStorePassword",password2);
    Properties props = System.getProperties();
    System.out.println("host-----"+props);
    props.setProperty("mail.pop3s.port", "993");
    props.setProperty("mail.pop3s.starttls.enable","true");
    props.setProperty("mail.pop3s.ssl.trust", "*");
    Session session = Session.getInstance(props,auth);
    session.setDebug(true);
    store = session.getStore("pop3s");
    System.out.println("store------"+store);
    store.connect(host,username,password);
    System.out.println("Connected...");
    inbox = store.getDefaultFolder().getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    Message[] msgs = inbox.getMessages();
    System.out.println("msgs.length-----"+msgs.length);
    result = 0;
    int no_of_messages = msgs.length;
    for ( int i=0; i < no_of_messages; i++)
    System.out.println("msgs.count-----"+i);
    System.out.println("Attachment....>"+msgs.getContentType());
    Multipart mp = (Multipart)msgs[i].getContent();
    System.out.println("Casting Success" + mp.getContentType());
    catch(Exception e)
    e.printStackTrace();
    finally
    try
    if(inbox!=null)
    inbox.close(false);
    if(store!=null)
    store.close();
    return result;
    catch(Exception e)
    e.printStackTrace();
    return result;
    Please check it
    Regards,
    Nisanth

Maybe you are looking for

  • Wrong stage in Approval Procedure

    Hi All. Recently, we've upgrade our SBO (2007A) to SP01, PL08 and then we noticed a strage problem regarding Approval Procedures. Our Approval Procedure Template (for POs) has 2 stages as below: First stage - st1 Defined Approvals - 2 Required - 1 Se

  • 10.5.6 upgrade, 4GB memory, fails on boot, works if pull either chip.

    After the update of 10.5.6, getting 2 beeps, then 3 beeps after that, searching posts, mentioned bad memory. My 2.4GHx 24" iMac system with 2 memory chips for total of 4GB, which is the max for this system, (purchased from Other World Computing last

  • Dynamic Item Creation

    Hi, Can i create more than 50 items dynamically in a page. I tried creating but it is not working. In one of my application page i have more than 10 regions, each region has 6-7 dynamic items. Any work-around?? Regards, Som

  • When I open Time Machine all I see is the desktop. Where r the other folders?

    All I see are copies of desktops that were bacjed up on my time machine. I can only restore the desktop. Where can I find the rest of hard drive contents?

  • Edge Animate on different browers

    Hi all, from your experience, I would like to know if Edge Animate works well with different browers. I mean do I need to test my work on IE, FF, Chrome, etc before I publish it? Thanks.