You use the SoapConnection object to connect to the SOAP server that hosts the Web service that you want to access. The SetOptions method on a SoapConnection object lets you set options such as the user ID and password for an HTTPS connection. For .NET Web services, you can also use authentication methods such as SetBasicAuthentication, SetCertificateFile and UseWindowsAuthentication.
Using multiple Web services in the same application If you connect to multiple Web services that have different authentication requirements, you must instantiate multiple SoapConnection objects and set the appropriate values in the SetOptions method or in the other authentication methods of each connection object.
You use the CreateInstance method to create the client proxy instance to access the Web service.
For more information on SoapConnection object methods, see the PowerBuilder Extension Reference in the online Help.
The following script creates a connection to a Web service on a SOAP server using the EasySoap Web service engine. 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 SetSoapLogFile method to specify a log file. It displays a return value in a message box.
SoapConnection conn // Define SoapConnection syb_currencyexchangeport proxy_obj // Declare proxy long rVal, lLog real amount //Define endpoint. You can omit it, if you want to use //the default endpoint inside proxy string str_endpoint str_endpoint = "http://services.xmethods.net:80/soap" conn = create SoapConnection //Instantiated connection lLog = conn.SetSoapLogFile ("C:\mySoapLog.log") // Set trace file to record soap interchange data, // if string is "", disables the feature rVal = Conn.CreateInstance(proxy_obj, & "syb_currencyexchangeport", str_endpoint) // Create proxy object try amount = proxy_obj.getrate("us","japan") // Invoke service messagebox("Current Exchange Rate", "One US Dollar"& + " is equal to " + string(amount) + " Japanese Yen") catch ( SoapException e ) messagebox ("Error", "Cannot invoke Web service") // error handling end try destroy conn