2014-11-01 55 views
0

我試了幾天訪問REST Web服務和響應是一個HTML:甲骨文UTL_HTTP連接如到RESTful Web服務

10.4.16 415不支持的媒體類型
服務器拒絕服務,因爲請求請求的實體採用所請求方法的請求資源不支持的格式。

它從瀏覽器(mozila)工作。要求:

https://xmlhub-test.xxx.xx/xmlhubws/jersey/SubmitMessage 

POST /xmlhubws/jersey/SubmitMessage HTTP/1.1 

Host: xmlhub-test.xxx.xx 

User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:12.0) Gecko/20100101 Firefox/12.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip, deflate 
Connection: keep-alive 
Referer: https://portal-test.xxx.xx/portal/page/portal/xxx/extranet/opma_main/xxxx/wsclient-xmlhub.html 
Cookie: JSESSIONID=JjhpJTqKsRYFGCjL3QLV2GcYMJHLvLDVlBL5hyh5FN8K2qyb10PR!-621147356!625535808; ObSSOCookie=s47sUDozSHzJ%2FarHPqrcaD5LkcFJXEmkuTQKr51UYXa3lZPjeNHKjzaUmxYbPxLkZYaaztIqCJwodlHpo6D4jR%2FVkKhmd%2Bcc9dJg4jw9cA3Kn%2FZxiwe3RA1Fyf2A%2BFLgy6eQStLzV6C9QbOi2lersS9gZBbYEy28etCXhPgMuOavl3Xtnf%2BeMVCj4Hg2QQxZSt%2FHjkSWRh%2FyVhDevt2yUo4zpoLTZ7ZKX28um6FO8CCXUTCvSlljWSzhzmSL9SwO;  RSERVER_XMLHUB_TEST_TCP_7012=R1894177232 
Content-Type: multipart/form-data; boundary=---------------------------204562724022109 
Content-Length: 2607 
-----------------------------204562724022109 
Content-Disposition: form-data; name="content"; filename="abc-01.xml" 
Content-Type: text/xml 

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

ETC

,我的代碼是:

我可以做什麼?我嘗試了什麼。我嘗試了幾十個變體(> 180 xml文件請求)。 請幫幫我。 Tjank你!

+0

變化'utl_http.set_header(v_http_request, '內容類型', '多部分/格式數據')''到utl_http.set_header(v_http_request, '內容類型' ,'application/xml')'並且再試一次 – 2014-11-01 23:33:37

+0

我試過這個但是不起作用 – 2014-11-02 17:31:34

+0

我有和GET相同的代碼: v_http_request:= utl_http.begin_request('https://xmlhub-test.xxx.xx/ xmlhubws /球衣/ checkMessageState」, 'GET', 'HTTP/1.1'); utl_http.set_authentication(v_http_request,xxx,xxxx,'Basic',false); UTL_HTTP.set_header(v_http_request,'Host','xmlhub-test.xxx.xx'); – 2014-11-03 08:25:25

回答

0

最後,工作原理:

BOUNDARY CONSTANT VARCHAR2(240) := '----=*#abc1234321cba#*='; 


UTL_HTTP.SET_WALLET(wallet_path, wallet_pwd); 

v_http_request := utl_http.begin_request('https://xmlhub-test.xxx.xx/SubmitMessage','POST','HTTP/1.1'); 
utl_http.set_body_charset(v_http_request, 'UTF-8'); 

utl_http.set_authentication (v_http_request, user, password,'Basic',false);         

UTL_HTTP.set_header(v_http_request, 'User-Agent', 'Mozilla/5.0 (Windows NT 5.2; rv:12.0) Gecko/20100101 Firefox/12.0'); 
UTL_HTTP.set_header(v_http_request, 'Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'); 
UTL_HTTP.set_header(v_http_request, 'Accept-Language', 'en-us,en;q=0.5'); 
UTL_HTTP.set_header(v_http_request, 'Connection', 'keep-alive'); 
UTL_HTTP.set_header(v_http_request, 'Referer', 'https://portal-test.xxx.xx'); 
UTL_HTTP.set_header(v_http_request, 'Transfer-Encoding', 'chunked'); 
UTL_HTTP.set_header(v_http_request, 'Content-Type', 'multipart/form-data; boundary="'|| BOUNDARY || '"'); 

utl_http.write_text(v_http_request, '--' || BOUNDARY|| utl_tcp.CRLF);  
utl_http.write_text(v_http_request, 'Content-Disposition: form-data; name="content"; filename="opma.xml"' || utl_tcp.crlf); 
utl_http.write_text(v_http_request, 'Content-Type: text/xml' || utl_tcp.crlf); 
utl_http.write_text(v_http_request, UTL_TCP.crlf || UTL_TCP.crlf); 

utl_http.write_text(v_http_request, v_send); 


utl_http.write_text(v_http_request, utl_tcp.crlf); 
utl_http.write_text(v_http_request, '--' || BOUNDARY||'--'); 
utl_http.write_text(v_http_request, utl_tcp.crlf); 

v_http_response := utl_http.get_response(v_http_request);