Utl_http.response 32767 stops at 32767.
Hi
Any help will be highly appreciated. The request works perfectly when > 32767 but the response stops at 32767.
This is the function that is called.
create or replace
FUNCTION utl_http_request_resp(url varchar2, requestbody clob)
RETURN VARCHAR2 AS
http_req utl_http.req;
http_resp utl_http.resp;
reqlength binary_integer;
responsebody clob:=null;
resplength binary_integer;
buffer varchar2(2000);
amount pls_integer := 2000;
offset pls_integer := 1;
begin
http_req := utl_http.begin_request(url, 'POST', 'HTTP/1.1');
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'SOAPAction', 'http://oracle.com/determinations/server/10.3/rulebase/types/Assess');
utl_http.set_header(http_req, 'Transfer-Encoding', 'chunked');
reqlength := dbms_lob.getlength(requestbody);
while(offset < reqlength) loop
dbms_lob.read(requestbody, amount, offset, buffer);
utl_http.write_text(http_req, buffer);
offset := offset + amount;
end loop;
http_resp := utl_http.get_response(http_req);
utl_http.read_text(http_resp, responsebody, 32767);
utl_http.end_response(http_resp);
return responsebody;
end;
Thanks in advance
Ankith
No need to post in a new thread.
See answer in the original : {message:id=10276314}
Similar Messages
-
How to handle utl_http response
Hi,
I use the below code to call a https using POST method
utl_http.set_proxy(apex_application.g_proxy_server, NULL);
utl_http.set_persistent_conn_support(TRUE);
utl_http.set_transfer_timeout(300);
utl_http.set_wallet(p_wallet, p_wallet_pwd);
l_http_req := utl_http.begin_request(p_api_url, 'POST');
utl_http.set_header(l_http_req, 'Proxy-Connection', 'Keep-Alive');
utl_http.set_header(l_http_req, 'Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
utl_http.set_header(l_http_req, 'Content-Length', length(l_post));
utl_http.write_text(l_http_req, l_post);
l_http_resp := utl_http.get_response(l_http_req);
utl_http.read_text(l_http_resp, l_response);
The url return a respose with below l_response content
<html>
<head>
<META HTTP-EQUIV='content-type' CONTENT='text/html; charset=UTF8'>
</head>
<title>Payment Page</title>
<form method="POST" name="ePayment" action="http://www.testing.com">
<input type="hidden" name="MerchantCode" value="M01247"><br>
<input type="hidden" name="PaymentId" value="2"><br>
<input type="hidden" name="RefNo" value="0001"><br>
<input type="hidden" name="Amount" value="1"><br>
<input type="hidden" name="Currency" value="MYR"><br>
<input type="hidden" name="Remark" value="Testing1"><br>
<input type="hidden" name="TransId" value=""><br>
<input type="hidden" name="AuthCode" value=""><br>
<input type="hidden" name="Status" value="0"><br>
<input type="hidden" name="ErrDesc" value="Permission not allow"><br>
<input type="hidden" name="Signature" value=""><br>
</form>
<script language="JavaScript">
document.ePayment.submit();
</script>
</html>
Apparently it will redirect to http://www.testing.com,
how should my procedure handle this response so it will redirect to the url?
Thanks.
Vincent pek
Edited by: [email protected] on May 3, 2010 7:09 AM<script language="JavaScript">
document.ePayment.submit();
</script>
</html>
Apparently it will redirect to http://www.testing.com,
how should my procedure handle this response so it will redirect to the url?
Thanks.
Vincent pekYour procedure should be able to run JavaScript, which it isn't.
Therefore, I would recommend that you talk to the website administrator and discuss using a webservice. -
Lync response group stops after a while with receiving incomming calls
Hi Folks,
We have a strange issue with the response groups of Lync.
It seems that the response group randomly stops working, what means that the users can't receive their call trough the response groups.
Only the response group call(s) don't work, the pstn -> lync lync-> lync call just works fine.
The quick fix is to restart one of the Lync front end servers.
But, that is not really a solution.
The event viewer don't show anything about this problem. Also the Lync monitoring service don't show anything.
Sometimes restarting the Windows Lync response group services solves the problem, but most of the time we need to restart the whole server.
I'm curious some people has the same experience.
If you need more information about our deployment, please feel free to ask.Hi,
I suggest you try to gather some logs on the Mediation server to see what is happening. Please use Lync logging tool and capture the data for S4
and then try to see if there are any errors after reporduce the problem.
Please try to enable logging tool to get detailed report:
http://blog.schertz.name/2011/06/using-the-lync-logging-tool/
http://technet.microsoft.com/en-us/library/gg558599.aspx
Regards,
Kent Huang
TechNet Community Support ************************************************************************************************************************ Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a
marked post does not actually answer your question. -
Non responsive firefox & stops in mid sentance in messanger or e-mail. Hour glass shows!
Foxfire VERY SLOW RESPONSE, TO OPEN FIREFOX. ALSO IT WILL SAY fIREFOX NON-RESPONSIVE & A HOUR GLASS SIGN SHOWS UP. i WILL BE WRITING IN CHAT OR AN E-MAIL 7 IT STOPS TYPING, AN HOUR GLASS SHOWS UP & IT WILL SAY NON-RESPONSIVE. i'M AM GETTING UPSET WITH ALL THESE PROBLEMS. wHAT CAN BE DONE??
-> Tap ALT key or press F10 to show the Menu Bar
-> go to Help Menu -> select "Restart with Add-ons Disabled"
Firefox will close then it will open up with just basic Firefox. Now do this:
-> Update ALL your Firefox Plug-ins https://www.mozilla.com/en-US/plugincheck/
-> go to View Menu -> Toolbars -> unselect All Unwanted toolbars
-> go Tools Menu -> Clear Recent History -> '''Time range to clear: select EVERYTHING''' -> click Details (small arrow) button -> place Checkmarks on '''Cookies, Cache''' -> click "Clear Now"
-> go to Tools Menu -> Options -> General -> place Checkmark on "Show the Downloads window when downloading a file" -> select Radio Button option2 "Always ask me where to save files"
-> go to Tools Menu -> Options -> Content -> place Checkmarks on:
1) Block Pop-up windows 2) Load images automatically 3) Enable JavaScript
-> go to Tools Menu -> Options -> Security -> place Checkmarks on:
1) Warn me when sites try to install add-ons 2) Block reported attack sites 3) Block reported web forgeries 4) Remember Passwords for sites
-> Click OK on Options window
-> click the Favicon (small drop down menu icon) on Firefox SearchBar (its position is on the Right side of the Address Bar) -> click "Manage Search Engines" -> select all Unwanted Search Engines and click Remove -> click OK
-> go to Tools Menu -> Add-ons -> Extensions section -> REMOVE All Unwanted/Suspicious Extensions (Add-ons) -> Restart Firefox
You can enable your Known & Trustworthy Add-ons later. Check and tell if its working. -
Writing all the rows in one line but cannot write more than 32767 character
Dear All,
i am trying to write the column of a table to a file with the '||' seperators. i want to write all the rows in one line of the file.
for E.g
Column1 Column2
A B
C D
in the file the output needs to be gone like
A||B||C||D
but after 32767 character it gives a write error. could please someone let me know what is wrong with my function below or how can i write more than 32767 character in one one.
CREATE OR REPLACE FUNCTION CORP_IB_DUMP_FILE (
P_QUERY IN VARCHAR2,
P_SEPARATOR IN VARCHAR2 DEFAULT '',
P_DIR IN VARCHAR2,
P_FILENAME IN VARCHAR2
RETURN NUMBER AUTHID CURRENT_USER
IS
L_OUTPUT UTL_FILE.FILE_TYPE;
L_THECURSOR INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
L_THECURSOR2 INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
L_COLUMNVALUE VARCHAR2 (4000);
L_STATUS INTEGER;
L_COLCNT NUMBER DEFAULT 0;
L_SEPARATOR VARCHAR2 (10) DEFAULT '';
L_CNT NUMBER DEFAULT 0;
BEGIN
L_OUTPUT := UTL_FILE.FOPEN (P_DIR, P_FILENAME, 'w', 32767);
DBMS_SQL.PARSE (L_THECURSOR, P_QUERY, DBMS_SQL.NATIVE);
FOR I IN 1 .. 255
LOOP
BEGIN
DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, I, L_COLUMNVALUE, 4000);
L_COLCNT := I;
EXCEPTION
WHEN OTHERS
THEN
IF (SQLCODE = -1007)
THEN
EXIT;
ELSE
RAISE;
END IF;
END;
END LOOP;
DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, 1, L_COLUMNVALUE, 4000);
L_STATUS := DBMS_SQL.EXECUTE (L_THECURSOR);
LOOP
EXIT WHEN (DBMS_SQL.FETCH_ROWS (L_THECURSOR) <= 0);
L_SEPARATOR := '';
FOR I IN 1 .. L_COLCNT
LOOP
DBMS_SQL.COLUMN_VALUE (L_THECURSOR, I, L_COLUMNVALUE);
UTL_FILE.PUT (L_OUTPUT, L_SEPARATOR || L_COLUMNVALUE);
L_SEPARATOR := P_SEPARATOR;
UTL_FILE.FFLUSH (L_OUTPUT);
END LOOP;
UTL_FILE.FFLUSH (L_OUTPUT);
L_CNT := L_CNT + 1;
END LOOP;
DBMS_SQL.CLOSE_CURSOR (L_THECURSOR);
UTL_FILE.FCLOSE (L_OUTPUT);
RETURN L_CNT;
END CORP_IB_DUMP_FILE;
/user577300 wrote:
Dear All,
i am trying to write the column of a table to a file with the '||' seperators. i want to write all the rows in one line of the file.
for E.g
Column1 Column2
A B
C D
in the file the output needs to be gone like
A||B||C||D
but after 32767 character it gives a write error. could please someone let me know what is wrong with my function below or how can i write more than 32767 character in one one.
CREATE OR REPLACE FUNCTION CORP_IB_DUMP_FILE (
P_QUERY IN VARCHAR2,
P_SEPARATOR IN VARCHAR2 DEFAULT '',
P_DIR IN VARCHAR2,
P_FILENAME IN VARCHAR2
RETURN NUMBER AUTHID CURRENT_USER
IS
L_OUTPUT UTL_FILE.FILE_TYPE;
L_THECURSOR INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
L_THECURSOR2 INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
L_COLUMNVALUE VARCHAR2 (4000);
L_STATUS INTEGER;
L_COLCNT NUMBER DEFAULT 0;
L_SEPARATOR VARCHAR2 (10) DEFAULT '';
L_CNT NUMBER DEFAULT 0;
BEGIN
L_OUTPUT := UTL_FILE.FOPEN (P_DIR, P_FILENAME, 'w', 32767);
DBMS_SQL.PARSE (L_THECURSOR, P_QUERY, DBMS_SQL.NATIVE);
FOR I IN 1 .. 255
LOOP
BEGIN
DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, I, L_COLUMNVALUE, 4000);
L_COLCNT := I;
EXCEPTION
WHEN OTHERS
THEN
IF (SQLCODE = -1007)
THEN
EXIT;
ELSE
RAISE;
END IF;
END;
END LOOP;
DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, 1, L_COLUMNVALUE, 4000);
L_STATUS := DBMS_SQL.EXECUTE (L_THECURSOR);
LOOP
EXIT WHEN (DBMS_SQL.FETCH_ROWS (L_THECURSOR) <= 0);
L_SEPARATOR := '';
FOR I IN 1 .. L_COLCNT
LOOP
DBMS_SQL.COLUMN_VALUE (L_THECURSOR, I, L_COLUMNVALUE);
UTL_FILE.PUT (L_OUTPUT, L_SEPARATOR || L_COLUMNVALUE);
L_SEPARATOR := P_SEPARATOR;
UTL_FILE.FFLUSH (L_OUTPUT);
END LOOP;
UTL_FILE.FFLUSH (L_OUTPUT);
L_CNT := L_CNT + 1;
END LOOP;
DBMS_SQL.CLOSE_CURSOR (L_THECURSOR);
UTL_FILE.FCLOSE (L_OUTPUT);
RETURN L_CNT;
END CORP_IB_DUMP_FILE;
/Check your logic very carefully. You are using UTL_FILE.PUT() which should not automatically put end-of-line characters i n your file but you are reassigning l_seperator with p_seprator after the first time.
What value are you pasising in as p_seperator?
UTL_FILE.PUT() should allow you to write a string of bytes without newlines as long as its arguments are less than 32K, and you can control when the newlines get written. If your arguments are > 32K can you split them up without writing the newlines until you need to do so? Try something like (untested)
-- UTL_FILE.PUT (L_OUTPUT, L_SEPARATOR || L_COLUMNVALUE);
UTL_FILE.PUT (L_OUTPUT, substr(L_SEPARATOR || L_COLUMNVALUE,1,32767));
UTL_FILE.PUT (L_OUTPUT, substr(L_SEPARATOR || L_COLUMNVALUE),32767*2-1,32767));Edited by: riedelme on Sep 10, 2012 6:11 AM -
Read values from html response
Hi,
I am trying to make a call to an API using UTL_HTTP POST method over SSL and read the response html page and extract the values from the reponse.
I am able to call and get a response back in html format. I have stored the html response in a clob variable.
Now i want to parse this html and extract values from the form input items and send them out through OUT parameters.
For example, from below reponse i want to extract the value '1111d7nhcwse30wq' from 'I4GO_UNIQUEID'
Can anyone help me with the code to parse this html response and extract the values.
Any help is greatly appreciated.
Thanks
Sharath
sample Code:
PROCEDURE get_token (
p_requesterreference IN VARCHAR2,
p_cardnumber IN VARCHAR2,
p_cardtype IN VARCHAR2,
p_cardholdername IN VARCHAR2,
p_expirationmonth IN VARCHAR2,
p_expirationyear IN VARCHAR2,
p_streetaddress IN VARCHAR2,
p_postalcode IN VARCHAR2,
p_cvv2code IN VARCHAR2,
po_uniqueid OUT VARCHAR2,
po_errorindicator OUT VARCHAR2,
po_primaryerrorcode OUT VARCHAR2,
po_response OUT VARCHAR2,
po_status_code OUT VARCHAR2,
po_reason_phrase OUT VARCHAR2
IS
v_url VARCHAR2 (200);
v_url_params VARCHAR2 (32767);
v_resp_str VARCHAR2 (32767);
l_http_req UTL_HTTP.req;
l_http_resp UTL_HTTP.resp;
v_requesterreference VARCHAR2 (12) := p_requesterreference;
v_i4go_cardnumber VARCHAR2 (32) := p_cardnumber;
v_i4go_streetaddress VARCHAR2 (30) := p_streetaddress;
v_i4go_postalcode VARCHAR2 (9) := p_postalcode;
v_i4go_expirationmonth VARCHAR2 (2) := p_expirationmonth; -- MM format
v_i4go_expirationyear VARCHAR2 (2) := p_expirationyear; -- yy format
v_i4go_cvv2code VARCHAR2 (3) := p_cvv2code;
v_name VARCHAR2 (256);
v_value VARCHAR2 (1024);
l_clob CLOB;
pv_amp CONSTANT CHAR (1) := CHR (38);
CURSOR setup_cur
IS
SELECT interface_id, interface_name, interface_url, account_id, site_id
FROM rsv.shift4_setup
WHERE interface_name = 'I4GO';
v_setup_rec setup_cur%ROWTYPE;
BEGIN
OPEN setup_cur;
FETCH setup_cur
INTO v_setup_rec;
CLOSE setup_cur;
v_url := 'https://certify.i4go.com//index.cfm?fuseaction=account.PostCardEntry';
v_url_params :=
pv_amp
|| 'i4GO_AccountID='
|| v_setup_rec.account_id
|| pv_amp
|| 'i4Go_SiteID='
|| v_setup_rec.site_id
|| pv_amp
|| 'i4Go_CardNumber='
|| v_i4go_cardnumber
|| pv_amp
|| 'i4Go_ExpirationMonth='
|| v_i4go_expirationmonth
|| pv_amp
|| 'i4Go_ExpirationYear='
|| v_i4go_expirationyear
|| pv_amp
|| 'i4Go_CVV2Code='
|| v_i4go_cvv2code
|| pv_amp
|| 'i4Go_PostalCode='
|| v_i4go_postalcode;
-- begin request using POST method
UTL_HTTP.set_response_error_check (FALSE);
UTL_HTTP.set_transfer_timeout (180);
UTL_HTTP.set_wallet ('file:/etc/ORACLE/WALLETS/oracle', 'welcome1');
l_http_req := UTL_HTTP.begin_request (v_url, 'POST');
UTL_HTTP.set_header (l_http_req, 'User-Agent', 'Mozilla/4.0');
UTL_HTTP.set_header (l_http_req, 'Content-Type', 'application/x-www-form-urlencoded');
UTL_HTTP.set_header (l_http_req, 'content-length', LENGTH (v_url_params));
UTL_HTTP.write_text (l_http_req, v_url_params);
-- get response
l_http_resp := UTL_HTTP.get_response (l_http_req);
po_status_code := l_http_resp.status_code;
po_reason_phrase := l_http_resp.reason_phrase;
-- read response into a clob
DBMS_LOB.createtemporary (l_clob, FALSE);
BEGIN
LOOP
UTL_HTTP.read_text (l_http_resp, v_resp_str, 32767);
DBMS_LOB.writeappend (l_clob, LENGTH (v_resp_str), v_resp_str);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body
THEN
-- end response
UTL_HTTP.end_response (l_http_resp);
END;
-- Fre resources
DBMS_LOB.freetemporary (l_clob);
EXCEPTION
WHEN OTHERS
THEN
DBMS_LOB.freetemporary (l_clob);
DBMS_OUTPUT.put_line (UTL_HTTP.get_detailed_sqlerrm);
RAISE;
END;
sample response:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Return With Payment Token</title>
<script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript"><!--
picSpinner= new Image(40,40);
picSpinner.src="images/loading040.gif";
bodyOnLoad = function() {
$("#noScriptDiv").hide();
$("#scriptDiv").show();
$("#i4GoMainForm").submit();
//--></script>
</head>
<body onload="bodyOnLoad();">
<form name="i4GoMainForm" id="i4GoMainForm" action="http://google.com" method="POST" onsubmit="$('#i4Go_submit').attr('disabled','disabled');">
<input name="I4GO_RESPONSE" type="hidden" value="SUCCESS" />
<input name="I4GO_RESPONSECODE" type="hidden" value="1" />
<input name="I4GO_CARDTYPE" type="hidden" value="VS" />
<input name="I4GO_UNIQUEID" type="hidden" value="1111d7nhcwse30wq" />
<input name="I4GO_EXPIRATIONMONTH" type="hidden" value="12" />
<input name="I4GO_EXPIRATIONYEAR" type="hidden" value="2012" />
<input name="I4GO_CARDHOLDERNAME" type="hidden" value="" />
<input name="I4GO_STREETADDRESS" type="hidden" value="" />
<input name="I4GO_POSTALCODE" type="hidden" value="65000" />
<div id="scriptDiv" style="font-family:Arial, Helvetica, sans-serif;font-size:18px;visibility:hidden;">
<img src="images/loading040.gif" alt="Spinner..." /> Loading...
</div>
<div id="noScriptDiv" style="font-family:Arial, Helvetica, sans-serif;">
<noscript>
<h1>Statement of Tokenization</h1>
<p>The payment information you have submitted has been securely stored in the Shift4 PCI-DSS certified data center and a token representing this information will be sent to the merchant for processing. Below is the information that will be returning to the originating merchant:</p>
<ul>
<li>Response: <strong>SUCCESS</strong></li>
<li>Response Code: <strong>1</strong></li>
<li>Card Type: <strong>VS</strong></li>
<li>Token: <strong>1111d7nhcwse30wq</strong></li>
</ul>
</noscript>
<input type="submit" name="i4Go_submit" id="i4Go_submit" value="Continue" />
</div>
</form>
</body>
</html>
Edited by: sgudipat on Apr 24, 2012 1:20 PMHere is working example for your HTML using xpath to extract values from html
You can store your html response in clob variable and then extract the value with xpath
declare
l_clob clob;
l_value varchar2(100);
l_xml xmltype;
begin
l_clob :='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Return With Payment Token</title>
<script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript"><!--
picSpinner= new Image(40,40);
picSpinner.src="images/loading040.gif";
bodyOnLoad = function() {
$("#noScriptDiv").hide();
$("#scriptDiv").show();
$("#i4GoMainForm").submit();
//--></script>
</head>
<body onload="bodyOnLoad();">
<form name="i4GoMainForm" id="i4GoMainForm" action="http://google.com" method="POST" onsubmit="$(''#i4Go_submit'').attr(''disabled'',''disabled'');">
<input name="I4GO_RESPONSE" type="hidden" value="SUCCESS" />
<input name="I4GO_RESPONSECODE" type="hidden" value="1" />
<input name="I4GO_CARDTYPE" type="hidden" value="VS" />
<input name="I4GO_UNIQUEID" type="hidden" value="1111d7nhcwse30wq" />
<input name="I4GO_EXPIRATIONMONTH" type="hidden" value="12" />
<input name="I4GO_EXPIRATIONYEAR" type="hidden" value="2012" />
<input name="I4GO_CARDHOLDERNAME" type="hidden" value="" />
<input name="I4GO_STREETADDRESS" type="hidden" value="" />
<input name="I4GO_POSTALCODE" type="hidden" value="65000" />
<img src="images/loading040.gif" alt="Spinner..." /> Loading...
<noscript>
Statement of Tokenization
The payment information you have submitted has been securely stored in the Shift4 PCI-DSS certified data center and a token representing this information will be sent to the merchant for processing. Below is the information that will be returning to the originating merchant:
Response: SUCCESS
Response Code: 1
Card Type: VS
Token: 1111d7nhcwse30wq
</noscript>
<input type="submit" name="i4Go_submit" id="i4Go_submit" value="Continue" />
</form>
</body>
</html>';
execute immediate 'alter session set events =''31156 trace name context forever, level 2''';
l_xml := xmltype(l_clob);
execute immediate 'alter session set events =''31156 trace name context off''';
select extractvalue( l_xml
, '/html/body/form/input[@name="I4GO_CARDTYPE"]/@value'
, 'xmlns="http://www.w3.org/1999/xhtml"' )
into l_value
from dual;
dbms_output.put_line(l_value);
end;
Problem when parsing html with xpath and xmltype
Edited by: peterv6i.blogspot.com on Apr 26, 2012 9:38 AM -
Question on utl_http.
Hi,
I am very new to UTL_HTTP package..
I am trying to call one of my webservice using this package..here is the code for this
CREATE OR REPLACE PACKAGE BODY prepaid_service AS
FUNCTION get_prepaid(transactionNumber IN VARCHAR2, transactionType IN VARCHAR2) RETURN VARCHAR2 IS
req demo_soap.request;
resp demo_soap.response;
URL VARCHAR2(200);
ACTION VARCHAR2(200);
BEGIN
req := demo_soap.new_request('n:header',
'xmlns:n="urn:examples:prepaid"');
demo_soap.add_parameter(req, 'transactionNumber', 'xsd:string', transactionNumber);
demo_soap.add_parameter(req, 'type', 'xsd:string', transactionType);
URL := 'http://10.72.149.179:8080/soap/servlet/rpcrouter';
ACTION := NULL;
resp := demo_soap.invoke(req,URL,ACTION);
RETURN demo_soap.get_return_value(resp, 'return','xmlns:ns1="urn:examples:prepaid"');
END;
BEGIN
* Since the Web service resides outside of the firewall, we need to set
* the proxy in the current session before invoking the service.
utl_http.set_proxy('www-proxy', NULL);
utl_http.set_persistent_conn_support(TRUE);
END;
The exception handling illustrates the use of "pragma-ed" exceptions
like Utl_Http.Http_Client_Error. In a realistic example, the program
would use these when it coded explicit recovery actions.
Request_Failed is raised for all exceptions after calling
Utl_Http.Set_Detailed_Excp_Support ( enable=>false )
And it is NEVER raised after calling with enable=>true
CREATE OR REPLACE PACKAGE BODY demo_soap AS
FUNCTION new_request(method IN VARCHAR2,
namespace IN VARCHAR2)
RETURN request AS
req request;
BEGIN
req.method := method;
req.namespace := namespace;
RETURN req;
END;
PROCEDURE add_parameter(req IN OUT NOCOPY request,
name IN VARCHAR2,
reqtype IN VARCHAR2,
value IN VARCHAR2) AS
BEGIN
req.reqbody := req.reqbody ||'<'||name||' xsi:type="'||reqtype||'">'||value||'</'||name||'>';
END;
PROCEDURE generate_envelope(req IN OUT NOCOPY request,
env IN OUT NOCOPY VARCHAR2) AS
BEGIN
env := '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><soap:Body><'||req.method||' '||req.namespace||'>'||req.reqbody||'</'||req.method||'></soap:Body></soap:Envelope>';
END;
PROCEDURE show_envelope(env IN VARCHAR2) AS
i pls_integer;
len pls_integer;
BEGIN
i := 1; len := length(env);
WHILE (i <= len) LOOP
dbms_output.put_line(substr(env, i, 60));
i := i + 60;
END LOOP;
END;
PROCEDURE check_fault(resp IN OUT NOCOPY response) AS
fault_node xmltype;
fault_code VARCHAR2(256);
fault_string VARCHAR2(32767);
BEGIN
fault_node := resp.doc.extract('/soap:Fault','xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/');
IF (fault_node IS NOT NULL) THEN
fault_code := fault_node.extract('/soap:Fault/faultcode/child::text()', 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
fault_string := fault_node.extract('/soap:Fault/faultstring/child::text()', 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
raise_application_error(-20000, fault_code || ' - ' || fault_string);
END IF;
END;
FUNCTION invoke(req IN OUT NOCOPY request,
url IN VARCHAR2,
action IN VARCHAR2) RETURN response AS
env VARCHAR2(32767);
http_req utl_http.req;
http_resp utl_http.resp;
resp response;
BEGIN
generate_envelope(req, env);
show_envelope('url='||url);
show_envelope('action='||action);
show_envelope(env);
-- show_envelope(env);
http_req := utl_http.begin_request(url,'POST','HTTP/1.0');
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', length(env));
utl_http.set_header(http_req, 'SOAPAction', action);
utl_http.write_text(http_req, env);
http_resp := utl_http.get_response(http_req);
utl_http.read_text(http_resp, env);
utl_http.end_response(http_resp);
resp.doc := xmltype.createxml(env);
resp.doc := resp.doc.extract('/soap:Envelope/soap:Body/child::node()',
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"');
show_envelope(resp.doc.getstringval());
check_fault(resp);
RETURN resp;
--RETURN NULL;
END;
FUNCTION invoke11 RETURN response AS
req demo_soap.request;
env VARCHAR2(32767);
http_req utl_http.req;
http_resp utl_http.resp;
resp response;
URL VARCHAR2(200);
ACTION VARCHAR2(200);
BEGIN
dbms_output.put_line('IN invoke11');
req := demo_soap.new_request('n:header',
'xmlns:n="urn:examples:prepaid"');
demo_soap.add_parameter(req, 'transactionNumber', 'xsd:string','1234');
demo_soap.add_parameter(req, 'type', 'xsd:string', 'transactionType');
URL := 'http://10.72.149.179:8080/soap/servlet/rpcrouter';
ACTION := NULL;
generate_envelope(req, env);
dbms_output.put_line('gen env');
show_envelope('url='||url);
show_envelope('action='||action);
show_envelope(env);
-- show_envelope(env);
http_req := utl_http.begin_request(url,'POST','HTTP/1.0');
dbms_output.put_line('after B req');
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', length(env));
utl_http.set_header(http_req, 'SOAPAction', action);
dbms_output.put_line('start write');
utl_http.write_text(http_req, env);
dbms_output.put_line('end write');
http_resp := utl_http.get_response(http_req);
dbms_output.put_line('end resp');
utl_http.read_text(http_resp, env);
utl_http.end_response(http_resp);
resp.doc := xmltype.createxml(env);
resp.doc := resp.doc.extract('/soap:Envelope/soap:Body/child::node()',
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"');
show_envelope(resp.doc.getstringval());
check_fault(resp);
RETURN resp;
--RETURN NULL;
END;
FUNCTION get_return_value(resp IN OUT NOCOPY response,
name IN VARCHAR2,
namespace IN VARCHAR2) RETURN VARCHAR2 AS
BEGIN
RETURN resp.doc.extract('//'||name||'/child::text()',namespace).getstringval();
END;
END;
when i called first procedure(get_prepaid), it is not working it is giving error as "ORA-12545: Connect failed because target host or object does not exist
ORA-06512: at "SYS.UTL_HTTP", line 1020
ORA-06512: at "RMS_BATCH.PREPAID_SERVICE", line 36
ORA-06512: at line 10"
But when i try run demo_soap.invoke11(), it is giving me proper output.. Couldn't find out why this error is coming..I am trying to run invoke11() from TOAD.
Please help me in resolving this problem..
Thanks in advance
Satya/apps
bkrdlr@tsrdclvmappq# ls -ld /apps/bkrdlr/interface_files/
drwxrwsr-x 3 oraqabdc mqm 4096 Mar 29 16:51 /apps/bkrdlr/interface_files/
/apps
bkrdlr@tsrdclvmappq# ls -ld /apps/bkrdlr
drwxrwxr-x 12 bkrdlr mqm 4096 Mar 30 09:34 /apps/bkrdlr
/apps
bkrdlr@tsrdclvmappq# ls -ld /apps
drwxr-xr-x 7 root root 4096 Jul 27 2010 /apps
/apps
bkrdlr@tsrdclvmappq# sqlplus cms/cms
SQL*Plus: Release 11.1.0.7.0 - Production on Wed Mar 30 17:20:15 2011
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for IBM/AIX RISC System/6000: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
SQL>Thank you. -
Invalid request when calling REST-webservice with UTL_HTTP.
Hello,
When i try to send some data to a REST-webservice i get as response "INVALID REQUEST"
I Think it is about the request-body that seems to be no UTF-8.
I tried to set the characterset with utl_http.set_body_charset(t_http_req, 'UTF-8').
But when i read the characterset with utl_http.get_body_charset(t_charset);, is still get "ISO-8859-1"
I am using: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
Some help would realy be appreciated because i am out of options trying to get the code working..
======MY CODE==========
create or replace procedure ipm40_send_bekendmaking(p_bdmg_id in number)
as
r_bekendmaking ipm40_bekendmakingen%rowtype;
r_gemeente ipm40_gemeenten%rowtype;
l_url httpuritype;
t_http_req utl_http.req;
t_http_resp utl_http.resp;
t_request_body varchar2(32767);
t_respond varchar2(32767);
-- t_teller integer := 1;
-- t_output varchar2(2000);
t_start number := 1;
t_body_lengte number;
t_chunkdata varchar2(4000);
t_tijd_1 varchar2(256);
t_tijd_2 varchar2(256);
t_timeout integer;
t_length number;
t_charset varchar2(256);
begin
select *
into r_bekendmaking
from ipm40_bekendmakingen
where id = p_bdmg_id;
select *
into r_gemeente
from ipm40_gemeenten
where gmte_code = r_bekendmaking.gmte_code;
l_url := httpuritype.createuri('http://zwolle.stadsbeheer.com:82/apex/ipm40bekendmaking?p_bdmg_id='||r_bekendmaking.id);
t_request_body := l_url.getClob();
/* request that exceptions are raised for error Status Codes */
--Utl_Http.Set_Response_Error_Check ( enable => true );
/* allow testing for exceptions like Utl_Http.Http_Server_Error */
--Utl_Http.Set_Detailed_Excp_Support ( enable => true );
utl_http.set_transfer_timeout(300);
t_http_req:= utl_http.begin_request( r_gemeente.url_webservice_bekendmakingen
, 'POST'
, 'HTTP/1.1');
utl_http.set_body_charset(t_http_req, 'UTF-8');
utl_http.get_body_charset(t_charset);
utl_http.set_authentication(t_http_req,r_gemeente.user_webservice_bekendmakingen,r_gemeente.pw_webservice_bekendmakingen);
t_length := length(t_request_body);
utl_http.set_header(t_http_req, 'Content-Type', 'application/xml charset=UTF-8');
utl_http.set_header(t_http_req, 'Content-Length', t_length);
utl_http.set_header(t_http_req, 'Transfer-Encoding', 'chunked' ); --
t_body_lengte := dbms_lob.getlength(t_request_body);
loop
t_chunkdata := dbms_lob.substr(t_request_body, 2000, t_start);
utl_http.write_text ( t_http_req, t_chunkdata );
t_start := t_start + 2000;
if t_start > t_body_lengte
then
exit;
end if;
end loop;
t_http_resp:= utl_http.get_response(t_http_req);
utl_http.read_text(t_http_resp, t_respond);
utl_http.end_response(t_http_resp);
if instr(t_respond,'Successfully document processed') != 0
then
update ipm40_bekendmakingen
set ind_status = 'S'
, datum_verzonden = sysdate
, response = t_respond
where id = r_bekendmaking.id;
else
update ipm40_bekendmakingen
set ind_status = 'F'
, datum_verzonden = null
, response = t_respond
where id = r_bekendmaking.id ;
end if;
commit;
exception
when others
then
t_tijd_2 := to_char(sysdate,'HH24:MI:SS');
t_respond := substr(sqlerrm,1,2000);
update ipm40_bekendmakingen
set ind_status = 'F'
, datum_verzonden = null
, response = t_respond
where id = r_bekendmaking.id ;
commit;
end;
===THE RESPOND=============
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to process the request:
<PRE>
POST /pushxml/pushxml-bm HTTP/1.0
Authorization: Basic Ymtfc21hcnRob2xkaW5nOllyZXMzdlFR
Content-Type: application/xml charset=UTF-8
Content-Length: 2096
Transfer-Encoding: chunked
Connection: close
</PRE>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Invalid Request
</STRONG>
</UL>
<P>
Some aspect of the HTTP Request is invalid. Possible problems:
<UL>
<LI>Missing or unknown request method
<LI>Missing URL
<LI>Missing HTTP Identifier (HTTP/1.0)
<LI>Request is too large
<LI>Content-Length missing for POST or PUT requests
<LI>Illegal character in hostname; underscores are not allowed
</UL>
<P>Your cache administrator is [email protected].
<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Fri, 12 Aug 2011 17:33:24 GMT by asd2cc001.asp4all.nl (squid)
</ADDRESS>
</BODY></HTML>Always check the access_log and error_log files of the Apache web server in such a case. This will identify whether the error comes from Apache itself, mod_plsql, the Apex run-time engine, or the Oracle database.
I see that you're creating a HTTP/1.1 in PL/SQL - however, the web server response indicates a HTTP/1.0 call was received. Unusual. And could be part of the problem. -
Not able to receive the web service response to java client - jax-rpc
HI,
Have a wsdl and created the java client using wscompile and got the set of files (Port, Binding, ServiceLocator, Service and all related java files).
My java client sends the valid java request to the webserver and i could see the correct response coming back to my machine as the reply from the webserver.
But i couldnt get the response printed using System.out.println in my java client when i invoke call.invoke() method with needed input parameters.
Do i need to set any encoding or how do i get the response in the my java client which is returned from the webserver?The whole PL/SQL which fails in case it helps to solve the issue
declare
peticion VARCHAR2(32767);
env VARCHAR2(32767);
url varchar2(1000);
http_req utl_http.req;
http_resp utl_http.resp;
begin
url:='http://<HOST>:7778';
-- soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
-- <auth:BasicChallenge
-- xmlns:auth="http://www.soap-authentication.org/2002/01/">
-- <Realm>Oracle Calendar Web Services</Realm>
-- </auth:BasicChallenge>
peticion:='
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<auth:BasicAuth xmlns:auth="http://soap-authentication.org/2002/01/">
<Name>sysadmin</Name>
<Password>sysadmin1</Password>
</auth:BasicAuth>
</soap:Header>
<soap:Body>
<cwsl:Create xmlns:cwsl="http://www.oracle.com/WebServices/Calendaring/1.0/">
<CmdId>Testoraptor Command 31</CmdId>
<iCalendar>
<vcalendar prodid="-//Oracle//Calendaring//Calendarlet//EN" version="2.0">
<vevent>
<class>PUBLIC</class>
<description>a long description</description>
<dtstart>20061003T090909</dtstart>
<duration>60M</duration >
<location>my location</location>
<priority>2</priority>
<summary>a title</summary>
<uid>4567</uid>
<x-oracle-eventtype>APPOINTMENT</x-oracle-eventtype>
</vevent>
</vcalendar>
</iCalendar>
</cwsl:Create>
</soap:Body>
</soap:Envelope>';
http_req := utl_http.begin_request(url||'/ocws-bin/ocas.fcgi', 'POST','HTTP/1.0');
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', length(peticion));
utl_http.set_header(http_req, 'SOAPAction', '"http://www.oracle.com/WebServices/Calendaring/1.0/Create"');
utl_http.write_text(http_req, peticion);
dbms_output.put_line (length(peticion));
http_resp := utl_http.get_response(http_req);
utl_http.read_text(http_resp, env);
utl_http.end_response(http_resp);
end;
We have tried many different XML structures but we are not able to create an appointment. -
Hello,
I am using UTL_HTTP in order to invoke one of the web services.
Can any one please help here....
utl_http.set_header(http_req, 'SOAPAction', action)
--> Here what is action, what do i need to pass when i invoke url ?
I have a sample where it calls utl_http. But i hardly understand the terms used here except url.
Can any any one tell me what is namespace, action, method used in below example
If you feel any direct alternative ay please guide me.
CREATE OR REPLACE PACKAGE BODY time_service AS -- Location of Web service definition
-- http://www.ripedev.com/webservices/LocalTime.asmx?WSDL
FUNCTION get_local_time(zipcode IN VARCHAR2) RETURN VARCHAR2 IS
req demo_soap.request;
resp demo_soap.response;
BEGIN
req := demo_soap.new_request('LocalTimeByZipCode',
'xmlns="http://ripedev.com/xsd/ZipCodeResults.xsd"');
demo_soap.add_parameter(req, 'ZipCode', 'xsd:string', zipcode);
resp := demo_soap.invoke(req,
'http://www.ripedev.com/webservices/LocalTime.asmx',
'http://ripedev.com/xsd/ZipCodeResults.xsd/LocalTimeByZipCode');
RETURN demo_soap.get_return_value(resp, 'LocalTimeByZipCodeResult',
'xmlns="http://ripedev.com/xsd/ZipCodeResults.xsd"');
END;
END;
CREATE OR REPLACE PACKAGE BODY demo_soap AS
FUNCTION new_request(method IN VARCHAR2,
namespace IN VARCHAR2)
RETURN request AS
req request;
BEGIN
req.method := method;
req.namespace := namespace;
RETURN req;
END;
PROCEDURE add_parameter(req IN OUT NOCOPY request,
name IN VARCHAR2,
type IN VARCHAR2,
value IN VARCHAR2)
AS
BEGIN
req.body := req.body ||
'<'||name||' xsi:type="'||type||'">'||value||'</'||name||'>';
END;
PROCEDURE generate_envelope(req IN OUT NOCOPY request,
env IN OUT NOCOPY VARCHAR2)
AS
BEGIN
env := '<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body><'||req.method||' '||req.namespace||'
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'||
req.body||'</'||req.method||'></SOAP-ENV:Body></SOAP-ENV:Envelope>';
END;
PROCEDURE
show_envelope(env IN VARCHAR2)
AS
i pls_integer;
len pls_integer;
BEGIN
i := 1; len:= length(env);
WHILE (i <= len) LOOP
dbms_output.put_line(substr(env, i, 60));
i := i + 60;
END LOOP;
END;
PROCEDURE check_fault(resp IN OUT NOCOPY response)
AS
fault_node xmltype;
fault_code VARCHAR2(256);
fault_string VARCHAR2(32767);
BEGIN
fault_node := resp.doc.extract('/soap:Fault', 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/'); IF (fault_node
IS NOT NULL) THEN
fault_code := fault_node.extract('/soap:Fault/faultcode/child::text()', 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
fault_string := fault_node.extract('/soap:Fault/faultstring/child::text()', 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
raise_application_error(-20000, fault_code || ' - ' || fault_string);
END IF;
END;
FUNCTION invoke( req IN OUT NOCOPY request,
url IN VARCHAR2,
action IN VARCHAR2)
RETURN response
AS
env VARCHAR2(32767);
http_req utl_http.req;
http_resp utl_http.resp;
resp response;
BEGIN
generate_envelope(req, env); -- show_envelope(env);
http_req := utl_http.begin_request(url, 'POST','HTTP/1.0');
UTL_HTTP.SET_AUTHENTICATION (HTTP_REQ, 'G016D01/S0162114','Xenios02', 'Basic',true);
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req,'Content-Length', length(env));
utl_http.set_header(http_req, 'SOAPAction', action);
utl_http.write_text(http_req,env);
http_resp := utl_http.get_response(http_req);
utl_http.read_text(http_resp, env);
utl_http.end_response(http_resp);
resp.doc := xmltype.createxml(env);
resp.doc := resp.doc.extract('/soap:Envelope/soap:Body/child::node()',
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"'); -- show_envelope(resp.doc.getstringval());
check_fault(resp);
RETURN resp;
END;
FUNCTION get_return_value(resp IN OUT NOCOPY response,
name IN VARCHAR2,
namespace IN VARCHAR2)
RETURN VARCHAR2
AS
BEGIN
RETURN resp.doc.extract('//'||name||'/child::text()',namespace).getstringval();
END;
END;Hi,
Please go through this link. I think this will definitely help you.
http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_http.htm
regards,
Dipankar. -
AXF_SOAPCALL response error 302 Moved Temporarily
DECLARE
STRREQUEST VARCHAR2(32767);
strResponse VARCHAR2(32767);
BEGIN
STRREQUEST :='<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken>
<Username>weblogic</Username> <Password>user_passwrod</Password>
</UsernameToken>
</Security>
</soap:Header>
<soap:Body xmlns:ns1="http://imaging.oracle/">
<ns1:updateDocument>
<documentId>2.IPM_002620</documentId>
<uploadToken></uploadToken>
<fieldValues name="Status" id="4">
<value type="TEXT">Posted</value>
</fieldValues>
<reserved>0</reserved>
</ns1:updateDocument>
</soap:Body>
</soap:Envelope>
STRRESPONSE := AXF_SOAPCALL ('http://myserver:16000/imaging/ws' , STRREQUEST, 'true' ,Null,Null );
DBMS_OUTPUT.PUT_LINE (STRRESPONSE);
end;
getting the folowing response :
<html><head><title>302 Moved Temporarily</title></head>
<body bgcolor="#FFFFFF">
<p>This document you requested has moved temporarily.</p>
<p>It's now at http://amcon-orclipm1:16000/imaging/ws/.</p>
</body></html>
Any idea what's the error :
302 Moved Temporarily
his document you requested has moved temporarily
Thanks
BilalHi,
I am working on a similar scenario where I my consuming an external web service using https protocol from PI.
I have configured a soap receiver channel to call the target url of this web service as https://portal.xyz.org.uk/webservice_alt.
I am getting an error HTTP 302 suggesting that PI is not able to follow the re-direction to the target URL as the service resides not on that URL but on https://portal1.xyz.org.uk/webservice_alt or https://portal2.xyz.org.uk/webservice_alt.
This is their server fail over handling mechanism which is very common. But PI 7.0 is not able to handle this.
So if I change the target URL on the SOAP receiver channel to https://portal1.xyz.org.uk/web service or https://portal2.xyz.org.uk/webservice_alt , PI works fine without errors . But this is not the right approach because, every time the web service provider takes one of these systems down for upgrade/patching etc, they inform us and then I manually go and change the target URL to the available server on my production PI system config.
My problem is I want to resolve this redirection error in PI. I have tried raising a call with SAP itself and they pointed out to use Axis adapter which is still not working.
So I am here asking for help. any suggestions please from the experts?
Thanks
Jhansi. -
How can I stop a task sequence if a custom HTA preflight check fails?
In our currently deployment method, we launch an HTA program before initiating the OSD process. This is only when run from the RAP menu, not via PXE. When a user initiates OSD through that menu, they get a message prompting them to close Outlook, and
a countdown of 5 mins, then OSD starts. They also have the ability to click on an 'OK' button to proceed on their own.
I've created a new script which checks WMI if Outlook and/or OCS are open, and if the machine is running on battery, spit out a "Failed" response and stop the HTA. I've also added a "recheck" button to re-do the check, and an 'OK
button if people jsut want to continue.
I'm curious if there is a way to prevent the task sequence from continuing if any of those conditions arent met. Currently it just pops up and says "Failed, Cannot conitue", but if they close the window, the task sequence thinks the program
has run, and the OSD migration starts. I'd like to be able and get the script to cancel the OSD process if a check fails.
Has anyone had success with this, using WINXP? I'd use the MS pre-flight check but it's only for WIN7.Interesting. Thanks for the response. Is there anybody out there that can assist with VBS part of the solution?
Here's the code I'm working with. Currently the battery piece isnt working as it should but I can figure that our, eventually. I'd like to get Jason's proposed solution in the code. If this isn't the right place, I'll take this somewhere
else.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>OSD Preflight checks</title>
<HTA:APPLICATION
APPLICATIONNAME="OSD Preflight checks"
ID="objOSDPreReqChecks"
SCROLL="no"
CONTEXTMENU="no"
SINGLEINSTANCE="no"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
WINDOWSTATE="normal"/>
<!-- #region STYLEs-->
<style type="text/css">
H1{color:Black;text-align:center;font-family: Arial, Helvetica, sans-serif;font-size: 26px;}
p{font-family:"Arial";font-size:10px;}
fail{color:Red;text-align:center;}
.Version {float:left; font-size:1.0em;font-style:italic;color:#888888;font-weight:bold;}
.Header1 {width: 180px; text-align: right;font-weight:bold;}<!-- '1st column heading -->
H2 {font-family: Arial, Helvetica, sans-serif; text-align: center;}
H3 {font-style: italic;}
.style2 {width: 180px; text-align: left;}
.Header2 {width: 150px; text-align: right;font-weight:bold;}<!-- '2nd column heading -->
.style4 {width: 410px; text-align: left;}
.StatusBar
font-family: Arial, Helvetica, sans-serif;
text-align: center;
.hidden {display: none; visibility: hidden;}
</style><!-- #endregion -->
</head>
<script language="VBScript" type="text/vbscript">
'======================================================================================
' Script
' Version
' Purpose To check a machine is suitable for taking an OS deployment
'======================================================================================
'Features
' Modular design
' Verbose "Debug Mode"
' In-built data validation
' Custom error handling
' Custom error codes - 90x0
' Generic WMI handler
'BUGfix: Change CLng to CDbl to avoid overflow (in GetRAM)
'fixed - moved head section to top to become head > script > body
'fixed - fCheckModel display with leading ,
'fixed - fgetmodels dictionary list
Option Explicit
' #region GLOBAL DECLARATIONS: Persistent fold region
'======================================================================================
'GLOBAL Vars
'Things to just display (in GUI)
Dim strRAM
Dim strCPUInfo
Dim strCPUName
Dim strCPUDesc
Dim iCPUCount
Dim iCPUCoreCount
Dim iRAM
Dim strBIOSver, strBIOSDate, strBIOSInfo
'Time related
Dim TimerInterval 'timer to refresh HTA at start
Dim iTimer 'abort timer
Const iAbortTimeout=300000 'delay before window closes (in milliseconds)
Dim pbTimerID
Dim pbHTML
Dim pbWaitTime
Dim pbHeight
Dim pbWidth
Dim pbBorder
Dim pbUnloadedColor
Dim pbLoadedColor
Dim pbStartTime
'Dictionary
Dim objModelsDict,colKeys,strKey 'models
Dim objApprovedMakesDict
'Misc GLOBAL vars
Dim blnDebug 'set TRUE to trigger debug mode
Dim bAbortBuild 'Boolean flag to abort or not abort
Dim strTemp 'throwaway/scratch
Dim strNamespace 'wmi default namespace for ANY machine
Dim strComputer 'wmi reference to current machine, just .
Dim strService 'WMI service
Dim strQuery 'custom WQL
Dim ErrMsg 'custom error messages
Dim iErrMode 'State machine for error mode
Dim lFlags 'WMI flag
Dim strDisks
'Pre-requisites - things that will cause build to abort if values do not meet spec
Dim strHTAVendor 'Make of hardware
Dim strHTAVendorState
Dim strHTAModel 'Model of hardware
Dim strHTAModelState 'Model state
Dim strHTARAM 'RAM
Dim strHTARAMState 'RAM state
Dim strHTACPUSpeed 'Processor speed
Dim strHTACPUCores 'Number of cores
Dim strHTACPUFullInfo 'CPU + cores
Dim strHTAHDD 'Disk info
Dim strHTAHDDState 'Disk state
Dim strHTACheckRAW 'NTFS check
Dim strHTAArchitecture 'Processor support
Dim strHTAProduct 'Product ID
Dim strHTAOutlook 'Outlook running
Dim strHTAOutlookState 'Outlook state
Dim strHTABattery 'Battery check
Dim strHTABatteryState 'Battery state
'for WQL filters
Dim strWQLPCInfo 'Pre-req - (1) for various inc. domain role (servers)
Dim strWQLRAM 'Pre-req - (2) RAM
Dim strWQLCPU 'Pre-req - CPU speed string (not int)
Dim strWQLBootOrder 'Pre-req - Boot order string
Dim strWQLSATAMode 'Pre-req - HDD mode
Dim strWQLGenericBIOS
Dim strWQLCPUCount 'Pre-req - how many CPUs
Dim strWQLCPUInfo
Dim strWQLFSType 'Pre-req - Check HDD not RAW (i.e. is NTFS)
Dim strWQLDisks 'Disks
Dim strWQLChassis 'Machine type
Dim strWQLID 'Unique code from OEM
Dim strWQLProc 'is Outlook running = False
Dim strWQLBattery 'is on Battery = False
'State
Const cProblem = " Problem!"
Const cRunAgain =" RunCheck: Run System Check Again"
Const cSuccess = " Success!"
Const cPassed=" Pass"
Const cFail=" Fail"
'Pre-requisite to check: SET VALUES HERE vvvvvvvvvvvvvvvv
Const cApprovedOEM="Hewlett-Packard"
Const LegacyOEM1="Dell Inc."
Const LegacyOEM2="IBM"
Const cMinimumMemoryMB = 1000 'RAM in MB
'Const cMinimumMemoryMB = 1000000 'force fail test data RAM in MB
Const cMinFS="NTFS"
' Const cMinFS="HPFS" 'force fail test data
Const iMinCores=1
'Const iMinCores=10099 'force fail cores test data
Const iMinCPUSpeed=2 '20 'in GHz
'Const iMinCPUSpeed=90000 'in GHz
Const iMinCPUArch=32
'Const iMinCPUArch=64
' #endregion
' To hide anything use ID.className = "hidden", to show set to "", e.g. NotFoundArea.className = "hidden"
Sub Window_Onload
Err.Clear
VersionSpan.InnerText = objOSDPreReqChecks.Version 'Get version
self.focus
self.moveTo 100,100 'Move window top left
StatusBar.InnerText="Validating machine..."
document.body.style.cursor = "wait" 'hourglass cursor
'Call PreflightChecks 'use for testing as a VBS only, otherwise HTA timer will call below
TimerInterval = window.setInterval("PreflightChecks",10)
End Sub
Function PreflightChecks
' #region HEADER NOTES: Persistent fold region
'Version history
'ver 5 OCTOBER 2011 - added error handler
'ver 3rd Nov - removed HPonly queries
'// Solution: Custom Script for use with MDT - Adapted from hardwareinfo.vbs Mikael Nystrom – http://deploymentbunny.com
'Typical BIOS content
'Processor Speed = 2133/1066 MHz
'Boot Order = Network Controller,ATAPI CD-ROM Drive,USB device,Hard Drive,Diskette Drive,PnP Device #2,PnP Device #3,PnP Device #4,PnP Device #5,PnP Device #6,PnP Device #7,PnPe #8,PnP Device #9,PnP Device #10,PnP Device #11
'SATA (disk) mode: *IDE,--,RAID,-- or IDE,*AHCI,RAID
'On Error Resume Next
' #endregion
' #region CONSTANTS: Persistent fold region
'======================================================================================
'Fields available in HP BIOS
Const sAsset = "Notebook Asset Tag"
Const sOwner = "Notebook Ownership Tag"
Const sMan = "Manufacturer"
Const sNoteModel = "Notebook Model"
Const sCPU = "Processor Type"
Const sCPUSpeed = "Processor Speed"
Const sRAM = "Memory Size"
Const sModel = "Product Name"
Const sBIOSName ="System BIOS"
Const sBIOSVer = "BIOS Version"
Const sBIOSDate = "BIOS Date"
'Other BIOS stuff you could use too
'Const sOwnerTag = "Enter Ownership Tag"
'Const sBIOS = "PCID"
'Const sBIOS = "Define Custom URL"
'Const sBIOS = "Set Alarm Time"
'Const sBIOS = "PCID Version"
Const TextMode="1" 'text case sensitive for dict obj
'WMI core constants
Const wbemFlagReturnImmediately = 16 'wmi - Causes the call to return immediately.
Const wbemFlagForwardOnly = 32 'wmi - Causes a forward-only enumerator to be returned.
'Forward-only enumerators are generally much faster and
'use less memory than conventional enumerators, but don't allow calls to SWbemObject.Clone_
'Advisory config values - as in "you want to the change these"
Dim strHTABootOrder
Dim strHTASATAMode
'Dim strHTACPU
' #endregion
'======================================================================================
' #region WQL: Persistent fold region
lFlags = wbemFlagReturnImmediately + wbemFlagForwardOnly
'Queries of things to check (HP)
strWQLBootOrder = "select Name, value from HP_BIOSSetting where Name='Boot order'"
strWQLSATAMode = "select Name, value from HP_BIOSSetting where (Name='SATA emulation' or name='SATA device mode')"
strWQLDisks ="SELECT * FROM Win32_DiskDrive where mediatype like 'Fixed%hard disk%'" 'win32_disk only avail after W7
strWQLFSType ="SELECT * from Win32_LogicalDisk where DriveType='3'" 'only bother with HDDs
'Generic WMI query strings
strWQLGenericBIOS="SELECT Manufacturer,SMBIOSBIOSVersion,ReleaseDate FROM Win32_BIOS WHERE PrimaryBIOS = True"
strWQLCPUCount= "SELECT NumberOfProcessors,NumberOfLogicalProcessors from Win32_ComputerSystem"
strWQLCPUInfo="SELECT Name,DataWidth,description,MaxClockSpeed,NumberofCores,NumberOfLogicalProcessors from Win32_Processor"
strWQLPCInfo="SELECT Domain,DomainRole,SystemType,Manufacturer,Model,TotalPhysicalMemory FROM Win32_ComputerSystem"
' strWQLPCInfo="SELECT Domain,DomainRole,SystemType,Manufacturer FROM Win32_ComputerSystem"
strWQLChassis="SELECT ChassisTypes from Win32_SystemEnclosure"
strWQLID="SELECT IdentifyingNumber,UUID from Win32_ComputerSystemProduct"
strWQLRAM="SELECT * FROM Win32_PhysicalMemory"
strWQLProc="SELECT * FROM Win32_Process"
strWQLBattery="SELECT * FROM BatteryStatus Where Voltage > 0"
' #endregion
' #region MAIN algorithm
'=====================================================================================================
' MAIN
'Algorithm
'1) Check make (vendor)
'2) Check model (in list)
'3) Check RAM >x
'4) Check HDD TYPE (HDD is not RAW)
'5) Check CPU architecture
'6) Check outlook
'7) Check battery
'=====================================================================================================
'Initialise
window.clearInterval(TimerInterval) 'Reset timer to 0
' blnDebug=True
blnDebug=False
bAbortBuild=False 'default to DON'T abort
' bAbortBuild=True
'Build list of approved vendors
Set objApprovedMakesDict = CreateObject("Scripting.Dictionary")
objApprovedMakesDict.comparemode=VBTextCompare
objApprovedMakesDict.add cApprovedOEM,"OK"
objApprovedMakesDict.add LegacyOEM1,"OK"
objApprovedMakesDict.add LegacyOEM2,"OK"
objApprovedMakesDict.add "Lenovo","Testdata"
If blnDebug Then Stop
'1) all machines check make
strHTAVendor=fCheckVendor(strWQLGenericBIOS) 'check vendor in BIOS - if vendor not approved ABORT without proceeding
If bAbortBuild=True Then
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "FATAL ERROR - goodbye cruel world"
iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript")
Else
StatusBar.InnerText="Vendor: " & strHTAVendor & vbTab & " " & strHTAVendorState
'2) Discover current Model
strHTAModel=fGetModelName(strWQLPCInfo) 'get model name from WMI
strHTAModel=fUniversalCheckData(strHTAModel,"'Discover Model - fGetModelName'") 'validate
Call fGetModels 'get list of all valid models (from text file)
strHTAModel=fCheckModel(strHTAModel)
'2a) Model number (optional)
strHTAProduct=fGetComputerSystemProdIDNumber(strWQLID) 'manufacturer's product ID
strHTAProduct=fUniversalCheckData(strHTAProduct,"'Discover ID - fGetComputerSystemProdIDNumber'")
' StatusBar.InnerText=StatusBar.InnerText & VbCrLf & vbTab & "Product Code: " & vbTab & strHTAProduct
'3) Check installed Memory
strHTARAM=fGetRAM(strWQLRAM) 'find RAM size
strHTARAM=fUniversalCheckData(strHTARAM,"'Detect RAM - fCheckRAM'")
strHTARAM=fCheckRAM(strHTARAM) 'check RAM meets req
If strHTARAMState=cFail Then Exit Function
'4) Disk format IS NTFS
strDisks=fGetDrives(strWQLFSType) 'Get formatting info for all drives
strHTACheckRAW=fUniversalCheckData(strDisks,"'Detect filesystem - fCheckNTFS'") 'Validate data
strHTACheckRAW=fCheckNTFS(strDisks) 'Check FS format is acceptable (not RAW)
If strHTACheckRAW=cFail Then Exit Function
'Generic CPU calls
strHTACPUFullInfo="CPUs:" & fGetCPUInfo(strWQLCPUInfo) & " with CPU cores:" & iCPUCoreCount
strBIOSInfo="BIOS version: " & strBIOSver & ", dated " & strBIOSDate
'5a) CPU Speed check (info from http://www.robvanderwoude.com/wmiexamples.php)
strCPUInfo=WMI(strWQLCPUInfo,strNamespace) 'Get CPU details
strTemp=split(strCPUInfo,"@"): strHTACPUSpeed=strTemp(1)
strHTACPUSpeed=fUniversalCheckData(strHTACPUSpeed,"'Check processor - fCheckCPUSpeed'") 'Validate data
strHTACPUSpeed=fCheckCPUSpeed(strHTACPUSpeed) 'Check CPU clock speed
'5b) cores check
strHTACPUCores=fUniversalCheckData(iCPUCoreCount,"Check core count - fCheckCores") 'Validate data
iCPUCoreCount=fCheckCores(iCPUCoreCount) 'pass or fail?
'5c) CPU address width
strHTAArchitecture=fUniversalCheckData(strHTAArchitecture,"Check core count - fCheckCores") 'Validate data
strHTAArchitecture=fCheckCPUArch(strHTAArchitecture)
'6) Check outlook
strHTAOutlook=fCheckProcess(strWQLProc)
'7) Check Battery
strHTABattery=fCheckBattery(strWQLBattery)
'end checkss
document.body.style.cursor = "default"
'Display hardware values in GUI (in table)
Vendor.innerhtml = strHTAVendor 'Use str...var..STATE if you want Pass/fail text instead
Model.innerhtml = strHTAModel
Product.innerhtml = strHTAProduct
RAM.innerhtml = strHTARAM
CPUspeed.innerhtml = strHTACPUSpeed
CPUInfo.innerhtml = strHTACPUFullInfo
HDDFS.innerhtml = strHTACheckRAW
CapableArchitecture.innerhtml=strHTAArchitecture
BIOSversion.innerhtml = strBIOSver
BIOSDate.innerhtml = strBIOSDate' CPUName.innerhtml = strCPUDesc 'GetCPUName
End If
'======================================================================================
' #endregion
End Function
'generic WMI queries, by field and namespace
Function WMI(strQuery,strNameSpace)
'Aim: generic WMI calls
'return value of BIOS
On Error Resume Next
Dim colItems,objItem
Dim objWMI
Const strService = "winmgmts:{impersonationlevel=impersonate}//" 'binding to WMI
Const strComputer = "." 'this machine
Set objWMI = GetObject(strService & strComputer & strNamespace) 'GLOBAL wmi
Set colItems = objWMI.ExecQuery(strQuery,,lFlags)
For Each objItem In colItems
If Err Then
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "WMI query: " & strQuery & " in " & strNamespace & objItem.Name
Call ErrHandler("WMI error " & strQuery,1)
Else
WMI=objItem.Name 'Return value
End If
Next
End Function
Function fGetModelName(strWQLPCInfo)
'Aim: Get model name from BIOS - WMI field sometimes varies if laptop, so try two
'Return STRING: Model string from BIOS or "UNKNOWN" if null
On Error Resume Next
Dim colPCInfo,objPCItem
Dim strModel
Set colPCInfo = GetObject("winmgmts:").ExecQuery(strWQLPCInfo,"WQL",lFlags)
If Err Then
Call ErrHandler("fGetModelName: Error querying WMI " & strWQLPCInfo,2)
Else
For Each objPCItem In colPCInfo
If Not IsNull(objPCItem.Model) Then
strModel=objPCItem.Model
' iRAM=objPCItem.TotalPhysicalMemory
Else
If (strHTAVendor=cApprovedOEM And IsLaptop = True) Then ' resort to HP specific query for older laptops
'Notebook
strModel=QueryHPBIOS(sNoteModel)
if strModel="" then strModel=QueryHPBIOS(sModel) 'try alt value
Else
strModel=QueryHPBIOS(sModel)
End If
End If
Next
End If
If strModel = "" Then
fGetModelName = "UNKNOWN"
Model.style.visibility="hidden"
Else
fGetModelName=strModel
End If
End Function
'====================================================
'====================================================
Function fGetRAM(strQuery)
'Aim: get RAM installed. NB Win32_ComputerSystem::TotalPhysicalMemory may not be accurate
'Return integer
On Error Resume Next 'equiv to Err.Clear
Dim colItems, item
Dim iTotalMemory
Set colItems = GetObject("winmgmts:").ExecQuery(strQuery,"WQL",lFlags)
If Err Then
Call ErrHandler("fGetRAM: Error querying " & strQuery,2)
Else
iTotalMemory = 0
For Each item In colItems
iTotalMemory = iTotalMemory + CDBL(item.Capacity)/(1024^2)
Next
End If
If iTotalMemory = "" Then
fGetRAM = "RAM UNKNOWN"
RAM.style.visibility="hidden"
Else
fGetRAM=iTotalMemory
End If
End Function
'====================================================
'====================================================
Function fGetCPUInfo(strQuery)
'Aim: query WMI for CPU info - number and number of cores
'Return: function=CPU count, var for the cores: iCPUCoreCount, strHTAArchitecture, strCPUDesc
On Error Resume Next
Dim colItems, objItem
Dim NumberOfProcessors
Set colItems = GetObject("winmgmts:").ExecQuery(strQuery,"WQL",lFlags)
If Err Then
Call ErrHandler("GetCPUInfo: Error querying " & strQuery,2)
Else
For Each objItem In colItems
If Err Then
Else
If Not IsNull(objItem.NumberOfCores) Then
NumberOfProcessors = Trim(objItem.NumberOfCores) 'NumberOfProcessors
End If
If Not IsNull(objItem.NumberOfLogicalProcessors) Then
iCPUCoreCount = Int(Trim(objItem.NumberOfLogicalProcessors))
End If
If Not IsNull(objItem.DataWidth) Then
strHTAArchitecture=Trim(objItem.DataWidth) & "-bit"
End If
If Not IsNull(objItem.description) Then
strCPUDesc = Trim(objItem.description) 'cpu name
End If
End If
Next
If NumberOfProcessors = "" Then
NumberOfProcessors = "UNKNOWN"
End If
fGetCPUInfo = Int(NumberOfProcessors)
' iCPUCoreCount = Int(NumberOfLogicalProcessors)
End If
End Function
'====================================================
'====================================================
Function fGetComputerSystemProdIDNumber(strWQLID)
'Aim: Get UUID from Win32_ComputerSystemProduct
'Return: great big integer
Dim colSys,objSys
Dim strUUID
On Error resume next
Set colSys = GetObject("winmgmts:").ExecQuery(strWQLID,"WQL",lFlags)
If Err then
Call ErrHandler("fGetComputerSystemProdIDNumber: Error querying " & strWQLID,2)
Else
For Each objSys In colSys
If Not IsNull(objSys.IdentifyingNumber) Then
strUUID = Trim(objSys.IdentifyingNumber)
End If
Next
If strUUID = "" Then
fGetComputerSystemProdIDNumber = "UNKNOWN"
Else
fGetComputerSystemProdIDNumber = strUUID
End If
End If
End Function
'=================================================================================
'=================================================================================
Function fGetDrives(strQuery)
Dim colDisks,objHDD
Dim strDriveType, strDiskSize, strDisk
Dim strDiskFSType
Dim iGBUnits
On Error Resume Next
iGBUnits=1073741824
Dim iRAW
iRAW=0
Set colDisks = GetObject("winmgmts:").ExecQuery(strQuery)
For Each objHDD In colDisks
Select Case objHDD.DriveType
Case 1 strDriveType = "Drive could not be determined."
Case 2 strDriveType = "Removable Drive"
Case 3 strDriveType = "Local hard disk."
Case 4 strDriveType = "Network disk."
Case 5 strDriveType = "Compact disk (CD)"
Case 6 strDriveType = "RAM disk."
Case Else strDriveType = "Drive type Problem."
End Select
strDiskFSType = objHDD.FileSystem
'Find C
If objHDD.Name="C:" Then
If isNull(objHDD.FreeSpace) Then
If blnDebug=True then Call ErrHandler("ALERT!! Volume " & objHDD.Name & "is RAW",1) 'Abort/clean
fCheckDrives="ALERT!! Volume " & objHDD.Name & "is RAW"
End If
End If
strDiskSize = Int(objHDD.Size /iGBUnits) & "GB" 'calc size of disk
strDisk = strDisk & VbCrLf & "Vol " & objHDD.Name & " (" & strDriveType & ") size: " & strDiskSize & " (free: " & Int(objHDD.FreeSpace /iGBUnits) & "GB), " & strDiskFSType
fGetDrives=strDisk
Next
If (Err.Number <>0) Then
Call ErrHandler("WMI Property Query Error: [" & Err.Number & "]",2)
fGetDrives = -1
Exit Function
End If
End Function
'=================================================================================
'=================================================================================
Function fUniversalCheckData(varData,strStage) 'template
'Aim: Check value passed...
'is not blank
'is in range x..y
'spelt OK
'is in a list
'format is text, numeric
'return: string: the original value
On Error Resume Next
Dim Err
if blnDebug Then StatusBar.InnerText = StatusBar.InnerText & VbCrLf & "Validating " & strStage & " data..."
If Err Then
Call ErrHandler("WARNING: Error discovering value in " & strStage,2) '1=Quit,2=Warn
strHTAModel="Unknown"
Else
Select Case varData
Case IsEmpty(varData) Or IsNull(varData)
Call ErrHandler("WARNING: Error in "& strStage,2) '1=Quit,2=Warn
fUniversalCheckData="Unknown"
Case IsNumeric(varData)
If varData<0 Then
Call ErrHandler("WARNING: Value negative"& strStage,2) '1=Quit,2=Warn
fUniversalCheckData="Unknown"
End if
' & varData &
Case IsDate(varData)
Case Else
fUniversalCheckData=varData 'Data OK - return value unchanged
End Select
End If
End Function
'=================================================================================
'Checks - follow if true DO, if false warn/abort
'=================================================================================
Function fCheckBattery(strQuery)
'Aim: Find if battery is running
'Return pass/fail
On Error Resume Next 'equiv to Err.Clear
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Dim colItems, item
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\WMI")
Set colItems = objWMIService.ExecQuery("SELECT * FROM BatteryStatus Where Voltage > 0", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each item In colItems
if objItem.PowerOnline = True Then
strHTABattery=objItem.PowerOnline
strHTABatteryState = cFail
Err.Raise 9010,"fCheckBattery",strHTABattery & " Laptop running on battery. OSD Cannot continue."
Call ErrHandler(ucase(strHTABatteryState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "FATAL ERROR - Laptop on Battery. Please plug into an outlet before proceeding."
iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript")
Else
strHTABatteryState = cPassed
End if
Next
fCheckBattery=strHTABattery
End Function
'====================================================
Function fCheckProcess(strQuery)
'Aim: Find if outlook is running
'Return pass/fail
On Error Resume Next 'equiv to Err.Clear
Dim colItems, item
Set colItems = GetObject("winmgmts:").ExecQuery(strQuery,"WQL",lFlags)
For Each item In colItems
if item.Name = "OUTLOOK.EXE" Then
strHTAOutlook=item.Name
strHTAOutlookState = cFail
Err.Raise 9010,"fCheckOutlook",strHTAOutlook & " running. OSD Cannot continue."
Call ErrHandler(ucase(strHTAOutlookState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "FATAL ERROR - Outlook Running, please close outlook before proceeding."
iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript")
Elseif item.Name = "communicator.exe" Then
strHTAOutlook=item.Name
strHTAOutlookState = cFail
Err.Raise 9010,"fCheckOutlook",strHTAOutlook & " running. OSD Cannot continue."
Call ErrHandler(ucase(strHTAOutlookState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "FATAL ERROR - Communicator Running, please close OCS before proceeding."
iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript")
Else
strHTAOutlookState = cPassed
End if
Next
fCheckProcess=strHTAOutlook
End Function
'====================================================
'1 - Make
Function fCheckVendor(strVendor)
'Aim: Check make is one the OS/build is designed For
'Return: STRINGS for "Make", BIOS version and BIOS date (generic): strHTAVendorState pass or fail
On Error Resume Next
Dim colItems,objItem
Set colItems = GetObject("winmgmts:").ExecQuery(strVendor, "WQL", lFlags)
For Each objItem In colItems
strHTAVendor=objItem.Manufacturer
if objApprovedMakesDict.exists(strHTAVendor) then
strBIOSver=objItem.SMBIOSBIOSVersion
strBIOSDate=Mid( objItem.ReleaseDate, 5, 2 ) & "/" & Mid( objItem.ReleaseDate, 7, 2 ) & "/" & Left( objItem.ReleaseDate, 4 )
strHTAVendorState=cPassed
Else
strHTAVendorState=cFail
Err.Raise 9010,"fCheckVendor",strHTAVendor & " found. The build will not work on this make of hardware"
Call ErrHandler(ucase(strHTAVendorState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
bAbortBuild=True
end if
Next
fCheckVendor=strHTAVendor
End Function
'=================================================================================
'=================================================================================
'2 - Models check
Function fCheckModel(strThisModel)
'Aim Check target machine is in list of models
'Return string
On Error Resume Next
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking model..." & VbCrLf
If objModelsDict.exists(trim(strThisModel)) then ' if current model in objDict then huzzah
strHTAModelState=cPassed
StatusBar.InnerText=StatusBar.InnerText & vbTab & "Model detected: " & vbTab & strHTAModelState
Else
strHTAModelState=cFail
Err.Raise 9010,"fCheckModel",strThisModel & " found. The build will not work on this model of hardware"
Call ErrHandler(ucase(strHTAModelState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
end if
fCheckModel=strHTAModel
End Function
'=================================================================================
'=================================================================================
'3 - RAM
Function fCheckRAM(strRAM)
'Aim: Check installed RAM > x
'Return string digits with units, e.g. 4GB
'use strHTARAM for value
'==================================================================
' Memory Preflight Check (from MDT2012)
'==================================================================
On Error Resume Next
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking RAM..."
If Err.Number <> 0 Then
Call ErrHandler("Error occurred while calculating computer's memory.",2)
End If
fCheckRAM = Int(strRAM/1024) & "GB" 'format in GB
If Int(strRAM) > cMinimumMemoryMB Then
strHTARAMState=cPassed 'Sufficient memory - show whole number in GB"
StatusBar.InnerText=StatusBar.InnerText & vbTab & "RAM installed: " & vbTab & strHTARAMState
Else
strHTARAMState=cFail
Err.Raise 9030 ,"fCheckRAM","Not enough memory in this machine!" & " Required physical memory is: " & cMinimumMemoryMB & " MB."
Call ErrHandler(ucase(strHTARAMState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1) 'abort build
End If
End Function
'=================================================================================
'=================================================================================
'4 - NTFS disk
Function fCheckNTFS(strDiskFS)
'Aim: Check HDD is NTFS
'Return string
On Error Resume Next
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking file system is not RAW..."
If Instr(1,strDiskFS,cMinFS,VBTextCompare)<>0 Then
fCheckNTFS=cMinFS 'disk format is OK (NTFS)
StatusBar.InnerText=StatusBar.InnerText & vbTab & " File system: " & cPassed
Else
fCheckNTFS=cFail
Err.Raise 9040 ,"fCheckNTFS","WARNING: Disk not correct file-system. Type required is: " & cMinFS & "." & VbCrLf & _
"The deployment will fail unless you reformat the target disk immediately."
Call ErrHandler(Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",2) 'halt build
End If
End Function
'====================================================
'=================================================================================
'5 - CPU checks
'=================================================================================
Function fCheckCPUSpeed(strCPU) 'any HW
'Aim: Check CPU speed
'Return string = number + appropriate units, e.g. 5HGz (strCPU)
On Error Resume Next
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking CPU spec..."
Select Case Right(strCPU,3) 'check units
Case "MHz"
strCPU=Left(strCPU,4)/1000 'reformat to GHz
Case "GHz"
strCPU=strCPU 'unit already OK
Case Else
Call ErrHandler("CPU units are unknown",2)
End Select
'Check clock speed
If Int(Left(trim(strCPU),1))>=iMinCPUSpeed Then
fCheckCPUSpeed=strHTACPUSpeed 'CPU is fine i.e don't change value
StatusBar.InnerText=StatusBar.InnerText & vbTab & "CPU Speed: " & cPassed
Else
fCheckCPUSpeed=cFail 'already in GHz
Err.Raise 9050,"fCheckCPUSpeed","CPU speed pre-requisite failed. Minimum processor clock speed is: " & iMinCPUSpeed
Call ErrHandler(Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1) 'halt build
End If
End Function
'=================================================================================
'=================================================================================
Function fCheckCPUArch(strCPUArch) 'any HW
'Aim: Check CPU width
'Return string
On Error Resume Next
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking CPU bus width..."
'Check clock speed
If Int(Left(trim(strCPUArch),2))>=iMinCPUArch Then
fCheckCPUArch=strHTAArchitecture 'CPU is fine i.e don't change value
StatusBar.InnerText=StatusBar.InnerText & vbTab & "CPU width: " & cPassed
Else
fCheckCPUArch=cFail 'already in GHz
Err.Raise 9052,"fCheckCPUArch","CPU width pre-requisite failed. Minimum processor width required is: " & iMinCPUArch
Call ErrHandler(Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1) 'abort build
End If
End Function
'=================================================================================
Function fCheckCores(iCores)
'Aim: Check hardware (CPU) has a minimum number of cores
'Return Integer
On Error Resume Next
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking CPU cores..."
If iCores>=iMinCores Then
fCheckCores=iCores
StatusBar.InnerText=StatusBar.InnerText & vbTab & "Core count: " & vbTab & cPassed
'StatusBar.InnerText=StatusBar.InnerText & vbTab & "CPU cores: " & cPassed
Else
fCheckCores=cFail
Err.Raise 9051,"fCheckCores","WARNING: Not enough cores on the CPU to support the build. Minimum CPU cores is: " & iMinCores
Call ErrHandler(Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",2) 'halt build
End If
End Function
'=================================================================================
'=================================================================================
Function fCheckHPCPUSpeed 'HP ONLY
'Aim: Check CPU speed
'return: string
'Check CPU speed
On Error Resume Next
strWQLCPU = "processor speed"
strTemp=QueryHPBIOS(strWQLCPU,"")
Select Case Right(strTemp,3)
Case "MHz"
strTemp=Left(strTemp,4)/1000 'reformat to GHz
Case "GHz"
strTemp 'is OK
Case Else
Call ErrHandler("CPU is unknown",2)
End Select
'Check clock speed
If strTemp>=iMinCPUSpeed Then
fCheckCPUSpeed= strTemp & "GHz"
Else
Err.Raise 9050,,"CPU speed pre-requisite failed"
Call ErrHandler("CPU is too slow",1)
fCheckCPUSpeed=cFail 'already in GHz
End If
End Function
'=================================================================================
'=================================================================================
Function fGetModels
'Aim: Read external text file
'return: dictionary object - models as key, integer as value e.g. Dell Optiplex,12
'On Error Resume Next
Dim objFSO
Dim objFile
Dim strFile
Dim strEntry
Dim n
Dim strfilepath
Dim iLineCount 'count lines to avoid listing first item with ,.
Set objModelsDict = CreateObject("Scripting.Dictionary")
set objFSO=CreateObject("Scripting.FileSystemObject")
Const ForReading=1
strfilepath = Left(window.location.pathname,InStrRev(window.location.pathname,"\"))
strFile=strfilepath & "Models.txt"
set objFile=objFSO.OpenTextFile(strFile,ForReading)
iLineCount=0
'read in each line of data until you reach the end of the file
do While objFile.AtEndOfStream<>True
strEntry=objFile.ReadLine
'you can now do what ever you want with the line as referenced with the strEntry variable such as
'echoing it back (e.g. wscript.Echo strEntry) or passing it as a variable to a function of subroutine (e.g. MyFunction strEntry)
objModelsDict.comparemode=VBTextCompare
objModelsDict.Add strEntry,iLineCount
iLineCount=iLineCount+1
If blnDebug then
If iLineCount=1 Then
StatusBar.InnerText=trim(strEntry)
Else
StatusBar.InnerText=StatusBar.InnerText & ", " & trim(strEntry) 'list models
End If
End If
Loop
objFile.Close
End Function
'=================================================================================
'=================================================================================
'====================================================
Function ErrHandler(strErrorMsg,iErrMode)
'Aim: to handle error states
' 1 = Abort
' 2 = Warn
'Return 'Appropriate text message explaining the error
'====================================================
Const msgTitle="SCCM Deployment Preflight Checklist"
'On Error Resume Next '< don't use that as we want to KEEP the error properties
'Abort=1
If iErrMode=1 Then
StatusBar.InnerText=strErrorMsg 'overwrite status with Error message
' StatusBar.InnerText=StatusBar.InnerText & VbCrLf & " " & strHTAOutlook & " " & strHTAVendor & " " & strHTAVendorState & _
' VbCrLf & " " & strHTAModel & strHTAModelState & _
' VbCrLf & " " & strHTARAM & strHTARAMState & _
' VbCrLf & " " & strHTAHDD & strHTAHDDState
iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript") 'Abort (close) after n seconds
'MsgBox strErrorMsg,vbExclamation,msgTitle
'ErrBar.class=""
ElseIf iErrMode=2 Then
'Warning
StatusBar.InnerText=StatusBar.InnerText & VbCrLf & strErrorMsg & " " '& "(" & Err.Description & " :" & Err.Number & ")"',vbExclamation,msgTitle
Err.Clear
End If
End Function
'====================================================
Sub Abort
'Aim: Quit gracefully
window.close()
End Sub
</script>
<!-- #region BODY -->
<body>
<br />
<div>
<span style="version"> <span id="VersionSpan"></span></div>
<div style="text-align: center;">
<H1 style="font-family: Arial, Helvetica, sans-serif; font-size: large; text-align: center; color: #000000; text-transform: capitalize">System information</H1>
<span>
<table border="1" cellspacing="0" cellpadding="0" style="width: 912px"
id="SysInfoTable">
<tr class="h1">
<td align="right" class="Header1" style="width: 76px; height: 18px">
</td>
<td align="right" class="Header1" style="height: 18px"><em id="VendorCaption">Vendor</em></td>
<td align="left" class="style2" style="height: 18px"><span id="Vendor"></span></td>
<td align="right" class="Header2" style="height: 18px"><em id="ModelCaption">Model</em></td>
<td align="center" class="style4" style="width: 400px; height: 18px"><span id="Model"></span></td>
</tr>
<tr>
<td align="right" class="Header1" style="width: 76px">
</td>
<td align="right" class="Header1"><em id="ProductCaption">Product ID</em></td>
<td align="left" class="style2"><span id="Product"></span></td>
<td align="right" class="Header2"><em id="RAMCaption">Memory(in MB)</em></td>
<td align="left" class="style4" style="width: 400px"><span id="RAM"></span></td>
</tr>`
<tr>
<td align="right" class="Header1" style="width: 76px">
</td>
<td align="right" class="Header1"><em id="CPUCaption">CPU speed (in GHz)</em></td>
<td align="left" class="style2"><span id="CPUspeed"></span></td>
<td align="right" class="Header2"><em id="CPUInfoCaption">No: CPU\Cores</em></td>
<td align="left" class="style4" style="width: 400px"><span id="CPUInfo"></span></td>
</tr>
<tr>
<td align="right" class="Header1" style="width: 76px">
</td>
<td align="right" class="Header1"><em id="DiskFSCaption">Filesystem info</em></td>
<td align="left" class="style2"><span id="HDDFS"></span></td>
<td align="right" class="Header2"><em id="CapableArchCaption">Architecture</em></td>
<td align="left" class="style4" style="width: 400px"><span id="CapableArchitecture"></span></td>
</tr>
<tr>
<td align="right" class="Header1" style="width: 76px">
</td>
<td align="right" class="Header1"><em id="BIOSVerCaption">BIOS version</em></td>
<td align="left" class="style2" ><span id="BIOSVERSION"></span></td>
<td align="right" class="Header2"><em id="BIOSDateCaption">BIOS Date</em></td>
<td align="left" class="style4" style="width: 400px"><span id="BIOSDate"></span></td>
</tr>
</table>
</span>
</div>
<div class="StatusBar">
<br />
<Span id="StatusBar">Loading...please wait.</Span>
</div> <br><br>
<div align="center">
<input type="button" name="btnStop" id="btnStop" value="Continue" onclick="Abort">
<input type="Button" value="Re-Scan Machine" name="button1" onClick="Window_Onload" class="button">
</div>
</body><!-- #endregion -->
</html> -
For the past few weeks I have been struggling with launching response groups and I am hoping someone might be able to help.
Little background on my config –
2 – Frontend 2013 servers (5.0.8308.556)
Sonus SBC1000 voice gateway, 1 PRI
Stuff that works – Direct calling inbound to end users works great!
So here is my problem. I set up a response group with a direct dial number to the outside and assign my people to the group and everything is good.
For about 15mins response groups work great! After about 15mins response groups stop working and calls to response groups are no longer picked up. This also affects chat with response groups.
When I turn on the logging software inside Lync I get these messages when the calls are dropped;
TL_INFO(TF_COMPONENT) [1]3784.356C::04/14/2014-14:24:54.627.018e2f49 (RgsCommonLibrary,RgsLogMessage.ReportMessage:2111.idx(227))
_rgs_message_begin_
Direction: Incoming
From: tel:+15555555555
To: sip:[email protected]
Message: CALLCONTROL: Call declined because CallControl is not started
WorkflowId: 08d328a20de8419caad0dee898586051
TL_ERROR(TF_COMPONENT) [1]3784.356C::04/14/2014-14:24:54.627.018e2f4a (RgsHostingFramework,CallControlManager.HandleAudioVideoCall:2049.idx(619))
(0000000000C9D21E)Call is declined because Call Control is not started.
I then simply restart response groups on one of the FE servers and they come back (for a short time) -
Here some interesting events logged in the Lync Server event logs after Response Group Service is restarted –
LS Response Group Service – 31028 - A WorkflowRuntime cannot be started.
Lync Server 2013, Response Group Service Match Making could not find the Contact object used for subscribing to agents' presence. Cause: The application has not been properly activated or the Contact object was deleted. Resolution: Deactivate and then activate
the application for this pool.
I am willing to try just about anything to get this to work. Any ideas out there? Thanks for all your help!Please check if the application server is active(lync control panel--Topology--status--double click your FE SERVER--applicationserver).
If the application server is not started, please start it. If it is started, restart it.
If issue still exist, use following steps:
use following command Get-CsApplicationEndpoint
And check for messages in "Yellow"
Locate the Identity in Active Directory using ADSIEdit
And Delete the "CN" located at the end of the Identity String
And try and add your Line URI or Response Group SIP Address.
Also you can refer below link
http://social.technet.microsoft.com/Forums/lync/en-US/cd25ddec-6e1e-4d58-9a9a-a530abfa82e3/response-groups-not-working
Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer"
Mai Ali | My blog: Technical -
non-responsive canon pixma mg3510 wireless print copy scan , costa rica
1, I take printer out of the box
2, I install power cable. [photo paper light comes on]
3, I install paper per instructions
4, I push power switch [ green power light comes on, stays on, never blinking ]
5, All buttons are non-responsive, including STOP, even when held down 15 seconds.Tanner,
Your Lombard can run a maximum of 512MB of RAM (2x256MB). The memory module for the top slot is standard height which is approximately 2.0"; the module for the lower (bottom) slot is low-profile, meaning 1.5" or less. The standard height module will only work in the top slot; the low-profile will work in either slot. Also, these 256MB modules are unique to the early iMac, Wallstreet, and Lombard; generic 256s will not work properly.
Generally, when a powerbook's sleep light comes on when either a charged main battery and/or a power adapter is connected, and a power manager reset does not resolve the issue, you have some other hardware problem. Since the 'book is not even turned on, bad RAM would not cause this. If memory were bad, you may or may not get the startup chime, but then you would receive a dialog box on the lit display of a problem with RAM or cache memory in 9.x; OSX does not have this dialog box but nonetheless the POST (power on self-test) still runs.
When you get a power adapter, I would try this:
-remove all power;
-remove the optical drive;
-lift off the keyboard and very carefully disconnect the keyboard ribbon cable;
-disconnect the rechargeable backup battery (PRAM battery);
-lift out the microprocessor card, remove both memory modules;
-disconnect the HD ribbon cable from the logic board;
-reinstall the microprocessor card without any memory;
-connect just the power adapter, then press the power button; if no response, press the reset button on the back panel, then try the power button.
In the above, you have stripped down the powerbook to its bare essentials for a power test. If you have no hardware problem, you should have no light steady sleep light and when the power button is pressed, you should hear 1-beep...no RAM detected.
http://docs.info.apple.com/article.html?artnum=58183
If the above produces no positive results, then you have a failed component somewhere. -
Normal, then slow response to remote control
I just had FiOS TV installed less than one week ago (on 1/15/10) and have noticed the following annoying behavior: After powering-up my TV and Set Top Box (STB), the remote control responds normally. I am able to change channels using direct numeric entry or the Channel up/down buttons. Also, the volume control responds normally. However, once I enter the program guide, or VOD, or select the DVR, response to commands from the remote works fine for a while, then the response completely stops, similar to when a PC stops responding to mouse or keyboard commands. It seems like the STB's on-board microprocessor or RAM are suddenly max'd out. If I let it sit there for a long time (e.g., about 10 minutes), response to the remote control is back to normal. Alternately, if I power the TV and STB off and on again, responsiveness to the remote control is normal (until I again try to use the Guide, VOD, or DVR). I have put fresh batteries in the remote, but the problem remains the same. Any ideas on how to fix this? Thanks.
Please call 1-888-553-1555. The tech will have to send some commands to the stb to refresh it. Please mention exactly the things you typed here.
Maybe you are looking for
-
I recently got the 2.3.4 update on my Incredible. Now whenever I'm on a call with my bluetooth headset, the headset will disconnect if I receive a text message while talking on the phone. This never happened before the update. Can someone else conf
-
Web Service call from adobe form
Hello, I developed the form in SFP, I created a webservice and tested the web service with a third party tool, this works fine. I added a new dataconnection and imported the wsdl file. I linked the request parameter to a from field and the returns pa
-
Hi all, how can I add documents which are linked to a business transaction (archivelink) to an automatically generated e-mail? In transactions one can add all sorts of documents in the documents tab. In certain cases, when saving the transaction an e
-
Images not turning out as they look in PS
Lately I have been having some issues with my processed images. They look good in PS, and in Windows Image Viewer as well as on Facebook (which is odd because FB generally compresses them bad), but when loaded into a phone, tablet, or uploaded into
-
How can I JavaBean with Oracle Forms 10g. I attempting to use graphics (Aircraft Image created using SVG) interactively with Oracle forms. Any sample code to lead me in the right direction would be helpful.