Integreert PeekServer(), SetLocation() en SetTimeOut() methods in de standaard SOAPClient klasse.
Werkwijze:
  • standaard SOAP client klasse discoveren van SOAP webservice klasse (inclusief PeekServer method)
  • klasse: Extends (%SOAP.WebClient, WS.SOAPClientExt)
  • het %Action argument van de PeekServer() WebMethod moet correct ingevuld worden: "http://tempuri.org/WS.???.PeekServer"
  • OF: PeekServer() kan de method PeekCheckWSDL() oproepen, wanneer geen PeekServer() aanwezig is in de WebService
  • indien gewenst, specifieke prepare methods PrepareXXX() toevoegen; zie PrepareTemplateMethod()
  • de volledige SOAP call implementeren (in de oproepende routine/klasse) zoals in de voorbeelden hieronder. Voorbeelden van SOAP calls :
     
      Via algemene prepare    -->  PrepareSoapMethod()
      --- -------- -------
        Set cl=$System.OBJ.New("WS.TBX.DataIOSoap")
        Set lbLocs=cl.GetLocations($LB("cache01\ADMIN1","cache02\JRNL-ADMIN1"))
        Set Rslt=cl.PrepareSoapMethod("GetKlant",lbLocs,.locIndx,1,45)
        Quit:('Rlst)
        Set km=cl.GetKlant(4645)
        Set cl=""
    
      Via specifieke prepare  --> PrepareXXX() zelf toe te voegen; zie PrepareTemplateMethod()
      --- ---------- -------
        Set cl=$System.OBJ.New("WS.TBX.DataIOSoap")
        Set Rslt=cl.PrepareGetKlant()   ; OR  cl.PrepareGetKlant(.lbLocs,.locIndx)   ; to obtain info about the Locs
        Quit:('Rlst)
        Set km=cl.GetKlant(4682)
        Do $System.OBJ.Dump(cl)
     
      Via losse instructies   --> PeekSOAPServer() / SetLocation() / SetTimeOut()
      --- -----------------
        Set cl=$System.OBJ.New("WS.TBX.DataIOSoap")
        Set lbLocs=cl.GetLocations($LB("cache01\ADMIN1","cache02\JRNL-ADMIN1"))
        Set locIndx=cl.PeekSOAPServer(lbLocs,0,"TBX_ERR")
        Do cl.SetLocation($S(locIndx>0:$LG(lbLocs,locIndx),1:""))
        Do cl.SetTimeOut(45)
        Set:(locIndx'<0) km=cl.GetKlant(6820)
    

    Opgelet: de ZTRAP rond de oorspronkelijke webmethod (hier: cl.GetKlant()) moet zelf geschreven worden.
        Set $ZTRAP="subSoapErrorGetKlant"
        Set km=cl.GetKlant(4645)
        Set $ZTRAP=""
        Quit
      subSoapErrorGetKlant  
        Set $ZTRAP=""
        Set $ZE="" 
        Quit
    
    De PeekSOAPServer() method bevat wel errortrapping.
    Het derde arg. MailParamType (="TBX_ERR") bepaald de mail die verzonden wordt in geval van fouten.
    ]]> 1 vhLib.Macro,%occInclude 1 0 De standaard code in de PeekServer() method (i.e.: Quit ..WebMethod("PeekServer").Invoke(##this, url...) ) moet vervangen worden door volgende routine:
     #define PeekUrl   $S($L(..Location):..Location, 1:..#LOCATION)_"?wsdl"
       New response,sc
       Set sc=..PeekCheckWSDL($$$PeekUrl,.response)
       Quit 1
    
    De variabele response als .local doorgeven, om eventuele verdere bewerkingen/controles uit te voeren op de WSDL.]]>
    1 %Status 0) request.Port=arUrl("port") If ..Timeout'="" Set request.Timeout = ..Timeout #If (##class(TECH.Config.ConfigMgr).Instance().GetBoolean("WS.SOAPClientExt_KanHttpProxyGebruiken")) If ..HttpProxyServer'="" { Set request.ProxyServer=..HttpProxyServer Set:(..HttpProxyPort'="") request.ProxyPort=..HttpProxyPort ;Set:(..HttpProxyHTTPS'="") request.ProxyHTTPS=..HttpProxyHTTPS } #EndIf ;If ..HttpRequestHeaderCharset'="" Set request.RequestHeaderCharset = ..HttpRequestHeaderCharset ;If ..HttpUsername'="" Set request.Username = ..HttpUsername ;If ..HttpPassword'="" Set request.Password = ..HttpPassword Do request.Get(tmpUrl) Set response=request.HttpResponse Quit:(response.StatusCode'="200")&&(response.StatusCode'="500") $$$ERROR($$$SOAPUnexpectedStatus,response.StatusCode) Quit:($piece(response.ContentType,";",1)'="text/xml") $$$ERROR($$$SOAPUnexpectedType,response.ContentType) Quit:(response.Data="") $$$ERROR($$$SOAPNoResponseBody) Quit $$$OK ]]>
    %String 1 %Boolean Return value of locNdx:
    • locNdx=0 : location from class parameter is used
    • locNdx>0 : n-th item from lbLocations
    • locNdx<0 : no valid location found! Return value of the method = 0 (false) ]]> %Boolean 0) Location=$LG(lbLocations,locNdx) Else If $L($LG(lbLocations,1)) Do . Set Location=$LI(lbLocations,1) . Set locNdx=1 Else Do . Set Location="" . Set locNdx=0 Do:($L($G(Location))) ..SetLocation(Location) Do:($D(TimeOut)) ..SetTimeOut(TimeOut) Quit $S(locNdx<0:0, 1:1) ]]> 0) Location=$LG(lbLocations,locNdx) ;Do:($L($G(Location))) ..SetLocation(Location) ;Do:($D(TimeOut)) ..SetTimeOut(TimeOut) Quit 1 } */ ]]> TimeOut:%Integer Location:%String %SOAP.Fault " #EndIf ]]> lbWSlocs:%List %List %List When blnSetLocation=1, this location is filled in in the ..Location Property, used for the main WebService call.
      MailParamType (e.g. "TBX_ERR") used in the Error Trap routine for formatting the mail to be sent.
      Return locNdx : possible values:
      • -1 : Response from any location NOT OK !
      • 0 : Response from Default location OK
      • >0 : Response from (location of n-th list item) OK
      ]]>
      lbLocations:%List,blnSetLocation:%Boolean=1,MailParamType:%String 1 %Integer just perform the requested SOAP-method ; Verify that locNdx corresponds with a non-empty location Set:(locNdx>0)&&($LG(lbLocations,locNdx)="") locNdx=0 If +$G(blnSetLocation,1) Do . Do ..SetLocation($S(locNdx>0:$LG(lbLocations,locNdx),1:"")) Quit locNdx pssPeekLocations ;New Client,i,sc Set Client=$System.OBJ.New(SoapClass) Do Client.PreparePeekServer() ;Do Client.SetTimeOut(5) Set %objlasterror="" Set:($G(lbLocations)="") lbLocations=$LB("") Set locNdx=-1 For i=1:1:$LL(lbLocations) Do Quit:(locNdx>0) . Set sc=$$pssPeekLocation($LG(lbLocations,i)) . Set:(sc) locNdx=i Quit pssPeekLocation(loc) ;w "Perform a PeekServer() at location "_$G(loc),! ;New PeekResult Do Client.SetLocation($G(loc)) #If (##class(TECH.Config.ConfigMgr).Instance().GetBoolean("SOAPlib_IsSoapFaultSupported")) Set Client.SoapFault="" ; SoapFault initieel leegmaken #Else ;Set Client.SoapFault="" #EndIf Set $ZTRAP="pssPeekSOAPError" Set PeekResult=Client.PeekServer() Set $ZTRAP="" Quit PeekResult pssPeekSOAPError ;New Err,msg Set Err=%objlasterror Set msg="(Peek) SOAP message: "_$$ParseStatus^vhLib(Err) If $$$GETERRORCODE(Err)=$$$CSPTimeout Do . Set PeekResult=0 Else Do . Set PeekResult=0 ; PeekServer returns another error ==> the actual WebMethod will probably return the same error // Log error via Mail Do:($D(MailParamType)) pssPeekSOAPErrorMail(SoapClass,loc) Set $ZE="" ;w "PeekResult (in ZTrap)="_PeekResult,! Quit PeekResult pssPeekSOAPErrorMail(cls,loc) ;New CustomMsg Set CustomMsg="Error within PeekServer(): SoapClass="_cls_" to location="_loc_" !" Do SOAPErrorMail^cspBasis.SOAPlib(MailParamType,,CustomMsg,,Client) ; MailParamType="TBX_ERR" Quit ]]>