[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Example using http_url_post_stmf



Mario,

Actually "http_post_stmf_xml" does not know anything about the data type of "peUsrDta". From the view of "http_post_stmf_xml" the type of "peUsrDta" is nothing but a black box.

It is completely up to the user to design and use "peUsrDta" to match his needs. Usually "peUsrDta" is defined as a data structure with sub fields or sub structures for each data item you want to retrieve from the response message. For that it is a good idea to define a reference field for "peUsrDta" as shown below for example:

 D response_t      DS                  qualified based(pDummy)
 D  itemFoo                     123A   varying
 D  itemBaa                      20A   varying
 D  structAddr                         likeds(addr_t)

 D addr_t          DS                  qualified based(pDummy)
 D  firstName                    50A   varying
 D  lastName                     50A   varying
 D  street                       70A   varying
 D  zip                          10A   varying
 D  city                         80A   varying

Instead of "based(pDummy)" you may use "template" if you are on V6R1 or higher.

With the reference field it is easy to define the response structure in the procedure that calls "http_post_stmf_xml" as well as in the end element callback procedure(s). Scott often uses "incoming" for the name of his end element callback procedures if I remember correctly.

Inside "incoming" you can define the response data structure like that:

 D Incoming        PR
 D   userdata                      *   value
 D   depth                       10I 0 value
 D   name                      1024A   varying const
 D   path                     24576A   varying const
 D   value                    65535A   varying const
 D   Attrs                         *   dim(32767)
 D                                     const options(*varsize)

 D response        DS                  likeds(response_t)
 D                                     based(userdata)

Inside "incoming" it is up to you to check parameter(s) "name" and/or path to get the right element. Once that "name" and/or "path" matches the expected values you know that the current element is the one you want and you can store the content of "value" in your data strutuce, e.g. "response.itemFoo".

You may also follow EXAMPLE10 and define "repsonse" this way:

 D Incoming        PR
 D   response                          likeds(response_t)
 D   depth                       10I 0 value
 D   name                      1024A   varying const
 D   path                     24576A   varying const
 D   value                    65535A   varying const
 D   attrs                         *   dim(32767)
 D                                     const options(*varsize)

         if ( path = '/joes/address' );

            select;
            when name = 'firstName';
               response.addr.firstName = value;
            when name = 'lastName';
               response.addr.lastName = value;
            endsl;

         endif;

The first way is more straight forward but very detailed and the second one is elegant but a bit tricky. (Just my opinion.)

In case of numeric values you may need to use %dec() to convert the content of "value" to a numeric value.

Does that help?

Thomas.


Am 08.04.2013 17:06, schrieb Mario Martoriello:
Thomas
Yes the debug log was the original and you are right there was a blank as
first char, removing this it works fine.
Now another  question when I use "http_post_stmf_xml" I can receive only a
value from the response  which is the field that I pass in "peUsrDta" or
didn't understand anything? If I need more information from the response
file have I to use "http_post_stmf_xmlt" or different approch?
Thank you for your  tips
Best regards
Mario

-----Messaggio originale----- From: thomas.raddatz@xxxxxx
Sent: Monday, April 08, 2013 1:57 PM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Example using http_url_post_stmf


Mario,

If the provided debug log is the original HTTPAPI debug log, then there
are still leading character as there are:

0d 0a 20 3c 3f 78 6d 6c
CR LF BL <  ?  x  m  l

sendraw(): entered
<?xml version="1.0" encoding="utf-8"?>
       <SOAP:Envelope

Please notice that the line after "sendraw()" does not start right at the
beginning. That is the space (hex 20) which is too much. Remove the space
and it should work. The CR and LF come from the HTTPAPI debug log and are
correct.

Thomas.


ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 08.04.2013 12:44:03:

Von: martoriello@xxxxxxxxxxxxxxx
An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx,
Datum: 08.04.2013 12:53
Betreff: Re: Example using http_url_post_stmf
Gesendet von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx

Thomas and Mike
Thank you for your answers. I did the suggested changes but I received
always an error (parse error)
Attached is the debug file for the test.
I attach also the very simple pgm that I used for testing
Any suggestion?
thanks in advance
Mario

-----Messaggio originale----- From: thomas.raddatz@xxxxxx
Sent: Monday, April 08, 2013 7:49 AM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Example using http_url_post_stmf


Mario,

The very first characters of a XML document must be the declaration
node:

<?xml version="1.0" encoding="utf-8"?>

Your XML file starts with carriage return, linefeed and lots of blanks:



I always use Notepad++ and the "XML Tools" plugin to validate XML files,
because MS Internet Explorer does not return all errors, such as this
one.
But with Notepadd++ I get the following error message:



Once that I removed the the invalid characters, the XML validates fine:



Regards,

Thomas.


ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 05.04.2013 17:56:26:

> Von: martoriello@xxxxxxxxxxxxxxx
> An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx,
> Datum: 05.04.2013 18:04
> Betreff: Example using http_url_post_stmf
> Gesendet von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>
> Hi all
> I am quite new to Httpapi  and I am looking for an example  about
> the use of http_url_post_stmf . I have to send a xml file to a
> webserver that is on a Epson printer. Looking at the example in
> Httpapi first I wrote a pgm that send the example data written in a
> program variable using “http_url_post_xml” and it was Ok . Then I
> modified the program to send the same data written now in a xml file
> using http_url_post_stmf and I receive an error. So  I try to send
> the xml file using the HTTPAPI  cmdline interface  to try to
> understand what I receive from the server and the response file is :
>
> <?xml version="1.0" encoding="utf-8"?>
> <soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/
> ">
> <soapenv:Body>
> <response success="false" code="PARSER_ERROR" status="0">
> </response>
> </soapenv:Body>
> </soapenv:Envelope>
> maybe I did a mistake when I copied the data in the xml file and
> there is no problem or I am using the http_url_post_stmf in a wrong
> mode. Another question is how in the incoming procedure can I read
> the values of success and code attributes of response tag?
> Attached is the XML file that I am using.
> Thanks in advance
> Mario[Anhang "esempio_scontrino.xml" gelöscht von Thomas Raddatz/
> OBI/DE]
>
-----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
>
-----------------------------------------------------------------------


--
IMPORTANT NOTICE:
This email is confidential, may be legally privileged, and is for the
intended recipient only. Access, disclosure, copying, distribution, or
reliance on any of it by anyone else is prohibited and may be a criminal
offence. Please delete if obtained in error and email confirmation to
the
sender.






-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
[Anhang "httpapi_debug.txt" gelöscht von Thomas Raddatz/OBI/DE]
[Anhang "xfkp262" gelöscht von Thomas Raddatz/OBI/DE]
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------


--
IMPORTANT NOTICE:
This email is confidential, may be legally privileged, and is for the
intended recipient only. Access, disclosure, copying, distribution, or
reliance on any of it by anyone else is prohibited and may be a criminal
offence. Please delete if obtained in error and email confirmation to the
sender.






-----------------------------------------------------------------------
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
-----------------------------------------------------------------------