[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: xml-sax issue
The service program was build with WSDL2RPG and that is where the varying
was set. I just never changed it.
> Stripped out the subst and it bombs.
>
> the XML parser detected error code 302.
>
>
>> I am not clear as to why you would be using a VarChar field in any
>> case.
>> The data coming in is not a VarChar. It is a straight character and
>> you
>> would not be trimming it.
>> The data length parameter says how long the data actually is. All it
>> is
>> passing is a pointer to the data so as in my example program
>> dcl-s Data Char(32765) Based(InPointerToData);
>> So lets say it a Order number and the length says 7.
>> OrderNumber = %Subst(Data:1:Length);
>> This pulls that value out of the incoming field.
>> Now if you try to reference anything past 7 in this example, you are
>> going to get garbage.
>> On the next *XMLCHARS event it might be 50.
>> You need to look for *XML_START_ELEMENT and see if this an element
>> that
>> you want.
>> What I do is just build a tag.
>> So first time in
>> /REQUEST
>> Then
>> /REQUEST/ORDER
>> then
>> /REQUEST/ORDER/NUMBER
>> Then in the *XML_CHARS event I just compare to see if I want to
>> process
>> that event
>> If Tag = '/REQUEST/ORDER/NUMBER';
>> Â // Process order number.
>> etc.
>>
>> On Tue, Sep 8, 2015 at 12:44 PM, Elbert Cook
>> <[1]elbert@xxxxxxxxxxxxxxx> wrote:
>>
>> Â Â Could the problem be something like the following scenario. If
>> not my
>> Â Â apologizes for not understanding the question.
>> Â Â xml = %trim(%subst(GetResponse: 3: 5000));
>> Â Â When you have a varying field, the field contains 2 extra
>> invisible
>> Â Â positions, contain the length of the data.
>> Â Â D Data1 s 20a
>> Â Â D Data2 s 20a
>> Â Â D Data3 s 20a
>> Â Â D ds
>> Â Â D GetResponse 20a varying inz('<MMMProcess>')
>> Â Â D InvisLen 2a overlay(GetResponse: 1)
>> Â Â D Value 20a overlay(GetResponse: 3)
>> Â Â Data1 = Value;
>> Â Â Data2 = %subst(GetResponse: 1)
>> Â Â Data3 = %subst(GetResponse: 3)
>> Â Â Data1 contains "<MMMProcess>"
>> Â Â Data2 contains "<MMMProcess>"
>> Â Â Data3 contains "MMProcess>"
>> Â Â With %subst your start with position 1, if you are using a
>> data
>> Â Â structure
>> Â Â you start with position 3.
>> Â Â ----> I'm getting a weird character Ã<MMMProcess>
>> Â Â Yes, GetResponse would have a weird first two position if you
>> are
>> Â Â retrieving
>> Â Â the first two invisible fields.
>> Â Â -----Original Message-----
>> Â Â From: Paul Roy [mailto:[2]paul.roy@xxxxxxx]
>> Â Â Sent: Tuesday, September 08, 2015 3:02 PM
>> Â Â To: HTTPAPI and FTPAPI Projects
>> Â Â Subject: Re: xml-sax issue
>> Â Â that's looks like a problem of a variable length string not
>> correctly
>> Â Â defined...
>> Â Â mismatch in a definition of a program/procedure ?
>> Â Â Paul
>> Â Â From: "RPG List" <[3]rpglist@xxxxxxxxxxx>
>> Â Â To: "HTTPAPI and FTPAPI Projects"
>> <[4]ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
>> Â Â Date: 08/09/2015 19:42
>> Â Â Subject: Re: xml-sax issue
>> Â Â Sent by: [1][5]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>> Â Â John,
>> Â Â I don't recall off the top of my head. He tried sending it as
>> UTF-16
>> Â Â but
>> Â Â its defaulting to 8 so I'm not sure if that's the problem or
>> not.
>> Â Â I recompiled the srvpgm and stubs and created the sample
>> program, in
>> Â Â debug
>> Â Â when I check the xml value immediately following the web
>> service call
>> Â Â I'm
>> Â Â getting a weird character Ã<MMMProcess>
>> Â Â and it is starting in position 2. I don't recall seeing this
>> before.
>> Â Â Ideas?
>> Â Â > XML-INTO is usually a lot less work than XML-SAX unless you
>> only want
>> Â Â > a small portion of the data. From what you posted earlier it
>> didn?t
>> Â Â > look that complex - what problems did you encounter with
>> XML-INTO?
>> Â Â >
>> Â Â >
>> Â Â > On Sep 8, 2015, at 2:21 PM, RPG List
>> <[6]rpglist@xxxxxxxxxxx>
>> wrote:
>> Â Â >
>> Â Â >> Scott the 3:5000 is a typo, that should be a 1.
>> Â Â >>
>> Â Â >> I am using XML-SAX because I wasn't able to get XML-INTO to
>> work.
>> Â Â >> However, I found out this morning that the XML is coming in
>> as
>> Â Â UTF-8.
>> Â Â >> I asked him to change that to 16 for a test, since I recall
>> reading
>> Â Â >> that RPG does not like 8.
>> Â Â >>
>> Â Â >> I'm open to suggestions to make this learning curve easier
>> Â Â >>
>> Â Â >>
>> Â Â >>> Dutch,
>> Â Â >>>
>> Â Â >>> You are doing this:
>> Â Â >>>
>> Â Â >>> xml = %trim(%subSt(GetResponse:3:5000));
>> Â Â >>>
>> Â Â >>> Can you explain why you are doing that %subst? Wouldn't
>> that cause
>> Â Â the
>> Â Â >>> '<M' at the start of the XML document to be chopped off,
>> making
>> Â Â this
>> Â Â an
>> Â Â >>> invalid document?
>> Â Â >>>
>> Â Â >>> The %trim() is not necessary, but shouldn't hurt anything.
>> Â Â >>>
>> Â Â >>> Can you explain why you want to use XML-SAX here instead
>> of
>> Â Â XML-INTO
>> Â Â or
>> Â Â >>> the XML parser included with HTTPAPI? (Which is a wrapper
>> around
>> Â Â >>> Expat)
>> Â Â >>>
>> Â Â >>>
>> Â Â >>> On 9/4/2015 4:34 PM, RPG List wrote:
>> Â Â >>>> Scott,
>> Â Â >>>> I'm not sure we don't have another problem. Here's why
>> when I step
>> Â Â >>>> through the xmlhandler, I get the start_document on the
>> first
>> Â Â read,
>> Â Â >>>> and then I get end_document on the second read. That's
>> it.
>> Its
>> Â Â >>>> almost
>> Â Â as
>> Â Â >>>> though its never seeing the data further. I ran a test
>> using the
>> Â Â >>>> following:
>> Â Â >>>>
>> Â Â >>>> XML = '<xmlTest>+
>> Â Â >>>> <name type="author">AS400 Sample Code/name>+
>> Â Â >>>> </xmlTest>';
>> Â Â >>>>
>> Â Â >>>> that worked.
>> Â Â >>>>
>> Â Â >>>> Here is what the xml document looks like coming in:
>> Â Â >>>>
>> Â Â >>>>
>> '<MMMProcess><Results><Claim>8104550</Claim><Amount>1995.83</'
>> Â Â >>>> 'Amount><Code>7320</Code><Xrg>53</Xrg><MEANLOS2>2</MEAN'
>> Â Â >>>> 'LOS2><Error_Code>0</Error_Code></Results></MMMProcess>'
>> Â Â >>>>
>> Â Â >>>>
>> Â Â >>>> I just can't find what's wrong with the xml..
>> Â Â >>>>
>> Â Â >>>>
>> Â Â >>>>> Dutch,
>> Â Â >>>>>
>> Â Â >>>>> The XML processing instructions ("header" as you call
>> it)
>> are
>> Â Â >>>>> optional.
>> Â Â >>>>> They are not required.
>> Â Â >>>>>
>> Â Â >>>>> The problem is what I said in my first reply to you.
>> Please read
>> Â Â the
>> Â Â >>>>> article I linked to so you can learn how XML-SAX works.
>> Â Â >>>>>
>> Â Â >>>>> -SK
>> Â Â >>>>>
>> Â Â >>>>>
>> Â Â >>>>> On 9/4/2015 3:18 PM, RPG List wrote:
>> Â Â >>>>>> one additional issue I saw this morning Scott and maybe
>> this is
>> Â Â >>>>>> the problem, the incoming XML does not have what I
>> would
>> call a
>> Â Â standard
>> Â Â >>>>>> header:
>> Â Â >>>>>>
>> Â Â >>>>>> IE: it does not have a version or description that I
>> see
>> in most
>> Â Â xml
>> Â Â >>>>>> documents, maybe that's needed or maybe not?
>> Â Â >>>>>>
>> Â Â >>>>>>
>> Â Â >>>>>>> Dutch,
>> Â Â >>>>>>>
>> Â Â >>>>>>> This looks an awful lot like a program that I wrote a
>> long time
>> Â Â ago
>> Â Â >>>>>>> to
>> Â Â >>>>>>> print the XML events. I would not recommend using this
>> to
>> Â Â actually
>> Â Â >>>>>>> parse a document -- to parse with XML-SAX you're going
>> to need
>> Â Â >>>>>>> to create a stack of XML elements (implemented in RPG
>> as an
>> Â Â >>>>>>> array, most
>> Â Â >>>>>>> likely)
>> Â Â >>>>>>> and keep track of the current XML element you're
>> working on,
>> Â Â etc.
>> Â Â >>>>>>> There
>> Â Â >>>>>>> was another program included in that same article
>> called
>> Â Â "CustXml"
>> Â Â >>>>>>> that
>> Â Â >>>>>>> demonstrates this -- that program would be a better
>> starting
>> Â Â point.
>> Â Â >>>>>>>
>> Â
>> Â
>> [2][7]http://iprodeveloper.com/print/rpg-programming/rpgs-xml-sax-
>> opco
>> Â Â >>>>>>> de
>> Â Â >>>>>>>
>> Â Â >>>>>>> (use the "print" option to format the code better,
>> Penton media
>> Â Â has
>> Â Â >>>>>>> screwed up the code figures in their article archive)
>> Â Â >>>>>>>
>> Â Â >>>>>>> Based on what you've shown us, the only thing you'd
>> get
>> in your
>> Â Â >>>>>>> string is the name of the XML tag you're parsing.
>> (Since that's
>> Â Â >>>>>>> what's pointed to by "string" during the
>> XML_START_ELEMENT
>> Â Â >>>>>>> event.)
>> Â Â >>>>>>>
>> Â Â >>>>>>> You say you're getting nothing at all...? Since you're
>> getting
>> Â Â >>>>>>> it from the 'value' field, you'd need to show us the
>> definition
>> Â Â >>>>>>> and/or
>> Â Â code
>> Â Â >>>>>>> that
>> Â Â >>>>>>> populates 'value' for us to see how that works. Funny
>> that you
>> Â Â >>>>>>> omitted that part of the code considering that your
>> question is
>> Â Â >>>>>>> about it?
>> Â Â >>>>>>>
>> Â Â >>>>>>> Also, is this part of a program that uses HTTPAPI or
>> FTPAPI? If
>> Â Â >>>>>>> so, I
>> Â Â >>>>>>> guess we can discuss it here... if not, however, this
>> really
>> Â Â >>>>>>> doesn't
>> Â Â >>>>>>> belong on this mailing list.
>> Â Â >>>>>>>
>> Â Â >>>>>>> -SK
>> Â Â >>>>>>>
>> Â Â >>>>>>>
>> Â Â >>>>>>> On 9/3/2015 9:17 PM, RPG List wrote:
>> Â Â >>>>>>>> I am attempting to parse out the data I'm getting
>> from
>> a web
>> Â Â >>>>>>>> service and I'm having a little trouble.
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> I'm using the following as my to the handler:
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> xml = %trim(%subSt(GetResponse:3:5000));
>> Â Â >>>>>>>> xml-sax %handler(xmlHandler: ignoreMe)
>> Â Â >>>>>>>> %XML(xml: 'doc=string');
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> GetResponse has the full xml string I'm expecting.
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> my xmlhandler is defined as follows:
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> P xmlHandler b
>> Â Â >>>>>>>> D pi 10i 0
>> Â Â >>>>>>>> D ignore 1a
>> Â Â >>>>>>>> D event 10i 0 value
>> Â Â >>>>>>>> D string * value
>> Â Â >>>>>>>> D stringLen 20i 0 value
>> Â Â >>>>>>>> D exceptionId 10i 0 value
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> I then have the following code in the procedure:
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> OutputXML.name = XML_Event_Name(event);
>> OutputXML.data
>> =
>> Â Â >>>>>>>> *blanks;
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> select;
>> Â Â >>>>>>>> when string=*null or stringlen<1;
>> Â Â >>>>>>>> // no string given...
>> Â Â >>>>>>>> when stringlen>%size(value);
>> Â Â >>>>>>>> OutputXML.data = '** string length invalid'; other;
>> Â Â >>>>>>>> OutputXML.data = %subst(value:1:stringlen); endsl;
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> // Change Current XML group if applicable Select;
>> Â Â >>>>>>>> When OutputXML.name = 'XML_START_ELEMENT';
>> Â Â >>>>>>>>
>> Â Â >>>>>>>>
>> Â Â >>>>>>>>
>> Â Â >>>>>>>>
>> Â Â >>>>>>>> The problem is outputXML.data never has a value that
>> I
>> can
>> Â Â see.
>> Â Â >>>>>>>> Am
>> Â Â >>>>>>>> I
>> Â Â >>>>>>>> doing something wrong or am I missing a step?
>> Â Â >>>>>>>>
>> Â Â >>>>>>>>
>> Â Â >>>>>>>>
>> Â Â >>>>>>>>
>> Â Â >>>>>>>>
>> Â Â >>>>>
>> Â Â >>>
>> Â Â >>>
>> Â
>> Â
>> ------------------------------------------------------------------
>> -----
>> Â Â >>> This is the FTPAPI mailing list. To unsubscribe, please go
>> to:
>> Â Â >>> [3][8]http://www.scottklement.com/mailman/listinfo/ftpapi
>> Â Â >>>
>> Â
>> Â
>> ------------------------------------------------------------------
>> -----
>> Â Â >>>
>> Â Â >>
>> Â Â >>
>> Â Â >>
>> Â
>> Â
>> ------------------------------------------------------------------
>> -----
>> Â Â >> This is the FTPAPI mailing list. To unsubscribe, please go
>> to:
>> Â Â >> [4][9]http://www.scottklement.com/mailman/listinfo/ftpapi
>> Â Â >>
>> Â
>> Â
>> ------------------------------------------------------------------
>> -----
>> Â Â >
>> Â Â > Jon Paris
>> Â Â >
>> Â Â > [5][10]www.partner400.com
>> Â Â > [6][11]www.SystemiDeveloper.com
>> Â Â >
>> Â Â >
>> Â
>> Â
>> ------------------------------------------------------------------
>> -----
>> Â Â > This is the FTPAPI mailing list. To unsubscribe, please go
>> to:
>> Â Â > [7][12]http://www.scottklement.com/mailman/listinfo/ftpapi
>> Â Â >
>> Â
>> Â
>> ------------------------------------------------------------------
>> -----
>> Â Â >
>> Â Â >
>> Â
>> Â
>> ------------------------------------------------------------------
>> -----
>> Â Â This is the FTPAPI mailing list. To unsubscribe, please go to:
>> Â Â [8][13]http://www.scottklement.com/mailman/listinfo/ftpapi
>> Â
>> Â
>> ------------------------------------------------------------------
>> -----
>> Â Â Disclaimer
>> Â Â The information contained in this communication from the
>> sender
>> is
>> Â Â confidential. It is intended solely for use by the recipient
>> and others
>> Â Â authorized to receive it. If you are not the recipient, you
>> are
>> hereby
>> Â Â notified that any disclosure, copying, distribution or taking
>> action in
>> Â Â relation of the contents of this information is strictly
>> prohibited and
>> Â Â may be unlawful.
>> Â Â This email has been scanned for viruses and malware, and may
>> have been
>> Â Â automatically archived by Mimecast Ltd, an innovator in
>> Software as a
>> Â Â Service (SaaS) for business. Providing a safer and more useful
>> place
>> Â Â for your human generated data. Specializing in; Security,
>> archiving and
>> Â Â compliance. To find out more [9]Click Here.
>> References
>> Â Â 1. mailto:[14]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>> Â Â 2.
>> [15]http://iprodeveloper.com/print/rpg-programming/rpgs-xml-sax-opco
>> Â Â 3. [16]http://www.scottklement.com/mailman/listinfo/ftpapi
>> Â Â 4. [17]http://www.scottklement.com/mailman/listinfo/ftpapi
>> Â Â 5. [18]http://www.partner400.com/
>> Â Â 6. [19]http://www.SystemiDeveloper.com/
>> Â Â 7. [20]http://www.scottklement.com/mailman/listinfo/ftpapi
>> Â Â 8. [21]http://www.scottklement.com/mailman/listinfo/ftpapi
>> Â Â 9. [22]http://www.mimecast.com/products/
>> --------------------------------------------------------------------
>> ---
>> This is the FTPAPI mailing list. To unsubscribe, please go to:
>> [23]http://www.scottklement.com/mailman/listinfo/ftpapi
>> --------------------------------------------------------------------
>> ---
>>
>> References
>>
>> 1. mailto:elbert@xxxxxxxxxxxxxxx
>> 2. mailto:paul.roy@xxxxxxx
>> 3. mailto:rpglist@xxxxxxxxxxx
>> 4. mailto:ftpapi@xxxxxxxxxxxxxxxxxxxxxx
>> 5. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>> 6. mailto:rpglist@xxxxxxxxxxx
>> 7. http://iprodeveloper.com/print/rpg-programming/rpgs-xml-sax-opco
>> 8. http://www.scottklement.com/mailman/listinfo/ftpapi
>> 9. http://www.scottklement.com/mailman/listinfo/ftpapi
>> 10. http://www.partner400.com/
>> 11. http://www.SystemiDeveloper.com/
>> 12. http://www.scottklement.com/mailman/listinfo/ftpapi
>> 13. http://www.scottklement.com/mailman/listinfo/ftpapi
>> 14. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>> 15. http://iprodeveloper.com/print/rpg-programming/rpgs-xml-sax-opco
>> 16. http://www.scottklement.com/mailman/listinfo/ftpapi
>> 17. http://www.scottklement.com/mailman/listinfo/ftpapi
>> 18. http://www.partner400.com/
>> 19. http://www.SystemiDeveloper.com/
>> 20. http://www.scottklement.com/mailman/listinfo/ftpapi
>> 21. http://www.scottklement.com/mailman/listinfo/ftpapi
>> 22. http://www.mimecast.com/products/
>> 23. http://www.scottklement.com/mailman/listinfo/ftpapi
>> -----------------------------------------------------------------------
>> This is the FTPAPI mailing list. To unsubscribe, please go to:
>> http://www.scottklement.com/mailman/listinfo/ftpapi
>> -----------------------------------------------------------------------
>>
>
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list. To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
>
>
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------