Purpose | The xservice statement is used to invoke a Superx++ service or to send a Superx++ object to a remote server as a courier messenger. Please note that if there is no URL specified then this is a Superx++ service call on the same machine as the client. For more details on Superx++ services you should read the Superx++ Services Specification. | |||||||||||||||
Format |
xservice({xml/text}) {service name}.{service method name}({parm name} = {parm value}, ...);
xservice({xml/text}, {listener URL}) {service name}.{service method name}({parm name} = {parm value}, ...);
xservice({xml/text}, {listener URL}, {object name});
{xml/text} |
xml means package the result in XML, text means package the result as is without the XML wrapper. |
{listener URL} |
the URL of the Superx++ service listener, i.e. the URL to the remote server's XppExt.dll |
{object name} |
the name of the Superx++ object to be sent to the remote server as a courier messenger |
{service name} |
the name of the Superx++ service whose method is to be invoked |
{service method name} |
the name of the Superx++ service method to be invoked |
{parm name} |
the name of the parameter being passed to the Superx++ service method |
{parm value} |
the value of the parameter being passed to the Superx++ service method |
|
|
Example #1 |
string sRet; int i; for (i = 0; i < 10; i = i + 1) { sRet = sRet + xservice("text", "http://RemoteServer/SomeDir/XppExt.dll") Calculator.Mult(Parm1 = i, Parm2 = 20) + ", "; } xout(sRet); In the code above the Mult method of the Calculator Superx++ service on the remote server is invoked. The result is written as text into sRet. This occurs in the loop 10 times and sRet is written to the output stream. |
|||||||||||||||
Example #2 |
class XPlant { construct { public: protected: } public: string Execute() { /* this Execute() method gets executed on the remote server by the Superx++ framework */ string sRet = xservice("xml") Calculator.Mult(Parm1 = 40, Parm2 = 20); string sVal; int i; for (i = 0; i < 10; i = i + 1) { sVal = xservice("xml") Calculator.Mult(Parm1 = i, Parm2 = 10); sRet = sRet + sVal + ", "; } return sRet; }; } /* The MyTree object is an object based on two different classes */ node(XPlant) MyTree; xout( xservice("xml", "http://localhost/XppExt_Release/XppExt.dll", "MyTree"); ); The code above creates the XPlant class which contains the Execute() method. Execute() is invoked automatically at the remote server by the Superx++ framework. So it is the main entry point for the courier messenger code to be executed at the remote server. Notice that there are Superx++ service calls within the Execute() method which are executed locally; that is to say, locally on the remote server. You can place whatever conditionals or loops you need to make the code more complex and able to handle errors/exceptions. The xservice statement that sends the MyTree object to the remote server is placed on the client within an xout statement. This means that whatever result(s) are passed back from the Execute() method will be sent to the client's output stream. |