Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PL/SQL posting to HTTP request

426784Aug 3 2004
Hi

As part of a web application I am developing, I need to generate an HTTP post from a PL/SQL package. The problem I am having is that the message going out is not properly formatted and is being rejected by the listening application (in this case, WebCT)

The MIME message should be formatted like this. (this is what I get when I use Perl to generate the call...)

POST /webct/systemIntegrationApi.dowebct HTTP/1.1
Host: roach:4041
Connection: Keep-Alive, TE
TE: trailers, deflate, gzip, compress
User-Agent: RPT-HTTPClient/0.3-3E
Accept-Encoding: deflate, gzip, x-gzip, compress, x-compress
Content-type: multipart/form-data; boundary=WebCT_Enterprise_API_boundary
Content-length: 1506

--WebCT_Enterprise_API_boundary
Content-Disposition: form-data; name="adapter"

ims
--WebCT_Enterprise_API_boundary
Content-Disposition: form-data; name="ACTION"

import
--WebCT_Enterprise_API_boundary
Content-Disposition: form-data; name="OPTION"

unrestrict
--WebCT_Enterprise_API_boundary
Content-Disposition: form-data; name="SCTMODE"

OFF
--WebCT_Enterprise_API_boundary
Content-Disposition: form-data; name="TIMESTAMP"

1091141996
--WebCT_Enterprise_API_boundary
Content-Disposition: form-data; name="AUTH"

3D 1F DC E0 F7 15 5A 1F F4 99 CA 70 D4 68 1C 57
--WebCT_Enterprise_API_boundary
Content-Disposition: form-data; name="FILENAME"; filename="baseline_import.xml"

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE ENTERPRISE SYSTEM "IMS-EP01.dtd">
<ENTERPRISE>
<PROPERTIES>
<DATASOURCE>McGill University SCT Banner</DATASOURCE>
<TYPE>Initial Creation</TYPE>
<DATETIME>2000-00-00T12:00:00</DATETIME>
</PROPERTIES>
<GROUP>
<SOURCEDID>
<SOURCE>Banner 2000 SCT Banner</SOURCE>
<ID>6536.200409</ID>
</SOURCEDID>
<DESCRIPTION>
<SHORT>HIST-666-001</SHORT>
</DESCRIPTION>
<RELATIONSHIP myrelationship="3">
<SOURCEDID>
<SOURCE>Banner 2000 SCT Banner</SOURCE>
<ID>6537.200409</ID>
</SOURCEDID>
</RELATIONSHIP>
</GROUP>
</ENTERPRISE>
WebCT_Enterprise_API_boundary

HTTP/1.1 200 OK
Date: Thu, 29 Jul 2004 21:56:27 GMT
Server: Apache/2.0.49 (Unix) DAV/2 mod_ssl/2.0.49 OpenSSL/0.9.6m mod_jk/1.2.3-dev
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

35
Success: Import file (baseline_import.xml) complete.

0



My PL/SQL code that tries to build the outgoing call is

req := utl_http.begin_request('http://atlas.cc.mcgill.ca:8900/webct/systemIntegrationApi.dowebct','POST', 'HTTP/1.1');
utl_http.write_text(req,'Content-type: multipart/form-data; boundary=WebCT_Enterprise_API_Boundary' || CHR(13)|| CHR(10) ||
'' || CHR(13)|| CHR(10) ||
'--WebCT_Enterprise_API_Boundary' || CHR(13)|| CHR(10) ||
'Content-Disposition: form-data; name="adapter"' || CHR(13)|| CHR(10) ||
'' || CHR(13)|| CHR(10) ||
'ims' || CHR(13)|| CHR(10) ||
'--WebCT_Enterprise_API_Boundary' || CHR(13)|| CHR(10) ||
'Content-Disposition: form-data; name="ACTION"' || CHR(13)|| CHR(10) ||
'' || CHR(13)|| CHR(10) ||
'import' || CHR(13)|| CHR(10) ||
'--WebCT_Enterprise_API_Boundary' || CHR(13)|| CHR(10) ||
'Content-Disposition: form-data; name="OPTION"' || CHR(13)|| CHR(10) ||
'' || CHR(13)|| CHR(10) ||
'unrestrict' || CHR(13)|| CHR(10) ||
'--WebCT_Enterprise_API_Boundary' || CHR(13)|| CHR(10) ||
'Content-Disposition: form-data; name="SCTMODE"' || CHR(13)|| CHR(10) ||
'' || CHR(13)|| CHR(10) ||
'OFF' || CHR(13)|| CHR(10) ||
'--WebCT_Enterprise_API_Boundary' || CHR(13)|| CHR(10) ||
'Content-Disposition: form-data; name="TIMESTAMP"' || CHR(13)|| CHR(10) ||
'' || CHR(13)|| CHR(10) ||
timestamp || CHR(13)|| CHR(10) ||
'--WebCT_Enterprise_API_Boundary' || CHR(13)|| CHR(10) ||
'Content-Disposition: form-data; name="AUTH"' || CHR(13)|| CHR(10) ||
'' || CHR(13)|| CHR(10) ||
mac || CHR(13)|| CHR(10) ||
'--WebCT_Enterprise_API_Boundary' || CHR(13)|| CHR(10) ||
'Content-Disposition: form-data; name="FILENAME"; filename="xlist.xml"' || CHR(13)|| CHR(10) ||
'' || CHR(13)|| CHR(10) ||
total_xml_string || CHR(13)|| CHR(10) ||
'--WebCT_Enterprise_API_Boundary--' || CHR(13)|| CHR(10));
resp := utl_http.get_response(req);
utl_http.read_text(resp, val);
utl_http.end_response(resp);



When I watch the network traffic generated by this PL/SQL I do not have any carriage returns which makes WebCT to believe that the message does not carry the proper data and returns Fatal Failure(99): Invalid URL arguments...

Is there somewhere where I can see sample code for placing HTTP requests using the utl_http package? Or if I am doing something obviously wrong (I am new at this whole PL/SQL thing...) please let me know.

Thank you
Bogdan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2004
Added on Aug 3 2004
0 comments
621 views