XML Logging: Difference between revisions

357 bytes removed ,  23 February 2019
m
add syntax highlighting
m (add syntax highlighting)
m (add syntax highlighting)
Line 70: Line 70:
Finally you need to create a procedure that will utilise that client to ''reconstitute'' the XML from the data that your published method receives and call that procedure as the first thing each of your published methods do:
Finally you need to create a procedure that will utilise that client to ''reconstitute'' the XML from the data that your published method receives and call that procedure as the first thing each of your published methods do:


  Object oLogSample is a cWebService<br />
<source lang="dataflex">
  Object oLogSample is a cWebService
   Use cWSLogSample.pkg
   Use cWSLogSample.pkg
   Object oOwnService is a cWSLogSample
   Object oOwnService is a cWSLogSample
   End_Object  <span style="color:green;">// oOwnService</span><br />
   End_Object  // oOwnService
   <span style="color:green;">// LogMsg: The arguments are - 1 Data passed to the method
   // LogMsg: The arguments are - 1 Data passed to the method
   //                            2 Name of the method (literal)
   //                            2 Name of the method (literal)
   //                            3 Name of the variable (literal)
   //                            3 Name of the variable (literal)
   //                            4 Object handle for type - which will be named "oWS{typeName}"</span>
   //                            4 Object handle for type - which will be named "oWS{typeName}"
   <span style="color:midnightblue;">Procedure LogMsg Variant Data String sOp String sName Handle hoObj
   Procedure LogMsg Variant Data String sOp String sName Handle hoObj
       tSoapParameter Param
       tSoapParameter Param
       Handle  hoXML hoDoc
       Handle  hoXML hoDoc
       String  sXML
       String  sXML
       Boolean bOK<br />
       Boolean bOK
       Get Create of Desktop U_cXmlDomDocument to hoXML
       Get Create of Desktop U_cXmlDomDocument to hoXML
       Get CreateDocumentElementNS of hoXML (psServiceURI(Self)) sOp to hoDoc<br />
       Get CreateDocumentElementNS of hoXML (psServiceURI(Self)) sOp to hoDoc
       Get DefineStructParameter of oOwnService hoObj 1 1 sName (psServiceURI(Self)) to Param.SoapParamDef
       Get DefineStructParameter of oOwnService hoObj 1 1 sName (psServiceURI(Self)) to Param.SoapParamDef
       ValueTreeSerializeParameter Data to Param.ValueTree
       ValueTreeSerializeParameter Data to Param.ValueTree
       Get ValueTreeToXml of oOwnService Param.SoapParamDef Param.ValueTree hoDoc to bOK<br />
       Get ValueTreeToXml of oOwnService Param.SoapParamDef Param.ValueTree hoDoc to bOK
       Get psXML of hoXml to sXML
       Get psXML of hoXml to sXML
       Send Destroy of hoDoc
       Send Destroy of hoDoc
       Send Destroy of hoXML<br />
       Send Destroy of hoXML
       <span style="color:green;">// Now you can log sXML in some way...</span><br />
       // Now you can log sXML in some way...
   End_Procedure</span>  <span style="color:green;">// LogMsg</span><br />
   End_Procedureb // LogMsg
   { Published = True  }
   { Published = True  }
   { Description = "Interface for sending something to the system" }
   { Description = "Interface for sending something to the system" }
   Procedure  SendSomething tSomeDocumentType Doc
   Procedure  SendSomething tSomeDocumentType Doc
       <span style="color:midnightblue;">Send LogMsg Doc "SendSomething" "Doc" (oWStSomeDocumentType(oOwnService(Self)))</span><br />
       Send LogMsg Doc "SendSomething" "Doc" (oWStSomeDocumentType(oOwnService(Self)))
       <span style="color:green;">// Code that actually does stuff...</span><br />
       // Code that actually does stuff...
   End_Procedure  <span style="color:green;">// SendSomething</span><br />
   End_Procedure  // SendSomething
  End_Object  <span style="color:green;">// oLogSample</span><br />
  End_Object  // oLogSample
</source>


'''Warning:''' Note that each time you change your service, you should regenerate the web service client (as in [[#Step_2:_Create_a_Client | Step 2]]) immediately afterwards and then recompile your WebApp... <u>again</u>!
'''Warning:''' Note that each time you change your service, you should regenerate the web service client (as in [[#Step_2:_Create_a_Client | Step 2]]) immediately afterwards and then recompile your WebApp... <u>again</u>!