Xml.getBytes("UTF-8")
Hi
I have seen xml.getBytes("UTF-8"). What is the use of this and Where can i get the other methods like getBytes(). e.g: xml.someMethod().
Please help.
Edited by: Monadear on Oct 18, 2007 11:37 AM
Is xml declared as a String? Read the javadoc for the String class.
http://java.sun.com/javase/6/docs/api/java/lang/String.html
Similar Messages
-
Hi all,
We are trying to interact with Documentum server through DFS exposed WCF which communicates through port 9443 and we are provided with documentum issued Public Key certificates. We have successfully imported the certificates in client machine and configured
the bindings as below in our .Net web application config file.
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding
name="ObjectServicePortBinding1">
<security
mode="Transport">
<transport
clientCredentialType="None"
proxyCredentialType="None"
realm=""
/>
<message
clientCredentialType="Certificate"
algorithmSuite="Default"
/>
</security>
</binding>
<binding
name="QueryServicePortBinding">
<security
mode="Transport">
<transport
clientCredentialType="None"
proxyCredentialType="None"
realm=""
/>
<message
clientCredentialType="Certificate"
algorithmSuite="Default"
/>
</security>
</binding>
</wsHttpBinding>
</bindings>
Also, we set the message encoding as MTOM and the wcf client object initialization code snippet is as below,
ObjectServicePortClient
serviceClient = new
ObjectServicePortClient(new
WSHttpBinding("ObjectServicePortBinding1"),
new
EndpointAddress(UriUtil.ObjectServiceUri));
if (serviceClient.Endpoint.Binding
is
WSHttpBinding)
WSHttpBinding
wsBinding = serviceClient.Endpoint.Binding as
WSHttpBinding;
wsBinding.MessageEncoding =
"MTOM".Equals(transferMode) ?
WSMessageEncoding.Mtom :
WSMessageEncoding.Text;
serviceClient.Endpoint.Behaviors.Add(new
ServiceContextBehavior(Config.RepositoryName,
Config.DocumentumUserName,
Config.DocumentumPassword));
When we execute the above code, we are getting error message as below,
Exception: The content type text/xml;charset=utf-8 of the response message does not match the content type of the binding (multipart/related; type="application/xop+xml"). If using a custom encoder, be sure that the IsContentTypeSupported
method is implemented properly. The first 407 bytes of the response were: '<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope"><faultcode>S:VersionMismatch</faultcode><faultstring>Couldn't
create SOAP message. Expecting Envelope in namespace http://schemas.xmlsoap.org/soap/envelope/, but got http://www.w3.org/2003/05/soap-envelope </faultstring></S:Fault></S:Body></S:Envelope>'
Then, we changed the bindings as below
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding
name="ObjectServicePortBinding1">
<security
mode="Transport">
<transport
clientCredentialType="Certificate"
proxyCredentialType="None"
realm=""
/>
<message
clientCredentialType="Certificate"
algorithmSuite="Default"
/>
</security>
</binding>
<binding
name="QueryServicePortBinding">
<security
mode="Transport">
<transport
clientCredentialType="
Certificate"
proxyCredentialType="None"
realm=""
/>
<message
clientCredentialType="Certificate"
algorithmSuite="Default"
/>
</security>
</binding>
</wsHttpBinding>
</bindings>
We are getting another error message,
Exception: The client certificate is not provided. Specify a client certificate in ClientCredentials.
Any pointers on resolving this issue would be highly helpful.
ThanksHi Dhanasegaran,
As per your case, the corresponding details which may guide you to resolve this issue:
1. First of all, you can try to call the wcf service directly from the browser & check where it will point out the correct location.
2. In config file ,Set IncludeExceptionDetailInFaults to true to enable exception information to flow to clients for debugging purposes .
Set this to true only during development to troubleshoot a service like below :
<serviceBehaviors>
<behavior name="metadataAndDebugEnabled">
<serviceDebug
includeExceptionDetailInFaults="true"
/>
<serviceMetadata
httpGetEnabled="true"
httpGetUrl=""
/>
</behavior>
</serviceBehaviors>
3. I suggest you to change that <security mode ="TransportWithMessageCredential"> instead of <security mode ="Transport">
for more information, refer the following link :
https://msdn.microsoft.com/en-us/library/aa354508(v=vs.110).aspx -
I have a WCF service I am trying to run on a new installation of 64-bit Windows Server 2008 IIS. Although it runs fine on Windows 2003 IIS, it is throwing the error in the thread title, which appears to be a server config issue, but I am not sure. Googling and searching the MSDN forums did not turn up a solution. I tried running WCF Logging, but that didn't help either.
Does anyone have any suggestions on how to solve this probelm?
Here is the error:
The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">I have the same issue on Windows 7 machine. The service works fine using a SoapUI client but a .Net client faisl to get a response.
Hi,
I have a WCF service which works perfectly when using SoapUI but throws error in my .Net client.
{"The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first
1024 bytes of the response were: '<HTML><HEAD><link rel=\"alternate\" type=\"text/xml\" href=\"http://xyz.mysite.com/ysa/Broker.svc?disco\"/><STYLE type=\"text/css\">#content{ FONT-SIZE: 0.7em;
PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT:
5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP:
0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE><TITLE>Broker
Service</TITLE></HEAD><BODY><DIV id=\"content\"><P class=\"head'."}
I have the same service hosted on my local machine and when I point to the local service I can execute the operation with no issues. The message encoding is Soap11. I tried changing to Soap12 but I get exact same error. Any ideas greatly appreciated.
I do have windows Activation Features installed and I am using .Net Framework 4.
Thanks
Sofia Khatoon -
Hi,
How can I change the content-type (text/xml;charset=utf-8) sent by the SOAP adapter to an external webservice?
I need to sent text/xml as content-type to the webservice, otherwise I get an error.
I have tried with different adapter modules but so far no positive results.
Thanks.
Edited by: Roberto Viana on Mar 26, 2009 2:02 PMHi Stefan, many thanks for your answer.
According to your answer it is not possible to manipulate/change the way PI fills the content-Type.
I was hoping to solve the issue with a custom built adapter module that sets the HTTP header content-type to text/xml without the charset entry, but I understand that's not the case.
Regards,
Roberto Viana -
HI all,
we try to post an XML message (cXML invoice) to a receiver but it doesn´t work.
We use a communication channel "http-destination" where we configure content-type "text/xml" together with XML encoding "UTF-8".
The configured URL works fine and can be tested in SM59.
The XML payload itself has a declaration <?xml version="1.0" encoding="UTF-8"?>
but the strange thing that happens is that all these declarations are being ignored and instead US-ASCII is used. Which leads to an error due to some special german characters within the contents of the XML (e.g. ä, ö, etc.).
Does anybody of you know how I can achieve that the pre-set UTF-8 will be used as encoding type???
Many thanky in advance!
Willi WuerstlinHi.
I am trying to map the standard cXML invoice to SAP's standard idoc INVOIC01 - This is how the file looks like
<?xml version="1.0" ?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.014/InvoiceDetail.dtd">
<cXML version="" payloadID="2008-07-29T04:51:08-06:00.cXML.TEST4101V002" timestamp="2008-07-29T04:51:08-06:00" xml:lang="en-US">
<Header>...</Header>
...</cxml>
I am having problem with the line <!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.014/InvoiceDetail.dtd"> - when the payload is having this line XI is not accepting the message.
Please let me know how to address this.
Thanks. -
Hi folks,
I'm trying to establish a CSTRING XML stream with utf-8 encoding. I've only managed to do this in XSTRING so far.
If i use this coding, i get a binary output.
DATA: gt_result TYPE TABLE OF string,
l_result type string.
constants: encoding type string value 'UTF-8'.
data: g_ixml type ref to if_ixml.
data: g_stream_factory type ref to IF_IXML_STREAM_FACTORY.
data: g_encoding type ref to if_ixml_encoding.
g_ixml = cl_ixml=>create( ).
g_stream_factory = g_ixml->CREATE_STREAM_FACTORY( ).
g_encoding = g_ixml->create_encoding( character_set = 'utf-8'
byte_order = 0 ).
data: resstream type ref to if_ixml_ostream.
resstream = g_stream_factory->create_ostream_cstring( l_result ).
call method resstream->set_encoding
EXPORTING
encoding = g_encoding.
* XML Transformieren
CALL TRANSFORMATION id_indent
SOURCE itab = it_Itab
RESULT XML resstream.
* Temporär, XML File erzeugen
refresh gt_result.
APPEND l_result TO gt_result.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = 'c:test.xml'
CHANGING
data_tab = gt_result
EXCEPTIONS
file_write_error = 1.
Without this expression :
g_encoding = g_ixml->create_encoding(
character_set = 'utf-8' byte_order = 0 ).
I get a cstring stream, but in utf-16.
My question now is, how do I manage to get a utf-8 encoded stream in cstring?
Thanks for your help.
Cheers
DanielThis is the solution:
METHOD TRANSFORM_XML.
TYPE-POOLS TRUXS.
*********************** XML ***********************************
DATA: GT_RESULT TYPE TABLE OF STRING,
L_RESULT TYPE ETXML_LINE_STR.
CONSTANTS: ENCODING TYPE STRING VALUE 'UTF-8'.
DATA: G_IXML TYPE REF TO IF_IXML.
DATA: G_STREAM_FACTORY TYPE REF TO IF_IXML_STREAM_FACTORY.
DATA: G_ENCODING TYPE REF TO IF_IXML_ENCODING.
G_IXML = CL_IXML=>CREATE( ).
G_STREAM_FACTORY = G_IXML->CREATE_STREAM_FACTORY( ).
G_ENCODING = G_IXML->CREATE_ENCODING( CHARACTER_SET = ENCODING
BYTE_ORDER = 0 ).
DATA: RESSTREAM TYPE REF TO IF_IXML_OSTREAM.
RESSTREAM = G_STREAM_FACTORY->CREATE_OSTREAM_XSTRING( L_RESULT ).
CALL METHOD RESSTREAM->SET_ENCODING
EXPORTING
ENCODING = G_ENCODING.
* XML Transformieren
CALL TRANSFORMATION ID_INDENT
SOURCE ITAB = IT_ITAB
RESULT XML RESSTREAM.
* XString to String
CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
EXPORTING
IM_XSTRING = L_RESULT
IM_ENCODING = 'UTF-8'
IMPORTING
EX_STRING = E_XML.
* Temporär, XML File erzeugen
refresh gt_result.
APPEND e_xml TO gt_result.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = 'c:test.xml'
CHANGING
data_tab = gt_result
EXCEPTIONS
file_write_error = 1.
ENDMETHOD.
How can I give the 10 points to myself?
Cheers
Daniel -
DMEE: XML Encoding UTF-8/UTF-16
Hi,
I'm generating automatic payment files via program run SAPFPAYM_SCHEDULE.
The file is generated under UTF-8 but when generated on SAP server become UTF-16.
=> When double clicking on the Z_XML20022 and clicking on glasses you can see "<?xml version="1.0"
encoding="utf-8"?>"
=> When you have a look under AL11
/interfaces_sec/DECCLNT300/FI_payment_SAP032/out/PSAPCIT.PAYMENT_CN10_1. it's <?xml version="1.0"
encoding="utf-16"?>
I need to have utf-8.
Thanks in advance for your help.Hi,
If you using XSLT, you may use this transformation (based on your XML example, but simplified):
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl"
xmlns:am="http://www.xxx.com/ActionMessage"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output encoding="utf-8"/>
"your rest XML data"
</xsl:transform>
PS: I advise you to read the Note 1017101 - Encoding Problems with ABAP XML Processing, which explains better what I said above. -
XML encoding UTF-8 and accents
hello everybody !
a little problem with my xml file,
===========
<?xml version="1.0" encoding="UTF-8"?>
<videoData>
<video1
thumbtitle = "Soirs de fêtes - défilé de mode"
buffTime = "2"
header = "my description"
>flv/video1.flv</video1>
</videoData>
===========
my problem : no accent appears in my flash, and the result is : Soirs de ftes - dfil de mode
I read a lot of articles on different forums regarding the good encoding, it seems that <?xml version="1.0" encoding="UTF-8"?> is the good one
so I don't understand what is wrong.
I also use .txt file in other part of my website in flash, and I also have the same problem
I suppose it is in the actionscript I must write something :
===========
myLoadVars = new LoadVars();
myLoadVars.onLoad = function() {
myText.htmlText = myLoadVars.myHTMLdata;
myLoadVars.load("page1Text.txt");
============
Can somebody help me ?
thanks in advance for your help
FrançoiseHi.
I am trying to map the standard cXML invoice to SAP's standard idoc INVOIC01 - This is how the file looks like
<?xml version="1.0" ?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.014/InvoiceDetail.dtd">
<cXML version="" payloadID="2008-07-29T04:51:08-06:00.cXML.TEST4101V002" timestamp="2008-07-29T04:51:08-06:00" xml:lang="en-US">
<Header>...</Header>
...</cxml>
I am having problem with the line <!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.014/InvoiceDetail.dtd"> - when the payload is having this line XI is not accepting the message.
Please let me know how to address this.
Thanks. -
1. OracleXML Parser for PL/SQL can not parse XML docs encoded in UTF-8 format containing swedish E, D, V.
2. I can save XML(UTF-8) docs as CLOBs but E, D, V are not searchable with intermedia.
Using:
DB: 8.1.6
Oracle XML Parser for PL/SQl 1.0.2
DB char set: 8859-1
Tried to install DB with UTF8 char. set. Doesn't help!
Has anybody any idea how to solve it???
Thank youGregori!
In XML Header you have to set the encoding to ISO-8859-1
<?xml version='1.0' encoding='ISO-8859-1'?>.
This will allow you to parse the document correctly and save it in the database.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Grigori Genin ([email protected]):
1. OracleXML Parser for PL/SQL can not parse XML docs encoded in UTF-8 format containing swedish E, D, V.
2. I can save XML(UTF-8) docs as CLOBs but E, D, V are not searchable with intermedia.
Using:
DB: 8.1.6
Oracle XML Parser for PL/SQl 1.0.2
DB char set: 8859-1
Tried to install DB with UTF8 char. set. Doesn't help!
Has anybody any idea how to solve it???
Thank you<HR></BLOCKQUOTE>
null -
Hi
I am trying to reverse an Unicode 16 XML file.
The driver I am using is the following
JDBC DRIVER : com.sunopsis.jdbc.driver.xml.SnpsXmlDriver
JDBC URL : jdbc:snps:xml?f=C:/EMP.xml&s=EMP01
I am getting
"java.sql.SQLException: While generating the DTD from the XML file, a org.xml.sax.SAXParseException exception occurred saying: The encoding "UTF-16" is not supported."
error message. Whats the driver for UTF-16 XML files. If there a new jar file for it.
-appI am answering my own question. Issue was with XML file. So UTF-16 and UTF-8 have same JDBC driver.
-app -
Adobe Designer 7.0 - XML parsing error when data connection to XML with UTF-16
Hi all
<br />
<br />I need to change my data connection xml file to use UTF-16 instead of ISO-8859-1. When I connect the file with the UTF-16 encoding, I receive the following error
<br />
<br />Invalid XML: Xml parsing error: encoding specified in XML declaration is incorrect (error code 19) ..
<br />
<br />The XML declaration is:
<br /><?xml version="1.0" encoding="utf-16"?>
<br />
<br />I am able to succesfully set the encoding to "UTF-8". UTF-16 should also be possible.
<br />
<br />Has anyone seen this error before ? How can I resolve this ?
<br />
<br />Thanks in advance
<br />
<br />Bilal HaniffThank you, expert, for your quick reply.
Described problem got solved: we noticed later that the extra text only appears for users using Adobe professional 7.0, 'normal' users with adobe 8.0 reader don't get the extra text, so that is ok for us. -
Hello,
I call rfc (via xi) and get result as flat xml String from r/3.
This string contains english and hebrew characters. The english is o.k. but the value nodes in hebrew looks like " ׳ ׳�׳ ׳�׳׳ ׳׳�׳¨׳׳/׳׳׳�׳� "
how can i convert the string in order to see my language characters?
I think the source unicode is utf-8, and i need to convert it to utf-16 but i'm not sure about that nor how to do that.
Thanks for your help.
Roni.Hi Roni,
If your RFC returns an XML file as a java.lang.String object, the String itself is by definition UTF-16. To see if the XML file is correct, you could write it to disk and open it with your favourite text editor. Something like this.
private void save(String xml) throws IOException {
OutputStream out = new FileOutputStream(new File("/tmp/result.xml"));
out.write(xml.getBytes("UTF-8"));
out.close();
Or whatever supported encoding you like and that's supported by your text editor, e.g. ISO-8859-8 is Latin/Hebrew Alphabet; see http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html
Obviously, to correctly see the characters you need the necessary fonts too.
In case the above doesn't work, it means the xml String you receive from the RFC call is already corrupt. However, if it does work, the RFC as such works correctly.
The next step is likely to parse the XML to extract the information you need and store it in your Web Dynpro context. An XML parser usually expects bytes (a java.io.InputStream) as input, which means you need to convert the String to bytes and by doing that, you need to choose a character encoding. It could be something like the following.
SAXParserFactory.newInstance().newSAXParser().parse(new ByteArrayInputStream(xml.getBytes("UTF-8")), handler);
Note that the character encoding you specify here does make a difference. It should be the same, in order not to "confuse" the XML parser, as defined in the XML file's document type declaration, e.g. <?xml version="1.0" encoding="UTF-8"?>
BTW, what exactly do you do with the received XML to obtain the value nodes?
Kind regards,
Sigiswald -
Showing xml with xsl in a java webapplication
Dear members,
what are the possible ways to show an XML file in a web application written in java?
The xml file has to be transformed by a corresponding xsl file.
Regards,
Katjabhupesh,
Try my solution described here:
/people/valery.silaev/blog/2005/11/23/display-formatted-text-using-webdynpro-for-java
final String xml = <yorXmlStringFromRfc>;
final IWDCachedWebResource resource = WDWebResource.getWebResource
xml.getBytes("UTF-8"),
WDWebResourceType.XML
resource.setResourceName("XML_inline.xml");
resource.setAttachement( false );
resource.setReadOnce( false );
wdComponentAPI.getWindowManager.createExternalWindow
resource.getAbsoluteURL(), "XML Window Title", false
).open();
VS
Message was edited by: Valery Silaev -
SBL-EAI-08006 error!!!
Hi
I am trying to send a SOAP request to get the list of Integration Event using the following code:
String sURL = "https://secure-ausomxaxa.crmondemand.com/Services/Integration"
+ ";jsessionid="+getSessionId();
URL url = new URL(sURL);
HttpURLConnection uc = (HttpURLConnection)url.openConnection();
uc.setRequestProperty("SOAPAction", "document/urn:crmondemand/ws/integrationevent/:GetEvents");
uc.setRequestProperty("Cookie",sessionCookie);
uc.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setRequestMethod("POST");
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"
+ "<soap:Body>"
+ " <IntegrationEventWS_GetEvents_Input xmlns=\"urn:crmondemand/ws/integrationevent/\">"
+ " <EventCount/>"
+ " </IntegrationEventWS_GetEvents_Input>"
+ "</soap:Body>"
+ "</soap:Envelope>";
OutputStream out = uc.getOutputStream();
out.write(xml.getBytes("UTF-8"));
out.flush();
out.close();
But I am getting the following SOAP error when I try to send the SOAP request.
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>SOAPAction '<?>' is of invalid format: SOAPAction should be of the form "rpc/operationName" or "document/operationName".(SBL-EAI-08006)</faultstring>
<detail>
<siebelf:errorstack xmlns:siebelf="http://www.siebel.com/ws/fault">
<siebelf:error>
<siebelf:errorsymbol />
<siebelf:errormsg>SOAPAction '<?>' is of invalid format: SOAPAction should be of the form "rpc/operationName" or "document/operationName".(SBL-EAI-08006)</siebelf:errormsg>
</siebelf:error>
</siebelf:errorstack>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Is there anything else that needs to be added to the code?
글 수정: infinite05I can see many problem here.
1. First you said you are trying to get Activity Id but code is written for Query Contact
2. Code is written for Query Contacts, but soap action is specified for Get Integration Events
3. Soap Action which you are passing is wrong, it should be in double quotes.
Dinesh -
DBMS_XDB.CREATERESOURCE from JAVA
Hi all,
i'm trying to load XML-data into the database with the following pseudocode:
SQLText := "DECLARE
retB boolean;
XMLDoc XMLType;
BEGIN
XMLDoc := XMLType(?);
retB := DBMS_XDB.CREATERESOURCE('Resourcename', XMLDoc);
END";
SQLStmt := (OraclePreparedStatement) _conn.prepareStatement(SQLText);
SQLStmt.setString(1, xml);
SQLStmt.execute();
It works in JAVA with one exception. All characters using more than one byte in UTF-8 are double encoded. That means, if the XML-String contains an german umlaut ä (U+00E4) this character is encoded as "C3 A4" in the string. After submitting the XML to the database the ä has the value C3 83 C2 A4 => the value C3 is encoded as C3 83 and the value A4 is encoded as C2 A4.
Thats no problem if i query the documents from Java because the way back is the same. But if i retrieve the document over the protocoll server (WebDav or FTP) the character encoding is corrupted (2 characters for ä).
I am using Ora 11.2.0.1 on Linux with ojdbc6.jar. My NLS settings are as follows:
NLS_LANGUAGE GERMAN
NLS_TERRITORY GERMANY
NLS_CHARACTERSET AL32UTF8
NLS_NCHAR_CHARACTERSET AL16UTF16
On the client GERMAN_GERMANY.WE8MSWIN1252, but i also tried with SET NLS_LANG=GERMAN_GERMANY.AL32UTF8 because of the UTF coding of the XML string.
What I am doing the wrong way?
Thanks for your help,
regards
FrankHi odie_63,
thanks for your reply. I have extracted the relevant code of the program into a tiny test application.
package project1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.text.MessageFormat;
import oracle.jdbc.OraclePreparedStatement;
import oracle.ucp.jdbc.PoolDataSource;
import oracle.ucp.jdbc.PoolDataSourceFactory;
public class Application1 {
public static void main(String[] args) {
try {
doSimpleTest();
} catch (Exception e) {
e.printStackTrace();
public static void doSimpleTest(){
System.out.println("doing simple test case...");
final String insertSQL = " DECLARE\n" +
" retB boolean;\n" +
" XMLDoc XMLType;\n" +
" BEGIN\n" +
" XMLDoc := XMLType(?);\n" +
" retB := DBMS_XDB.CREATERESOURCE({0},XMLDoc); \n" +
" END;";
final String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><test xmlns=\"http://www.gfai.de/Test\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.gfai.de/Test http://www.gfai.de/Test\">äöü</test>";
String SQL_QUERY = null;
PoolDataSource _pds = null;
Connection _conn = null;
OraclePreparedStatement s = null;
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//Creating a pool-enabled data source
_pds = PoolDataSourceFactory.getPoolDataSource();
//Setting connection properties of the data source
_pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
_pds.setURL("jdbc:oracle:thin:@10.10.182.110:1521:ORALX64");
_pds.setUser("test");
_pds.setPassword("tset");
//Setting pool properties
_pds.setInitialPoolSize(5);
_pds.setMinPoolSize(5);
_pds.setMaxPoolSize(10);
// connection
_conn = _pds.getConnection();
// Insert
SQL_QUERY = MessageFormat.format(insertSQL, new Object[]{"'/public/test/test.xml'"});
s = (OraclePreparedStatement) _conn.prepareStatement(SQL_QUERY);
s.setString(1, new String(xml.getBytes("UTF-8")));
s.execute();
System.out.println("inserted...");
catch(Exception ex){
ex.printStackTrace();
finally{
try{s.close();_conn.close();}catch(Exception ex){};
return;
Before running the test it's required to set up the user test and the XML-schema. I have done it with the following lines of code:
CONNECT SYSTEM;
CREATE USER TEST IDENTIFIED BY "tset";
GRANT CREATE SESSION TO TEST;
GRANT RESOURCE TO TEST;
DECLARE
RETB BOOLEAN;
BEGIN
RETB := DBMS_XDB.CREATEFOLDER('/sys/schemas/PUBLIC/www.gfai.de');
RETB := DBMS_XDB.CREATEFOLDER('/sys/schemas/PUBLIC/www.gfai.de/test');
RETB := DBMS_XDB.CREATEFOLDER('/public/test');
COMMIT;
END;
CREATE OR REPLACE DIRECTORY TEST_DIR AS '/home/oracle';
GRANT READ ON DIRECTORY TEST_DIR TO test;
BEGIN
DBMS_XMLSCHEMA.registerSchema(
SCHEMAURL => 'http://www.gfai.de/Test',
SCHEMADOC => BFILENAME('TEST_DIR','Test.xsd'),
LOCAL => FALSE,
GENTYPES => TRUE,
GENTABLES => TRUE);
END;
After executing the test case i get the following results with sqlplus:
SQL> select dump(extractvalue(object_value,'/test')) from test_document;
DUMP(EXTRACTVALUE(OBJECT_VALUE,'/TEST'))
Typ=1 Len=12: 195,131,194,164,195,131,194,182,195,131,194,188
SQL>
The whole document is saved as
SQL> select xdburitype('/public/test/test.xml').getblob() from dual;
XDBURITYPE('/PUBLIC/TEST/TEST.XML').GETBLOB()
3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D225554462D38223F3E0A3C
7465737420786D6C6E733D22687474703A2F2F7777772E676661692E64652F546573742220786D6C
6E733A7873693D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D61
2D696E7374616E636522207873693A736368656D614C6F636174696F6E3D22687474703A2F2F7777
772E676661692E64652F5465737420687474703A2F2F7777772E676661692E64652F54657374223E
C383C2A4C383C2B6C383C2BC3C2F746573743E0A
SQL>
The schema definition file is as follows:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.gfai.de/Test"
targetNamespace="http://www.gfai.de/Test"
elementFormDefault="qualified"
xmlns:xdb="http://xmlns.oracle.com/xdb"
xdb:storeVarrayAsTable="true">
<xsd:element name="test" xdb:defaultTableSchema="TEST"
xdb:defaultTable="TEST_DOCUMENT">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:Schema>
thanks again,
regards
Frank
Maybe you are looking for
-
Error 1045 Using Report Generation Excel 2010
Hello, The attached code throws an error 1045 when using Excel 2010. I don't get this error when using Excel 2007. Please Advise Thanks Attachments: Source.zip 66 KB
-
ICal search doesn't find anything
when I test this by creating a future event with a particular word in it, then return to today and search for that word in the little "search" box at top right, it doesn't find that word. Why not?
-
sir, i have HP 8gb pen drive when insuret XXXXXXXX drivers is instuled Removebal Disk. whine opean insuret disk error come i have very importent Data as thier please satout this problem Thank you Pradeep
-
Migrating Japanese Characters from MS SQL Server 2000 to Oracle 9i usng Jsp
Hi , I have a situation where the Japanese characters are to be migrated from MS SQL Server 2000 to Oracle 91 and then render the same using JSP. I followed the below approach, 1. Extract the Japanese data from MS SQL Server and generate an XML 2. Pa
-
I'm experiencing strange behavior with my MacBookPro. I use .mac mail on three machines. They all sync-up beautifully. Occasionally however, a message on the MBP switches identity. That is, in the list pane, it says it's a message from person-X, yet