Axxia Systems Ltd
· This is only available in “open-script” non-compiled asp.net websites.
· The class libraries must have been pre-compile-tested before a hot-swap attempt is made.
· “Open-script” websites should only be used for internal data exchanges in order to mitigate the risk of non-authorised sources injecting their own assemblies into your solution.
1.) ProcessImmediate: attempts to process a data request sent on the current URL querystring.
2.) ProcessBufferedRequest: attempts to process an accumulated data request that has been sent on consecutive URL querystrings since the last reset or successful processing.
Method: AddDataToChannel |
[WebMethod(EnableSession = true)] [ScriptMethod(UseHttpGet = true)] publicstring AddDataToChannel(string data) { string result, status, message; result = ""; status = "OK"; message = "Data appended to channel"; result += "<brokerResponse>"; try { Session["data"] += data; } catch (Exception ex) { status = "Error"; message = ex.Message; goto FinishAddDataToChannel; } FinishAddDataToChannel: result += "<brokerStatus>" + status + "</brokerStatus>"; result += "<brokerMessage>" + message + "</brokerMessage>"; result += "</brokerResponse>"; return result; } |
Configuration: web.config |
<netTcpBinding> <bindingname="NetTcpBinding_LNPS_DynamicScriptClass"closeTimeout="00:01:00"openTimeout="00:01:00"receiveTimeout="00:10:00"sendTimeout="00:01:00"transactionFlow="false"transferMode="Buffered"transactionProtocol="OleTransactions"hostNameComparisonMode="StrongWildcard"listenBacklog="10"maxBufferPoolSize="2147483647"maxBufferSize="2147483647"maxConnections="10"maxReceivedMessageSize="2147483647"> <readerQuotasmaxDepth="32"maxStringContentLength="2147483647"maxArrayLength="16384"maxBytesPerRead="4096"maxNameTableCharCount="16384"/> <reliableSessionordered="true"inactivityTimeout="00:10:00"enabled="false"/> <securitymode="Transport"> <transportclientCredentialType="Windows"protectionLevel="EncryptAndSign"/> <messageclientCredentialType="Windows"/> </security> </binding> </netTcpBinding> |
Configuration: web.config |
<webServices> <protocols> <addname="HttpGet"/> <addname="HttpPost"/> </protocols> </webServices> |
// attempt to create requested service object try { classType = TypeDelegator.GetType(serviceClassValue); serviceClass = Activator.CreateInstance(classType); } catch (Exception ex) { status = "Error"; message = "Unable to create class [" + serviceClassValue + "] - " + ex.Message; goto FinishProcessRequest; } |
// attempt to invoke requested method try { paramValue = newobject[1]; paramValue[0] = data; Session["status"] = "OK"; Session["message"] = ""; invocationMethodResult = classType.InvokeMember(invocationMethodValue, BindingFlags.InvokeMethod, null, serviceClass, paramValue); status = (string)Session["status"]; if (status == "OK") { message += (message == "" ? "" : " - ") + "Invocation method executed OK"; } else { message = (string)Session["message"]; goto FinishProcessRequest; } } catch (Exception ex) { status = "Error"; message = "Unable to invoke [" + invocationMethodValue + "] - " + ex.Message; goto FinishProcessRequest; } |
· Invocations to conventional .net methods will fail if the required number of parameters (and the correct data types) for method parameters are not applied.
Class: DynamicsClass |
publicstring ExecuteScript(string data) { // Aif Service Client LNPS_DynamicScriptClassClient client = newLNPS_DynamicScriptClassClient(); // Create an instance of the CallContext class. CallContext context = newCallContext(); // attempt remote execution try { data = "str dynamicScript() { \n" + data + " \n}"; string result = client.runScript(context, data); try { if (result.Substring(0, 5) == "Error") { HttpContext.Current.Session["status"] = "Error"; HttpContext.Current.Session["message"] = result; } } catch { } return result; } catch (Exception ex) { return (ex.Message + ": " + ex.StackTrace); } } |
1.) The Requester sends the Generic Broker a HTTP request (or many requests) with URL parameters. The data for all these requests are accumulated by a Session object.
2.) Part of the URL parameters tells the Generic Broker which class to create and which method to invoke. Another section of the parameters contains the actual X++ script that will be executed on the AOS.
3.) The AOS receives the script and attempts dynamic compilation and execution. If successful, the results are passed back through the channel.
4.) The Generic Broker fields the response and sends it back to the Requester and audits the communication in a separate database.