× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



My suggestion is to firstly attempt to prove that you can transact the desired conversation with the xml service by developing a simple web page employing either built-in javascript connection methods or higher level methods provided by jQuery. That way the complexity of implementing the HTTP connection functions has been simplified for you so you can concentrate on getting the request right until you get the desired response. Once you understand what the correct conversation looks like then you should be able to write the same thing in RPGLE using Scott's HTTPAPI.

It would hazard a guess that the web service may be expecting a default POST request like that from a regular form on an HTML page rather than a form specifically designed to perform a file upload. That is, where the form does not explicitly specify an ENCTYPE attribute, which therefore defaults to enctype="application/x-www-form-ulrencoded" rather than the enctype="multipart/form-data required by a service that is specifically expecting a form based file upload.

For example , a regular looking HTML page with a form having 2 input fields, one of which has a value which is comprises an xml document like this -

<form name='form1' method='POST' action='http://google.co.nz'>
<p><input name='input1' value='harry'/>
<p><input name='data' size='100' value='<?xml version="1.0" encoding="UTF-8" ?><root><lvl>AAA</lvl></root>' />
<p><input type='submit' value='Submit' />
</form>

This would result in a POST request whose body would contains -
input1=harry&data=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+%3F%3E%3Croot%3E%3Clvl%3EAAA%3C%2Flvl%3E%3C%2Froot%3E

In this case the xml document has been urlencoded so that special characters like < and > have been converted to %3C and %3E. The web service may be expecting such a request.

Peter



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of tegger@xxxxxxxxxxx
Sent: Friday, 12 July 2013 6:48 a.m.
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: http_url_post_xml and REST



The XML is created on the IFS using codepage 819.

When it is downloaded to a PC, everything looks file. If I load it to IE or FIREFOX, everything comes up perfectly.







----- Original Message -----


From: tegger@xxxxxxxxxxx
To: "RPG programming on the IBM i (AS/400 and iSeries)" <rpg400-l@xxxxxxxxxxxx>
Sent: Thursday, July 11, 2013 2:17:57 PM
Subject: Re: http_url_post_xml and REST



Now that's a possibility.



What's the best way to force the encoding?





----- Original Message -----


From: "thomas raddatz" <thomas.raddatz@xxxxxx>
To: rpg400-l@xxxxxxxxxxxx
Sent: Thursday, July 11, 2013 2:44:21 AM
Subject: Re: http_url_post_xml and REST


For me the error message implies that you do not send the XML in UTF-8 but any other encoding. That way the server can not find the "<" character at the first position of the XML.

The error message:

   <?xml version="1.0" encoding="UTF-8"?><error>XML Error: Fatal error:
   Start tag expected, '&lt;' not found at :1.</error>

What the server tries to read:

   <?xml version="1.0" encoding="UTF-8"?>
   <service_orders>

Because of the wrong encoding it can not find the "<" of "<?xml ...".

Nothing more than a guess.

Thomas.

rpg400-l-bounces@xxxxxxxxxxxx schrieb am 10.07.2013 21:53:58:

Von: tegger@xxxxxxxxxxx
An: rpg400-l@xxxxxxxxxxxx,
Datum: 10.07.2013 21:54
Betreff: Re: http_url_post_xml and REST Gesendet von:
rpg400-l-bounces@xxxxxxxxxxxx



I have that in there. Thanks though!

I hard coded it just during my original attempts to get it running.



It's running now. Just have an error with the XML (or their server
says there's an error).



I was looking in the httpapi_debug.txt file and noticed that the
filename line is missing a double quote at the end of the filename.
I doubt that is causing my issue...


<?xml version="1.0" encoding="UTF-8"?><error>XML Error: Fatal error:
Start tag expected, '&lt;' not found at :1.</error>


<?xml version="1.0" encoding="UTF-8"?> <service_orders>
<service_order> <number>1-610615B</number> <account>2311960</account>
<service_type>Delivery</service_type>
<customer>
<customer_id>2311960</customer_id>
<first_name>HENRY</first_name>
<last_name>MILLER</last_name>
<phone1>301-555-1212</phone1>
<phone2>301-555-1213</phone2>
<address1>SOME STREET</address1>
<city>BOWIE</city>
<state>MD</state>
<zip>20716</zip>
</customer>
<items>
<item>
<sale_sequence>1</sale_sequence>
<item_id>1055746</item_id>
<serial_number>001999188</serial_number>
<description><![CDATA[P992050BD SOFA PAULA DEEN SOLITUDE 09/CW BRO NCO
31/BOL LENA 22/PIL RE]]></description> <quantity>1</quantity>
<location>Warehouse#1</location> <cube>3</cube> <price>1334.95</price>
<countable>1</countable> </item> </items> <cube>1</cube>
<pieces>1</pieces> <delivery_date>7/09/2014</delivery_date>
</service_order>
</service_orders>



----- Original Message -----


From: "Scott Klement" <rpg400-l@xxxxxxxxxxxxxxxx>
To: "RPG programming on the IBM i (AS/400 and iSeries)" <rpg400-
l@xxxxxxxxxxxx>
Sent: Wednesday, July 10, 2013 2:39:02 PM
Subject: Re: http_url_post_xml and REST

Jay,

I know you've gotten past this point already, but... one tip for you
with regard to the following code:


if (rc <> 1);
     msg = http_error(err);
     dsply msg;
     if err<>36;
        callp http_crash();
        return;
     endif;
     exsr $getPassword;
endif;


There are named constants in HTTPAPI_H for each error number.  So
instead of coding err<>36, you could code err<>HTTP_NDAUTH.  This is
just easier to read...  HTTP_NDAUTH visually looks like 'Need
Authentication", whereas it's hard to say what '36' means.  Even I
didn't know what it was without looking it up...

It's just a small tip, though... what you have will work okay, it's
just

not as nice to read.
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/rpg400-l.

--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/rpg400-l.



--
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 RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.


#####################################################################################

This correspondence is for the named person's use only. It may contain confidential
or legally privileged information, or both. No confidentiality or privilege is waived
or lost by any mistransmission. If you receive this correspondence in error, please
immediately delete it from your system and notify the sender. You must not disclose,
copy or rely on any part of this correspondence if you are not the intended recipient.
Any views expressed in this message are those of the individual sender, except where
the sender expressly, and with authority, states them to be the views of Veda.
If you need assistance, please contact Veda on either :-
Australia 1300-762-207 or New Zealand +64 9 367 6200

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.