Hi Jeff,

We have UniData, not Universe, but here is a sample code snippet I was 
playing with for consuming a SOAP web service in a UniBasic subroutine. It 
uses SOAPCreateRequest to manage the actual communication.  This is based 
on some sample code I found with a google search, but I don't remember 
exactly which site I found the example on.  It may have been 
http://permalink.gmane.org/gmane.comp.db.u2.general/52800 but I might be 
mistaken. 

Anyway, my test web service expected a product key as a parameter, then 
looked up that key in a database and returned a product description.  It's 
a really basic example, but I hope it helps.

Cheers,
Jim Stoner

******************************************************
$INCLUDE /usr/ud72/sys/INCLUDE/XML.H

Desc=""
NodeName=""
TextName=""

RespHeaders = ''
RespData = ''
SoapStatus = ''

URL = "http://<insert-url-for-wsdl>"
SoapAction = "GETDESC" ;* replace with the web service action
SoapNS = "urn:DefaultNamespace" ;* replace with the web service name space
SoapMethod = "GETDESC" ;* replace with the web service method
SoapParams = "KEY":@VM:A.KEY:@VM:"xsd:string" ;* replace with the required 
parameters for the web service call.  In my test case, the subroutine is 
passed in a single value which gets sent to the web service as a string 
param called KEY

Timeout = 30000

* create the request

IF SOAPCreateRequest(URL, SoapAction, SoapReq) <> 0 THEN
   PRINT "SOAPCreateRequest failed."
   RETURN
END

Status = SOAPSetParameters(SoapReq, SoapNS, SoapMethod, SoapParams )
Status = SOAPSubmitRequest(SoapReq, Timeout, RespHeaders, RespData, 
SoapStatus)
PRINT "SOAPSubmitRequest Status: " : Status

RespData = RespData:CHAR(10) ;* add a line-feed at the end of the xml 
string
PRINT "Response: ": RespData

IF XDOMOpen(RespData, XML.FROM.STRING, domFile) <> XML.SUCCESS THEN ;* 
domh is the document handle
   PRINT "XDOMOpen failed."
   RETURN
END
 
IF XDOMLocate(domFile, '//GETDESCReturn', '', nodeHandle) <> XML.SUCCESS 
THEN
   PRINT "XDOMLocate failed."
   RETURN
END

Status=XDOMGetNodeName(nodeHandle, NodeName)
PRINT "Node Name: ": NodeName
 
IF XDOMLocateNode(nodeHandle, XDOM.CHILD, XDOM.FIRST.CHILD, XDOM.TEXT.NODE
, textHandle) <> XML.SUCCESS THEN
   PRINT "XDOMLocateNode failed."
   RETURN
END

IF XDOMGetNodeValue(textHandle, Desc) <> XML.SUCCESS THEN
   PRINT "XDOMGetNodeValue failed."
   RETURN
END

PRINT "Returned Description: " : Desc

RETURN
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to