PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
New WINDEV, WEBDEV and WINDEV Mobile 26 feature!
  • How to retrieve the Webservice response?
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
AFTER
In french: AFTER
Runs a process only after a given procedure has been executed, and continues to execute the current code while waiting for this procedure to end. This type of statement is used to call a SOAP Webservice asynchronously.
Example
trackingSearch is trackSearch
trackingSearchRes is resultTrackSearch
trackingSearch.accountNumber = 99999999
trackingSearch.consigneesCountry = "FR"
trackingSearch.consigneesZipCode = "37100"
trackingSearch.sendersRef =  "111111"
 
AFTER trackingSearchRes = TrackingServiceWSService.trackSearch(trackingSearch) DO
IF ErrorOccurred() THEN
Trace("Failed to call the Webservice: " + ErrorInfo(errFullDetails))
ELSE
Trace("Webservice successfully run")
END
END
Syntax
AFTER <Result> = <SOAP Webservice call> DO
      <Code executed if response>
END
<Code executed after SOAP Webservice call>
<AFTER>:
Marks the beginning of the statement block.
<Result>:
Result of the execution of the SOAP Webservice.
<SOAP Webservice call>:
Call to the procedure used to query the SOAP Webservice.
<Code executed if response>:
Code executed only if the SOAP Webservice has been executed and has sent the response.
<Code executed after SOAP Webservice call>:
Code executed directly after the call to the SOAP Webservice (whether the SOAP Webservice sent a response or not).
<END>:
Marks the end of the statement block.
Remarks

How to retrieve the Webservice response?

The Webservice response can be retrieved in <Code executed if response>. Several syntaxes are available:
  • Declaration of the return value in the block AFTER ... DO:
    In this case, the Webservice returns a wsResponse variable. To be manipulated, this variable must be explicitly assigned in the variable used to retrieve the result of the Webservice.
    AFTER x = Websevice_Call() DO
    // here x is a wsResponse, it must be explicitly assigned
    // in a variable used to retrieve the result of the Webservice
    Res is TypeWS = x
    // code executed after the Webservice response
    // .... = Res
    END
    // code executed immediately
  • Declaration of the return value outside the block AFTER ... DO:
    In this case, the return variable can be manipulated directly.
    Res is TypeWS
    AFTER Res  = WebseviceNoResponse() DO
    // code executed after the Webservice response
    // .... = Res
    END
    // code executed immediately
  • This syntax can only be used for calling SOAP Webservices.
  • The <Code executed if response> is executed as a Callback procedure once the Webservice has been executed and has sent a response.
  • Important : the code executed after the SOAP Webservice call (after the END keyword) is executed in the context of the calling thread. If the call is made in the main the thread, the execution of a wait function (ThreadPause, Multitask, EventWait, etc.) will cause a deadlock.
  • The ErrorOccurred WLanguage variable can be used to handle possible errors during the call to the SOAP Webservice. For example:
    // Calls the SOAP Webservice to verify the VAT number
    AFTER MyResponse = checkVat(sCountry, sVATNum) DO
    // If an error occurred
    IF ErrorOccurred THEN
    ...
    END
    END
Minimum version required
  • Version 26
This page is also available for…
Comments
Click [Add] to post a comment