MARX#82611 Is het mogelijk om bij verwerkingsfout een HTTP4xx code wordt teruggestuurd
svn path=/Website/trunk/; revision=64855
This commit is contained in:
@@ -41,7 +41,16 @@
|
||||
}
|
||||
|
||||
"Error 'Operation not Allowed' op de volgende regel betekent meestal dat de upload te groot is";
|
||||
var xmlResp = api_gen_import(API, Request.BinaryRead(bytes));
|
||||
var result = api_gen_import(API, Request.BinaryRead(bytes));
|
||||
xmlResp = result.xmldom;
|
||||
|
||||
if (API.apidata.errorhandling == 1)
|
||||
{
|
||||
if (result.anyError) // een 'E' in imp_log
|
||||
{
|
||||
Response.Status = '400 Bad Request';
|
||||
}
|
||||
}
|
||||
|
||||
Response.ContentType = "text/xml";
|
||||
if (API.apidata.stylesheet_out)
|
||||
@@ -52,5 +61,6 @@
|
||||
else
|
||||
Response.Write(xmlResp.xml);
|
||||
|
||||
|
||||
ASPPAGE_END();
|
||||
%>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
Context: Ook vanuit APPL\MARX\API_mareon_opdracht.asp
|
||||
*/
|
||||
|
||||
// result: { xmldom: object, anyError: boolean }
|
||||
function api_gen_import(API, data, charset) //
|
||||
{
|
||||
var fileStream = Server.CreateObject("ADODB.Stream");
|
||||
@@ -72,7 +73,7 @@ function api_gen_import(API, data, charset) //
|
||||
|
||||
if (import_key > 0)
|
||||
{
|
||||
var anyError = 0; // hoeveel errors?
|
||||
var errorCount = 0; // hoeveel errors?
|
||||
var elementDetails = xmlResp.createElement("details");
|
||||
var sql = "SELECT imp_log_status,"
|
||||
+ " imp_log_omschrijving,"
|
||||
@@ -106,7 +107,7 @@ function api_gen_import(API, data, charset) //
|
||||
if (oRs("imp_log_status").Value != null )
|
||||
{
|
||||
if (oRs("imp_log_status").Value == 'E' || oRs("imp_log_status").Value == 'F')
|
||||
anyError ++
|
||||
errorCount ++
|
||||
var elementStatus = xmlResp.createElement("status");
|
||||
var elementStatusText = xmlResp.createTextNode(oRs("imp_log_status").Value);
|
||||
elementStatus.appendChild(elementStatusText);
|
||||
@@ -143,6 +144,6 @@ function api_gen_import(API, data, charset) //
|
||||
}
|
||||
|
||||
xmlResp.appendChild(FCLTElement);
|
||||
return xmlResp;
|
||||
return { xmldom: xmlResp, anyError: errorCount > 0 };
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/iface.inc" -->
|
||||
<!-- #include file="../Shared/rapportselector.inc" -->
|
||||
<!-- #include file="../Shared/selector.inc" -->
|
||||
<!-- #include file="fac.inc" -->
|
||||
<%
|
||||
FCLTHeader.Requires({ plugins:["jQuery"] })
|
||||
@@ -25,10 +26,10 @@ var api_omschrijving;
|
||||
var api_apikey;
|
||||
var api_filepath;
|
||||
var api_loglevel;
|
||||
var api_errorhandling;
|
||||
var usrrap_key;
|
||||
var api_viewmapping_json;
|
||||
var api_stylesheet;
|
||||
var import_app_key;
|
||||
var api_options_json;
|
||||
var api_xmlnode;
|
||||
|
||||
@@ -56,14 +57,18 @@ if (api_key > 0)
|
||||
var api_omschrijving = oRs("fac_api_omschrijving").Value;
|
||||
var api_filepath = oRs("fac_api_filepath").Value;
|
||||
var api_loglevel = oRs("fac_api_loglevel").Value;
|
||||
var api_errorhandling = oRs("fac_api_errorhandling").Value;
|
||||
var usrrap_key = oRs("fac_usrrap_key").Value;
|
||||
var api_viewmapping_json = prettyJson(oRs("fac_api_viewmapping_json").Value);
|
||||
var api_stylesheet = oRs("fac_api_stylesheet").Value;
|
||||
var api_stylesheet_out = oRs("fac_api_stylesheet_out").Value;
|
||||
var import_app_key = oRs("fac_import_app_key").Value;
|
||||
var api_options_json = prettyJson(oRs("fac_api_options_json").Value);
|
||||
oRs.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
var api_errorhandling = 1; // default 400 on error
|
||||
}
|
||||
%>
|
||||
|
||||
<html>
|
||||
@@ -119,6 +124,12 @@ if (api_key > 0)
|
||||
RWFIELDTR("fac_api_omschrijving", "fld", L("lcl_fac_api_omschrijving"), api_omschrijving, {maxlength: 60});
|
||||
RWFIELDTR("fac_api_filepath", "fld required", L("lcl_fac_api_filepath") , api_filepath, {maxlength: 64});
|
||||
RWFIELDTR("fac_api_loglevel", "fld", L("lcl_fac_api_loglevel") , api_loglevel);
|
||||
var sql = " SELECT 0, " + safe.qL("lcl_fac_api_errorhandling0") + " FROM DUAL"
|
||||
+ " UNION ALL SELECT 1, " + safe.qL("lcl_fac_api_errorhandling1") + " FROM DUAL";
|
||||
FCLTselector("fac_api_errorhandling", sql,
|
||||
{ initKey: api_errorhandling,
|
||||
label: L("lcl_fac_api_errorhandling")
|
||||
});
|
||||
FCLTrapportselector("fac_usrrap_key"
|
||||
,"sgRapport"
|
||||
,{ label: L("lcl_fac_api_usrrap")
|
||||
@@ -128,7 +139,6 @@ if (api_key > 0)
|
||||
RWTEXTAREATR("fac_api_viewmapping_json", "fldtxt", L("lcl_fac_api_viewmapping") , api_viewmapping_json, {maxlength: 4000, no_bb_codes: true});
|
||||
RWFIELDTR("fac_api_stylesheet", "fld", L("lcl_fac_api_stylesheet") , api_stylesheet, {maxlength: 64});
|
||||
RWFIELDTR("fac_api_stylesheet_out", "fld", L("lcl_fac_api_stylesheet_out"), api_stylesheet_out, {maxlength: 64});
|
||||
RWFIELDTR("fac_import_app_key", "fld", L("lcl_fac_import_app") , import_app_key);
|
||||
RWTEXTAREATR("fac_api_options_json", "fldtxt", L("lcl_fac_api_options") , api_options_json, {maxlength: 4000, no_bb_codes: true});
|
||||
BLOCK_END();
|
||||
IFACE.FORM_END();
|
||||
|
||||
@@ -53,11 +53,11 @@ if (viewjson)
|
||||
var fields = [ { dbs: "fac_api_name", typ: "varchar", frm: "fac_api_name" },
|
||||
{ dbs: "fac_api_filepath", typ: "varchar", frm: "fac_api_filepath" },
|
||||
{ dbs: "fac_api_loglevel", typ: "number", frm: "fac_api_loglevel" },
|
||||
{ dbs: "fac_api_errorhandling", typ: "number", frm: "fac_api_errorhandling" },
|
||||
{ dbs: "fac_usrrap_key", typ: "key", frm: "fac_usrrap_key" },
|
||||
{ dbs: "fac_api_viewmapping_json", typ: "varchar", val: viewjson, len: 4000},
|
||||
{ dbs: "fac_api_stylesheet", typ: "varchar", frm: "fac_api_stylesheet"},
|
||||
{ dbs: "fac_api_stylesheet_out", typ: "varchar", frm: "fac_api_stylesheet_out"},
|
||||
{ dbs: "fac_import_app_key", typ: "key", frm: "fac_import_app_key"},
|
||||
{ dbs: "fac_api_options_json", typ: "varchar", val: viewoptions, len: 4000},
|
||||
{ dbs: "fac_api_omschrijving", typ: "varchar", frm: "fac_api_omschrijving", len: 60}];
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/iface.inc" -->
|
||||
<!-- #include file="../Shared/rapportselector.inc" -->
|
||||
<!-- #include file="../Shared/selector.inc" -->
|
||||
<!-- #include file="fac.inc" -->
|
||||
<%
|
||||
FCLTHeader.Requires({ plugins:["jQuery"] })
|
||||
@@ -92,9 +93,17 @@ if (oRs.Eof)
|
||||
BLOCK_START("apiSample", L("lcl_fac_api"), { "icon": "fa-network-wired" });
|
||||
ROFIELDTR("fld", L("lcl_key") , oRs("fac_api_key").Value);
|
||||
ROFIELDTR("fld", L("lcl_fac_api_name") , oRs("fac_api_name").Value);
|
||||
ROFIELDTR("fld", L("lcl_fac_api_omschrijving"), oRs("fac_api_omschrijving").value);
|
||||
ROFIELDTR("fld", L("lcl_fac_api_omschrijving") , oRs("fac_api_omschrijving").value);
|
||||
ROFIELDTR("fld", L("lcl_fac_api_filepath") , oRs("fac_api_filepath").Value);
|
||||
ROFIELDTR("fld", L("lcl_fac_api_loglevel") , oRs("fac_api_loglevel").Value);
|
||||
var sql = " SELECT 0, " + safe.qL("lcl_fac_api_errorhandling0") + " FROM DUAL"
|
||||
+ " UNION ALL SELECT 1, " + safe.qL("lcl_fac_api_errorhandling1") + " FROM DUAL";
|
||||
FCLTselector("fac_api_errorhandling", sql,
|
||||
{ initKey: oRs("fac_api_errorhandling").Value,
|
||||
label: L("lcl_fac_api_errorhandling"),
|
||||
readonly: true
|
||||
});
|
||||
|
||||
FCLTrapportselector("fac_usrrap_key"
|
||||
,"sgRapport"
|
||||
,{ label: L("lcl_fac_api_usrrap")
|
||||
@@ -104,21 +113,8 @@ if (oRs.Eof)
|
||||
ROTEXTAREATR("fldtxt", L("lcl_fac_api_viewmapping") , prettyJson(oRs("fac_api_viewmapping_json").Value));
|
||||
ROFIELDTR("fld", L("lcl_fac_api_stylesheet") , oRs("fac_api_stylesheet").Value);
|
||||
ROFIELDTR("fld", L("lcl_fac_api_stylesheet_out") , oRs("fac_api_stylesheet_out").Value);
|
||||
ROFIELDTR("fld", L("lcl_fac_import_app") , oRs("fac_import_app_key").Value);
|
||||
ROTEXTAREATR("fldtxt", L("lcl_fac_api_options") , prettyJson(oRs("fac_api_options_json").Value));
|
||||
BLOCK_END();
|
||||
if (0) // We weten niet welke user te gebruiken?
|
||||
{
|
||||
BLOCK_START("apiSample", L("lcl_fac_api")+" "+L("lcl_fac_api_sample"), { "icon": "fa-eye" });
|
||||
var proto = (Request.ServerVariables("SERVER_PORT") == "443")? "https" : "http";
|
||||
var sitenoroot = proto + "://" + Request.ServerVariables("SERVER_NAME");
|
||||
var site = sitenoroot + rooturl;
|
||||
var deep = site + "/?API="+oRs("fac_api_name").Value+"&APIKEY="+oRs("fac_api_apikey").Value;
|
||||
ROFIELDTR("fldtxt",L("lcl_fac_api_sample"), deep);
|
||||
var deep = site + "/?fac_id="+customerId+"&API="+oRs("fac_api_name").Value+"&APIKEY="+oRs("fac_api_apikey").Value;
|
||||
ROFIELDTR("fldtxt",L("lcl_fac_api_of"), deep);
|
||||
BLOCK_END();
|
||||
}
|
||||
|
||||
SUBFRAME_END();
|
||||
%>
|
||||
|
||||
@@ -368,8 +368,16 @@ if (v_API)
|
||||
|
||||
var API_imp = new API_func(v_API);
|
||||
// utf-8 moet als parameter mee, b.v. een €-teken in een omschrijving van de XML zorgt ervoor dat de XML ongeldig wordt...
|
||||
var result = api_gen_import(API_imp, xmlReq.xml, "utf-8");
|
||||
var resultdata = api_gen_import(API_imp, xmlReq.xml, "utf-8");
|
||||
var result = resultdata.xmldom;
|
||||
|
||||
if (API.apidata.errorhandling == 1)
|
||||
{
|
||||
if (result.anyError) // een 'E' in imp_log
|
||||
{
|
||||
Response.Status = '400 Bad Request';
|
||||
}
|
||||
}
|
||||
|
||||
__Log("result:" + result.xml);
|
||||
if (result)
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
var bytes = Request.TotalBytes;
|
||||
if (bytes == 0)
|
||||
{
|
||||
__DoLog("api_gen_import empty body posted", "#ffff00");
|
||||
__DoLog("api_bct_factuur_import empty body posted", "#ffff00");
|
||||
Response.Write("Error: no data posted for API import");
|
||||
Response.End; // Grof maar anders AiAi, dat is nog erger
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user