Procedure for Calling C++ Decode Methods
NOTE: As of version 1.1, C++ exceptions are no longer used. Therefore, any application programs that used only try/catch blocks to detect errors will not work properly. The return status code from the decode method is the only mechanism used to report error conditions.
2. Create an instance of an input stream or message buffer object from which the XML message to be decoded will be read.
3. Create an instance of the generated global element control class to link the generated type class instance with the message buffer or input stream instance.
5. If decoding was successful (indicated by return status equal to zero), the decoded data will now be available for use in the generated type variable. The generated print method can be called at this time to examine the contents of the data structure.
6. If decoding failed, the message buffer or stream printErrorInfo method can be invoked to print the reason for failure.
#include "employee.h" #include "rtxmlsrc/rtXmlCppMsgBuf.h" int main (int argc, char** argv) { int i, stat; const char* filename = "message.xml"; OSBOOL trace = TRUE, verbose = FALSE; // Step 1: create instance of class into which message will be decoded PersonnelRecord value; // Step 2: create an input stream from which the message will be read OSFileInputStream in (filename); OSXMLDecodeBuffer decodeBuffer (in); // Step 3: create a control class instance to tie the data object // and input stream object together. personnelRecord_CC personnelRecord (decodeBuffer, value); if (verbose) rtxSetDiag (personnelRecord.getCtxtPtr(), 1); // Step 4: Decode stat = personnelRecord.decode(); if (0 == stat) { if (trace) { printf ("decoded XML message:\n"); personnelRecord.print ("personnelRecord"); printf ("\n"); } } else { printf ("Decoding failed\n"); decodeBuffer.printErrorInfo(); } return stat; }The calling procedure on WSDL input operation decode method is the same as that on XSD glabal element deocde method. When calling a C++ XML decode method for WSDL operation output, the user must initialize a fault variable. This is a variable of type Oper_Fault, where Oper is the operation name.
Add_Output value; Add_Fault fault; ... Add_Output_CC pdu (decodeBuffer, value, fault); decodeBuffer.setDiag (verbose); // Decode in.reset (); decodeBuffer.resetErrorInfo (); stat = pdu.decodeFrom(decodeBuffer); if (0 == stat) { if (trace) { printf ("decoded XML message:\n"); pdu.print ("Add_Output"); printf ("\n"); } } else if (RTERR_SOAPFAULT == stat) { if (trace) { printf ("decoded XML message:\n"); fault.print ("Add_Fault"); printf ("\n"); } } else { printf ("Decoding failed\n"); decodeBuffer.printErrorInfo(); return stat; }
Copyright © Objective Systems 2002-2008 This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included. |
Objective Systems, Inc.55 Dowlin Forge RoadExton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |