SoapConnection:
CreateInstance method
Description
Creates a proxy instance with a default URL for a SOAP server,
which comes from a user-supplied WSDL file. The client application
must create a proxy instance before it can access a Web service.
Syntax
1 |
<span>conn</span>.<span>CreateInstance</span> (ref powerobject <span>proxy_obj</span>, string <span>proxy_name</span>, {string <span>portname</span>}) throws SoapException |
Argument |
Description |
---|---|
conn |
The name of the SoapConnection object |
proxy_obj |
The referenced name of your proxy object |
proxy_name |
The name of the proxy, based on the port |
portname |
(Optional) The port name from a URL not |
Return Values
Long. Valid values are:
Value |
Description |
||
---|---|---|---|
|
Successful |
||
|
Invalid proxy name |
||
|
Failed to create proxy |
Examples
In this example, the client application creates a
proxy instance to access the Web services at http://my.server/soap/myport.
The proxy name “syb_myport” is generated by the Web Service
Proxy wizard when you select “syb_” as a prefix for a service
port (endpoint) called “myport”.
1 |
syb_myport myproxy<br>long ret<br> <br>ret = Conn.<span>CreateInstance</span>(myproxy, "syb_myport", "http://my.server/soap/myport") |
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 is used). The script uses the SetOptions method
to specify a log file. It displays a return value in an application
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 proxystring 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> <br>// Set trace file to record soap interchange data, <br>// if string is "", disables the feature<br> <br>rVal = Conn.<span>CreateInstance</span>(proxy_obj, &<br>   "syb_currencyexchangeport", str_endpoint)<br> <br>// Create proxy object<br>try<br> <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 |
Usage
After you instantiate a proxy, you are ready to call the SOAP
methods you want from the associated Web service port.