Connecting to a SOAP server
The SoapConnection class
is used to connect to the SOAP server that hosts the Web service
you want to access. You can use the SetOptions method
on a SoapConnection object to set options such as the user ID and
password for an HTTPS connection. You use the CreateInstance method
to create the client proxy instance to access the Web service.
Example
The following script creates a connection to a Web service
on a SOAP server. It sets the connection properties using an endpoint
defined in the CreateInstance method. If the endpoint is not defined
in the CreateInstance method, a default URL stored in the proxy
would be used. The script uses the SetOptions method
to specify a log file. It displays a return value in a message box.
|
1 |
SoapConnection conn // Define SoapConnection<br />syb_currencyexchangeport proxy_obj // Declare proxy<br />long rVal, lLog<br />real amount<br /><br />//Define endpoint. You can omit it, if you want to use<br />//the default endpoint inside proxy<br />string str_endpoint<br /><br />str_endpoint = "http://services.xmethods.net:80/soap"<br />conn = create SoapConnection //Instantiated connection<br /><br />lLog = conn.SetOptions("SoapLog=~"C:mySoapLog.log~"") <br />// Set trace file to record soap interchange data, <br />// if string is "", disables the feature<br /><br />rVal = Conn.CreateInstance(proxy_obj, &<br /> "syb_currencyexchangeport", str_endpoint)<br /><br />// Create proxy object<br />try<br /> amount = proxy_obj.getrate("us","japan") <br /> // Invoke service<br /> messagebox("Current Exchange Rate", "One US Dollar"&<br /> + " is equal to " + string(amount) + " Japanese Yen")<br />catch ( SoapException e )<br /> messagebox ("Error", "Cannot invoke Web service")<br /> // error handling <br />end try<br />destroy conn |
Document get from Powerbuilder help
Thank you for watching.
Subscribe
Login
0 Comments
Oldest