Problem in XML Encryption
Hello Experts,
I am trying to invoke the other platform encrypted service.
I imported the public key given by the other platform so that i would be able to encrypt the request.
In the receiver agreement I encrypted the request and decrypted the response using my pvt key.
Using the soapui tool i tested and it failed. It shows the following error.
com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.interfaces.messaging.api.exception.MessagingException: XIAdapter:ADAPTER.SOAP_EXCEPTION:soap fault: weblogic.xml.crypto.encrypt.api.XMLEncryptionException: Unable to resolve encryption key for weblogic.xml.crypto.encrypt.api.EncryptedType{keyInfo=null, cipherData=CipherValue: u0MSUd43Onj/fTW02gFSfV/IbOEkvQ1teKVVxJQd1e8pXS+ZFq04rnx3YIx4fKsEk5pogEF8HHb546plmZFZCca3Wx2mTuPctRK1M9k8uioEqUBQdJHG3f3aheXyYZnhw2vkEv0lHNjbSn7El8NMdzbWB7brpZBU
How shall i solve it.?
Regards,
Kevin
Edited by: Kevin Mascarenhas on Aug 18, 2008 8:19 AM
Hi,
check out this weblog
Setup HTTPS (SSL) for the Sneak Preview SAP NetWeaver 04 ABAP Edition on Windows
go through these links,hope these ll help you to solve your problem
http://www.sap-si.com/files/Security_final_en.pdf
/people/gregor.wolf3/blog
Regards,
Surya
Similar Messages
-
Problem parsing XML with schema when extracted from a jar file
I am having a problem parsing XML with a schema, both of which are extracted from a jar file. I am using using ZipFile to get InputStream objects for the appropriate ZipEntry objects in the jar file. My XML is encrypted so I decrypt it to a temporary file. I am then attempting to parse the temporary file with the schema using DocumentBuilder.parse.
I get the following exception:
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element '<root element name>'
This was all working OK before I jarred everything (i.e. when I was using standalone files, rather than InputStreams retrieved from a jar).
I have output the retrieved XML to a file and compared it with my original source and they are identical.
I am baffled because the nature of the exception suggests that the schema has been read and parsed correctly but the XML file is not parsing against the schema.
Any suggestions?
The code is as follows:
public void open(File input) throws IOException, CSLXMLException {
InputStream schema = ZipFileHandler.getResourceAsStream("<jar file name>", "<schema resource name>");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
try {
factory.setNamespaceAware(true);
factory.setValidating(true);
factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
factory.setAttribute(JAXP_SCHEMA_SOURCE, schema);
builder = factory.newDocumentBuilder();
builder.setErrorHandler(new CSLXMLParseHandler());
} catch (Exception builderException) {
throw new CSLXMLException("Error setting up SAX: " + builderException.toString());
Document document = null;
try {
document = builder.parse(input);
} catch (SAXException parseException) {
throw new CSLXMLException(parseException.toString());
}I was originally using getSystemResource, which worked fine until I jarred the application. The problem appears to be that resources returned from a jar file cannot be used in the same way as resources returned directly from the file system. You have to use the ZipFile class (or its JarFile subclass) to locate the ZipEntry in the jar file and then use ZipFile.getInputStream(ZipEntry) to convert this to an InputStream. I have seen example code where an InputStream is used for the JAXP_SCHEMA_SOURCE attribute but, for some reason, this did not work with the InputStream returned by ZipFile.getInputStream. Like you, I have also seen examples that use a URL but they appear to be URL's that point to a file not URL's that point to an entry in a jar file.
Maybe there is another way around this but writing to a file works and I set use File.deleteOnExit() to ensure things are tidied afterwards. -
hi everybody,
I've a big problem with XML on Linux, in details I see my program stopping on Linux at the instruction
XMLReader xr = XMLReaderFactory.createXMLReader("org.apache.crimson.parser.XMLReaderImpl");
and it's strange because on Windows it runs and there aren't problems about permissions on files, does anyone knows what to do?
thanks in advance!
StefanoWhat happens on that line? I'm assuming you get some kind of error or exception.
Make sure the JAR file for Crimson is in your classpath. -
Problem with XML in APEX ORA-06502
i, I have a problem with XML generation, I developed an application in APEX, and in a html page I have this process:
declare
l_XML varchar2(32767);
begin
select xmlElement
"iva",
xmlElement("numeroRuc",J.RUC),
xmlElement("razonSocial", J.RAZON_SOCIAL),
xmlElement("idRepre", J.ID_REPRE),
xmlElement("rucContador", J.RUC_CONTADOR),
xmlElement("anio", J.ANIO),
xmlElement("mes", J.MES),
xmlElement
"compras",
select xmlAgg
xmlElement
"detalleCompra",
--xmlAttributes(K.ID_COMPRA as "COMPRA"),
xmlForest
K.COD_SUSTENTO as "codSustento",
K.TPLD_PROV as "tpldProv",
K.ID_PROV as "idProv",
K.TIPO_COMPROBANTE as "tipoComprobante",
to_char(K.FECHA_REGISTRO, 'DD/MM/YYYY') as "fechaRegistro",
K.ESTABLECIMIENTO as "establecimiento",
K.PUNTO_EMISION as "puntoEmision",
K.SECUENCIAL as "secuencial",
to_char(K.FECHA_EMISION, 'DD/MM/YYYY') as "fechaEmision",
K.AUTORIZACION as "autorizacion",
to_char(K.BASE_NO_GRA_IVA, 9999999999.99) as "baseNoGraIva",
to_char(K.BASE_IMPONIBLE, 9999999999.99) as "baseImponible",
to_char(K.BASE_IMP_GRAV, 9999999999.99) as "baseImpGrav",
to_char(K.MONTO_ICE, 9999999999.99) as "montoIce",
to_char(K.MONTO_IVA, 9999999999.99) as "montoIva",
to_char(K.VALOR_RET_BIENES, 9999999999.99) as "valorRetBienes",
to_char(K.VALOR_RET_SERVICIOS, 9999999999.99) as "valorRetServicios",
to_char(K.VALOR_RET_SERV_100, 9999999999.99) as "valorRetServ100"
xmlElement
"air",
select xmlAgg
xmlElement
"detalleAir",
xmlForest
P.COD_RET_AIR as "codRetAir",
to_char(P.BASE_IMP_AIR, 9999999999.99) as "baseImpAir",
to_char(P.PORCENTAJE_AIR, 999.99) as "porcentajeAir",
to_char(P.VAL_RET_AIR, 9999999999.99) as "valRetAir"
from ANEXO_COMPRAS P
where P.ID_COMPRA = K.ID_COMPRA
AND P.ID_INFORMANTE_XML = K.ID_INFORMANTE_XML
xmlElement("estabRetencion1", K.ESTAB_RETENCION_1),
xmlElement("ptoEmiRetencion1", K.PTO_EMI_RETENCION_1),
xmlElement("secRetencion1", K.SEC_RETENCION_1),
xmlElement("autRetencion1", K.AUT_RETENCION_1),
xmlElement("fechaEmiRet1", to_char(K.FECHA_EMI_RET_1,'DD/MM/YYYY')),
xmlElement("docModificado", K.DOC_MODIFICADO),
xmlElement("estabModificado", K.ESTAB_MODIFICADO),
xmlElement("ptoEmiModificado", K.PTO_EMI_MODIFICADO),
xmlElement("secModificado", K.SEC_MODIFICADO),
xmlElement("autModificado", K.AUT_MODIFICADO)
from SRI_COMPRAS K
WHERE K.ID IS NOT NULL
AND K.ID_INFORMANTE_XML = J.ID_INFORMANTE
AND K.ID BETWEEN 1 AND 25
).getClobVal()
into l_XML
from ANEXO_INFORMANTE J
where J.ID_INFORMANTE =:P3_MES
and J.RUC =:P3_ID_RUC
and J.ANIO =:P3_ANIO
and J.MES =:P3_MES;
--HTML
sys.owa_util.mime_header('text/xml',FALSE);
sys.htp.p('Content-Length: ' || length(l_XML));
sys.owa_util.http_header_close;
sys.htp.print(l_XML);
end;
Now my table has more than 900 rows and only when I specifically selected 25 rows of the table "ANEXO_COMPRAS" in the where ( AND K.ID BETWEEN 1 AND 25) the XML is generated.+
I think that the problem may be the data type declared "varchar2", but I was trying with the data type "CLOB" and the error is the same.+
declare
l_XML CLOB;
begin
--Oculta XML
sys.htp.init;
wwv_flow.g_page_text_generated := true;
wwv_flow.g_unrecoverable_error := true;
--select XML
select xmlElement
from SRI_COMPRAS K
WHERE K.ID IS NOT NULL
AND K.ID_INFORMANTE_XML = J.ID_INFORMANTE
).getClobVal()
into l_XML
from ANEXO_INFORMANTE J
where J.ID_INFORMANTE =:P3_MES
and J.RUC =:P3_ID_RUC
and J.ANIO =:P3_ANIO
and J.MES =:P3_MES;
--HTML
sys.owa_util.mime_header('text/xml',FALSE);
sys.htp.p('Content-Length: ' || length(l_XML));
sys.owa_util.http_header_close;
sys.htp.print(l_XML);
end;
The error generated is ORA-06502: PL/SQL: numeric or value error+_
Please I need your help. I don`t know how to resolve this problem, how to use the data type "CLOB" for the XML can be generate+JohannaCevallos07 wrote:
Now my table has more than 900 rows and only when I specifically selected 25 rows of the table "ANEXO_COMPRAS" in the where ( AND K.ID BETWEEN 1 AND 25) the XML is generated.+
I think that the problem may be the data type declared "varchar2", but I was trying with the data type "CLOB" and the error is the same.+
The error generated is ORA-06502: PL/SQL: numeric or value error+_
Please I need your help. I don`t know how to resolve this problem, how to use the data type "CLOB" for the XML can be generate+The likeliest explanation for this is that length of the XML exceeds 32K, which is the maximum size that <tt>htp.p</tt> can output. A CLOB can store much more than this, so it's necessary to buffer the output as shown in +{message:id=4497571}+
Help us to help you. When you have a problem include as much relevant information as possible upfront. This should include:
<li>Full APEX version
<li>Full DB/version/edition/host OS
<li>Web server architecture (EPG, OHS or APEX listener/host OS)
<li>Browser(s) and version(s) used
<li>Theme
<li>Template(s)
<li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
And always post code wrapped in <tt>\...\</tt> tags, as described in the FAQ.
Thanks -
Hi
I am working on BLS and having problem in xml query.I want to perform some calculation over xml columns.Than total of this as a new column.I can do this part in logic editor itself but can i do these both task by XSLT.
Can be made our own XSLT for this ?
I am feeling kind of fear to xslt. Can anybody help me in this.
Thanks a lot in advance
thomasRam,
In xMII there is a list of predefined xslt transforms that do something similar to what you are explaining. The 3 that I think may be what you are looking for are
they are under Calculation Transformations and Subtotal Transformation take a look at these and tell me if they are doing what you want to accomplish. In the xMII help file do a search on Inline Transforms or navigate to Advanced Topics -> Inline Transforms -> Predefined Inline Transforms. In this section there are examples of how to use these transforms and apply them in the query templates. If this is not what you are looking for can you explain in a little more detail along with a simple example of how you want this transform to work. Also why do you want to use xslt if you can already accomplish this in BLS?
Regards,
Erik -
Facing problem in xml schema xsd file registration
Hi,
i am facing problem in xml schema xsd file registration when
the number of column is more. It is showing persing error.
if i am deleting few column from xsd file . It is working otherwise
showing error. Is there any solution for that please suggest me.
The Error is
ORA-31011:XML parsing failed
ORA_19202: Error occurred in XML processing
LPX-00230 : (message vary time to time-like invalid tag ending etc.)
Regards
Manoranjan
and thanks in advanceWhere is you XML coming from. Are you sure it's valid. If you are hard coding it as a SQL String constant are you hitting the 4k / 32K limit on the size of SQL / PL/SQL constant. Have you tried loading the content from a bfile..
-
Hi All,
I'm a newbie, and want to know if the output XML file (UUT test report) from TestStand can be encrypted without using any third party software?
Actually I want to know if TestStand itself supports encryption/decryption of XML?
And if TestStand doesn't supports, is there any work around for this requirement?
I am not allergic to Kudos, in fact I love Kudos.
Make your LabVIEW experience more CONVENIENT.Hello,
Encryption in XML file is required to encrypt the various configuration parameter values so that a user cannot view / edited it external outside the to the test application. By making use of Private / Public keys data would be encrypted.This key will be exchanged between TestStand & XML to decrypt & display it to user.
See additional details on XML encryption on : http://www.w3.org/TR/xmlenc-core/
We can encrypt the step result using LabVIEW encryption example --> http://zone.ni.com/devzone/cda/epd/p/id/3473
My question now is --> How to include the customize XML report header to include the encryption standard?
I saw many articles to make use of "ModifyReportHeader". Can someone furnish me with a working example of modifying the header through TestStand? I tried ... but in Vain.. -
Problem for xml generation using DBMS_XMLGEN
Hi All,
i have problem during xml generation using Any help would be highly appreciate
how could we publish xml data using data base API DBMS_XMLGEN in oracle applications (APPS) i.e. at 'View Output" using
Any help would be highly appreciate.
Let me know if need more explanation, this is High priority for me.
Thanks and Regards,
[email protected]
Message was edited by:
user553699You can set the null attribute to true , so that the tag appears in your XML
see the statement in Bold.
DECLARE
queryCtx dbms_xmlquery.ctxType;
result CLOB;
BEGIN
-- set up the query context
queryCtx := dbms_xmlquery.newContext(
'SELECT empno "EMP_NO"
, ename "NAME"
, deptno "DEPT_NO"
, comm "COMM"
FROM scott.emp
WHERE deptno = :DEPTNO'
dbms_xmlquery.setRowTag(
queryCtx
, 'EMP'
dbms_xmlquery.setRowSetTag(
queryCtx
, 'EMPSET'
DBMS_XMLQUERY.useNullAttributeIndicator(queryCtx,true);
dbms_xmlquery.setBindValue(
queryCtx
, 'DEPTNO'
, 30
result := dbms_xmlquery.getXml(queryCtx);
insert into clobtable values(result);commit;
dbms_xmlquery.closeContext(queryCtx);
END;
select * from clobtable
<?xml version = '1.0'?>
<EMPSET>
<EMP num="1">
<EMP_NO>7499</EMP_NO>
<NAME>ALLEN</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>300</COMM>
</EMP>
<EMP num="2">
<EMP_NO>7521</EMP_NO>
<NAME>WARD</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>500</COMM>
</EMP>
<EMP num="3">
<EMP_NO>7654</EMP_NO>
<NAME>MARTIN</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>1400</COMM>
</EMP>
<EMP num="4">
<EMP_NO>7698</EMP_NO>
<NAME>BLAKE</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM NULL="YES"/>
</EMP>
<EMP num="5">
<EMP_NO>7844</EMP_NO>
<NAME>TURNER</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>0</COMM>
</EMP>
<EMP num="6">
<EMP_NO>7900</EMP_NO>
<NAME>JAMES</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM NULL="YES"/>
</EMP>
</EMPSET>
http://sqltech.cl/doc/oracle9i/appdev.901/a89852/d_xmlque.htm -
XML DevCon 2001: Submit schema and stylesheet problems- win XML Spy
There are only a few days to submit schema and stylesheet problems for XML
DevCon 2001 in London. If the workshop instructors use your submission
during the conference, you win a copy of XML Spy.
<shamelessPlug>
XML DevCon 2001 has a content-rich technical program with a faculty that
includes Henry Thompson (W3C Fellow), Peter Chen (IEEE Fellow, ACM
Fellow),
Martin Bryan (DIFFUSE Project), and authors such as Bob DuCharme, Ian
Graham, Elliotte Rusty Harold, G. Ken Holman, Benoît Marchal, JP
Morgenthal,
and Simon St. Laurent. There are a variety of eBusiness sessions,
including
panel discussions and presentations about ebXML, Web Services, and UDDI.
The program includes presentations by Jonathan Borden, Ron Bourret, Lee
Buck, Alex Chaffee, Mark Colan, John Evdemon, Meike Klettke, Andy
Longshaw,
Ingo Macherius, Simon Nicholson, David Orchard, Sebastian Rahtz, Daniel
Rivers-Moore, Michael Rys, Krishna Sankar, Matt Sergeant, Richard Tobin,
Priscilla Walmsley, David RR Webber and other distinguished faculty.
</shamelessPlug>
http://www.xmldevcon2001.com/London/html/conference.php
For a free pass to exhibits and special events (keynotes, joint XML UK and
British Computer Society meeting, OASIS XPath/XSLT meeting, vendor
presentations):
http://www.xmldevcon2001.com/London/html/special_events.php
Public submissions (schemas and stylesheets)
Three members of the W3C Schema Working Group (Michael Rys, Henry
Thompson, Priscilla Walmsley) will teach a Schema Workshop. Submit
problem schemas to them by e-mail:
[email protected]
or
http://www.xmldevcon2001.com/London/html/session.php?code=W5
Sebastian Rahtz, Bob DuCharme, Benoît Marchal, and Ken Holman will
present the "Stylesheets and Transformations: Best Practices" workshop on
Thursday, February 22 in London. To submit a stylesheet or problem
description for their workshop:
[email protected]
or browse to:
http://www.xmldevcon2001.com/London/html/session.php?code=T17
========== Ken North ======================
See you at Javacon 2001 (New York, March 1)
www.javacon2001.com
XML DevCon 2001: London (February 21-23) New York (April 8-11)
www.xmldevcon2001.com
=======================================Looks okay to me. But then I have no idea of what those "problems" are that you mentioned. Was there a particular reason you didn't tell us what they are?
-
I am facing a new problem with xml schema, plz help me
Hi @,
I am facing a problem with xml schema validation. Below is my code.
public void initialize(String cfgFileName) {
try {
try {
DOMParserWrapper parser = (DOMParserWrapper)Class.forName("dom.wrappers.DOMParser").newInstance();
parser.setFeature( "http://apache.org/xml/features/dom/defer-node-expansion",true );
parser.setFeature( "http://xml.org/sax/features/validation",true);
parser.setFeature( "http://xml.org/sax/features/namespaces",true );
parser.setFeature( "http://apache.org/xml/features/validation/schema",true );
parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking",true );
Document document = parser.parse(cfgFileName);
System.out.println("Vijay .. code .. damar\n");
}catch (org.xml.sax.SAXParseException spe) {
} catch (org.xml.sax.SAXNotRecognizedException ex ){
} catch (org.xml.sax.SAXNotSupportedException ex ){
} catch (org.xml.sax.SAXException se) {
if (se.getException() != null)
se.getException().printStackTrace(System.err);
else
se.printStackTrace(System.err);
}catch (Exception e) {
System.out.println("Caught unknown exception : \n");
e.printStackTrace(System.err);
System.out.println("Vijay .. code .. success\n");
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
//docBuilder.setErrorHandler(myErrorHandler);
cfg = docBuilder.parse(new File(cfgFileName));
cfg .getDocumentElement ().normalize ();
} catch (Exception e) {
e.printStackTrace();
In the above code I am parsing the xml file and i am doing schema validation. Schema validation is proper and it is validating correctly. Only problem is that, It is validating and showing error correctly correctly but it is not catching that error.
For clear understanding I am printing one statement before parsing and after parsing.
SYSTEM.OUT.PRINTLN("Vijay .. code .. damar\n") this is before parsing
SYSTEM.OUT.PRINTLN("Vijay .. code .. success\n") this is after parsing
Here what is happening means, It is validating correctly and showing error :
[Error] nw_layout-new.xml:800:97: Datatype error: Value 'y' does not match regular expression facet 'yes|no'..
Vijay .. code .. damar
Vijay .. code .. success
Here it is showing error and still continueing not catching.
Plz give solution for this.
Thanks
vijay KHello dipthebe,
Check out the articles below go through troubleshooting steps for your iPhone when the screen is unresponsive. You may want to try and restore your iPhone as a new device and then test out what happens when you miss a call to see if the issue is still present afterwards.
iPhone, iPad, iPod touch: Troubleshooting touchscreen response
http://support.apple.com/kb/ts1827
Use iTunes to restore your iOS device to factory settings
http://support.apple.com/kb/HT1414
Regards,
-Norm G. -
Windows 7 problem with EFS (Encrypting file system)
Hello colleagues!
I think this topic is related more to the security.
The problem is a bit unusual and google doesn't give me a clear answers, but maybe anyone came across
with similar problem...
In general, I suspect that my problem is EFS (Encrypting file system), ie
service that automatically encrypts files using a digital signature (certificate).
A little background:
- On the work PC it was necessary to reinstall
the system, according to corporate rules all the content we have is encrypted using EFS (Encrypted files are highlighted with green color as you know).
I have copied all the data on a portable drive and also copied the certificates (certmgr.msc).
The system was reinstalled. The only change - it was x32 and became x64.
- It was necessary to free up some space on the hard drive (the file
system on it is NTFS), so, I temporary copied all the files on my home PC. My work certificate was installed on it too, because
I work from home
sometimes.
When the work PC was repaired, I've moved all the files back in
the same way (ie on the portable HDD, then to the work PC).
All files were working, but when I needed MS Word documents, it became clear that something was wrong.
When I've opened the document, it gaveme a window with weird symbols and prompts me to select the encoding ... of course -
no encoding was fit.
Started to explore all the documents, it appears that some part of them were working,
someof them not - all the old documents were working, ie the ones, which
were created before deploying EFS (newly created or copied files immediately encrypted).
So, now I am sure that the
documents were somehow re-encrypted, at least on a portable hard drive, they do not look as encrypted (not highlighted in green), but it's still not open.
Completely stopped opening all the documents that have
been encrypted (for all types of files, ie it is not just an MS Word, but also pdf, presentations, charts, and even the pictures).
Tell me, who faced similar?
How can it all back? I have no possibility to restore those documents from another sources.Try copy those corrupted files and make sure you are using the same certificate and then re-encrypt the copied files and try decrypt them.
If possible, use the same account as you used for encryption. -
anyone else noticed this? it happens sometimes when going to www.apple.com and switching to another site while www.apple.com still loads. safari or apple.com problem?
I got a same problem when I access to www.apple.com also, after this "problem receibing xml data" dialog appeared I cannot play streaming video(WMP).
-
Having a problem importing xml into an indesign template.
I am having a problem importing xml into an indesign template. The xml data is there and will populate the columns on the document but I am having problems matching styles, removing data that should not be mapped and importing repeated same fields but differnet data.
Message me if this is something you can do quickly for a fee.Also you can check the following link
[Reporting|http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/devsuite.htm]
Regards,
Tej -
Hi, all.
I'm generating a ciphered XML file (using apache.xml libraries). I've discovered that if I encrypt and decrypt an in-memory XML document, everything works fine.
However, if I save the ciphered XML document and then I load it and try to decipher, I get the following exception:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Vector.elementAt(Vector.java:435)
at org.apache.xerces.dom.DeepNodeListImpl.item(Unknown Source)
at org.apache.xml.security.encryption.XMLCipher$Factory.newEncryptedKey(Unknown Source)
at org.apache.xml.security.encryption.XMLCipher.loadEncryptedKey(Unknown Source)
at org.apache.xml.security.encryption.XMLCipher.loadEncryptedKey(Unknown Source)
at uoc.cripto.fases.fase21.decipherRSA(phase21.java:82)
at uoc.cripto.fases.fase21.main(phase21.java:100)I suppose that the problem is in the way I'm serializing to a file the ciphered XML document, or maybe the method to deserialize it. I'm using this code to serialize to a file:
public static void writeFile(Document doc, String fileName) throws Exception {
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Source input = new DOMSource(doc);
FileWriter writer = new FileWriter(fileName);
Result output = new StreamResult(writer);
transformer.transform(input, output);
}And for deserializing:
public static Document readFile (String fileName) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
File file = new File(fileName);
Document doc = builder.parse(file);
return doc;
}Can anyone help me? I'm seriously lost, and I need to solve this problem in order to pass a subject...
Thanks.Hi, all.
I've found the answer. It's enough to insert this line in the "readFile" function:
factory.setNamespaceAware(true);The exception seems to be thrown because the system can't find certain elements if the property NamespaceAware is false, and this is the default value.
So, that's all, folks!
Thank you for your patience, -
Problem validating XMl document
Hi everyone,
I'm facing a problem validating a XML document with Apache toolkit under windows XP and eclipse 3.0
I generate a pair of public/private keys using the RSA algorithm. The keys are of arbitrary length, but satisfying RSA conditions, ie we can encrypt and decrypt.
I can sign my XML document, but no way to validate it. Validation is only ok when I generate random keys using the KeyPairGenerator.
Do you think that arbitrary length keys don't allow to validate XML document. And do you have any idea how to solve the problem ( I'm not allowed to generate fixed length keys) ?
Thansk a lot for your precious help.solved!
urghh...forgot to load th eschema..duh. (must be friday)
here's the fixed code:
// parse the xml document (validate the xml string using a schema file)
// the xml document does not specified the System ID or location of
// schema..and use no namespace
public void parse(HandlerType type, String xmldoc) throws SAXException, IOException {
File schema = schemaMap.get(type);
DefaultHandler handler = handlerMap.get(yype);
XMLReader reader = XMLReaderFactory.createXMLReader(VENDOR);
InputSource source = new InputSource(new StringReader(xmldoc));
reader.setContentHandler(handler);
reader.setFeature("http://xml.org/sax/features/validation", true);
reader.setFeature("http://apache.org/xml/features/validation/schema", true);
reader.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
reader.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
"file:///" + schema.getAbsolutePath());
reader.parse(source);
}
Maybe you are looking for
-
Using database connection in a servlet and get errors after 8 hours
Hey, I'm running a poker script using applet/servlets and it works great. But for some reason about about 8 hours that database layer stops working. At first I thought it was the connections to mySQL that were timing out (because im using connection
-
Reports successfully execute but generate a login failed for user 'sa' err
I am running Crystal Reports Server XI R2. Classic ASP is used to generate embedded reports within our application. The crystal reports use ODBC to connect to a SQL Server 2005 database. The reports successfully generate in our Classic ASP applicatio
-
Need help setting up external hard drive for FCE project
Hi folks, Basically I am looking at making a 20-30 minute video this summer of my motocross adventures and what not and have equipped myself with an iMac (2.93 GHZ Core2Duo 640GB 4GB) and of course, FCE. I have tried smaller projects before (ranging
-
Hi, after numerous problems with "Mavericks" I have ditched it and returned to "Mountain Lion" however, whilst I have been able to rescue "pages", "numbers" etc, I am unable to return to the "mountain lion" version of iphoto. Can anyone offer any sug
-
Pls help me in writing a query for my problem !
I have to find out the amount(LAmt) for members who lie btw diff age groups, below are the table structures: table1 DOB ID 12/24/1986 F125 06/05/1988 F223 05/04/1987 F589 07/07/2001 F856 table2 LAmt ID LDate $56 F125 01/01/2011 $45 F223 08/22/2005 $8