Seems to me that the encoding on the character string is not UTF-8. Not a big surprise as it is coming from navigator, and there is a good chance that by the time the query makes it to IBM i the encoding is EBCDIC, not exactly sure what Navigator for i sends along. But you don't have to convert literal constants to EBCDIC to make comparisons. I don't know how to correct this though since I have not ever stored XML in the database. How is the table defined.
Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx
-----Rob <rob.couch@xxxxxxxxxxxxxx> wrote: -----
To: "Web Enabling the IBM i (AS/400 and iSeries)" <web400@xxxxxxxxxxxx>
From: Rob <rob.couch@xxxxxxxxxxxxxx>
Date: 11/24/2015 11:54AM
Subject: [WEB400] INSERT xml not working...
Has anyone used an xml field?
So I have learned that v7r1 DB2 has native xml support automatically.
I have created a table... with ID Bigint Identity, Type smallint,
Request xml.
This is my SQL using System i Navigator... I am running manual queries
until I can get it working, as it is failing in my PHP...
If all I insert is the Type... everything is fine... I have edited the
XML down to a single line.... still no joy...
insert into KWDB108.XMLReq ( Type, Request ) VALUES ( 2, '<?xml
version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:storis="
http://Storis">
<soapenv:Body>
<company:CreditApplicationRequest>
<mainFirstName>Jack</mainFirstName>
<mainLastName>Smith</mainLastName>
<mainMiddleInitial>A</mainMiddleInitial>
</company:CreditApplicationRequest>
</soapenv:Body>
</soapenv:Envelope>' ) ;
In The System i Messages Box I get....
INSERT INTO KWDB108.XMLReq ( Type, Request ) VALUES ( 2, '<?xml
version="1.0" encoding="utf-8"?> <soapenv:Envelope
xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:storis="
http://Storis"> <soapenv:Body>
<company:CreditApplicationRequest> <mainFirstName>Jack</mainFirstName>
<mainLastName>Smith</mainLastName>
<mainMiddleInitial>A</mainMiddleInitial>
</company:CreditApplicationRequest> </soapenv:Body> </soapenv:Envelope>' )
SQL State: 2200M
Vendor Code: -16168
Message: [SQ16168] XML declaration in XML document not valid. Cause . .
. . . : The XML declaration in the XML document or XML schema is
incorrect. The error type is 7. The error types are: 1 -- Unsupported
Byte Order Mark, declaration string order is incorrect, declaration must
be in lower case, the 'version=' string is missing, or unsupported
attributes were specified. 6 -- Specified version is not supported. 7 --
Specified encoding is not supported, or the internal encoding does not
match the external encoding. 8 -- The XML declaration is not terminated.
Recovery . . . : Correct the XML document. Try the request again.
The error codes are so vague....
Thanks,
Rob
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
As an Amazon Associate we earn from qualifying purchases.