我尝试了几天访问REST Web服务,响应是HTML:
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
我的代码是:
--UTL_HTTP.CLOSE_PERSISTENT_CONNS (g_wsdl_url);
utl_http.set_response_error_check( false );
utl_http.set_detailed_excp_support( true );
utl_http.set_cookie_support( true );
utl_http.set_transfer_timeout( 60 );
utl_http.set_follow_redirect( 3 );
utl_http.set_persistent_conn_support( true );
UTL_HTTP.SET_WALLET(xxxx, xxxxx);
v_http_request := utl_http.begin_request('https://xmlhub-test.xxx.xx/xmlhubws/jersey/SubmitMessage','POST','HTTP/1.1');
utl_http.set_body_charset(v_http_request, 'UTF-8');
utl_http.set_authentication (v_http_request, xxxx, xxxxxx,'Basic',false);
UTL_HTTP.set_header(v_http_request,'Host','xmlhub-test.xxx.xx');
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,'Accept-Encoding','gzip, deflate');
UTL_HTTP.set_header(v_http_request,'Connection','keep-alive');
--UTL_HTTP.set_header(v_http_request,'Referer','https://portal-test.bnr.ro/portal/page/portal/BNR/extranet/opma_main/opma/wsclient-xmlhub.html');
--text/html; charset=UTF-8 --'multipart/form-data'
utl_http.set_header(v_http_request,'Content-Type','multipart/form-data');
utl_http.set_header (v_http_request, 'Transfer-Encoding', 'chunked');
utl_http.set_header(v_http_request,'Content-Length', l_clob_len);
utl_http.set_header(v_http_request,'id', '"downloadMessage"');
utl_http.write_text(v_http_request,p_xml.getStringVal());
我该怎么办?我尝试了什么。我尝试了几十种变体(&gt; 180 xml文件请求)。 请帮我。 Tjank你!
答案 0 :(得分: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);