Mega Code Archive
 
 
    
Simple SOAP service using PocketSOAP
Title: Simple SOAP service using PocketSOAP
Question: How to use PocketSOAP to connect to a simple SOAP service?
Answer:
First you have to download and install PocketSOAP, then you have to create a new project and put PocketSOAP_TLB on the uses clause. The following example connects to a SOAP service to get Quote values at xmethods.net.
To import and create these Type Libraries (TLBs), go the menu "Project" - "Import Type Library..." and on the dialog mark the checkbox "Generate Component Wrapper". Select "Pocket SOAP 1.x.x Type Library" and click on "Create Unit".
Declare the following variables:
var
 env: ISOAPEnvelope;
 http: IHTTPTransport;
 params: ISOAPNodes;
 node: ISOAPNode;
 Value: OLEVariant;
 serialize: WideString;
To create the SOAP service wrapper use the following code:
begin
 env := CoCoEnvelope.Create;
 env.SetMethod('getQuote', 'urn:xmethods-delayed-quotes');
 env.Get_Parameters(params);
 params.Create('symbol', 'INTC', '', '', '', node);
To create the HTTP transport handler use the following code:
 http := CoHTTPTransport.Create;
 http.Set_SOAPAction('');
 env.Serialize(serialize);
 http.Send('http://services.xmethods.net:80/soap', serialize);
To get the result use the following code:
 env.Parse(http, '');
 env.Get_Parameters(params);
 node := CoCoSoapNode.Create;
 params.Get_Item(0, node);
 node.Get_Value(Value);
 ShowMessage(Value);
end;