SoapConnection

Description

The SoapConnection class is used to create a proxy object for a specific Web service and set options for the connection.

Methods

SoapConnection has the following methods:

The GenerateProxy method is currently not implemented.




CreateInstance

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

conn.CreateInstance (ref powerobject proxy_obj, string proxy_name, {string portname}) throws SoapException

Argument

Description

conn

The name of the SoapConnection object that establishes the connection

proxy_obj

The referenced name of your proxy object

proxy_name

The name of the proxy, based on the port name from a URL in the WSDL file stored in the proxy

portname

(Optional) The port name from a URL not stored in the proxy

Returns

Long. Valid values are:

Value

Description

0

Successful

100

Invalid proxy name

101

Failed to create proxy

Examples

Example 1

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".

syb_myport myproxy
long ret

ret = Conn.CreateInstance(myproxy, "syb_myport", "http://my.server/soap/myport")

Example 2

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:

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 proxystring str_endpoint

str_endpoint = "http://services.xmethods.net:80/soap"
conn = create SoapConnection  //Instantiated connection

lLog = conn.SetOptions("SoapLog=~"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

Usage

After you instantiate a proxy, you are ready to call the SOAP methods you want from the associated Web service port.

See also




SetOptions

Description

Sets connection options for SoapConnection class. The string values for the option names are not case sensitive.

Syntax

conn.SetOptions (string Options)

Argument

Description

conn

The name of the SoapConnection object that establishes the connection.

Options

Options you want to set for your connection. These can be:

  • SoapLog (EasySoap Web service engine only) The file path for SoapLog. To disable the log, enter "".

  • UserID A string value for an https connection.

  • Password A string value for an https connection.

  • Domain (.NET Web service engine only) A string value for the Web domain to which the user belongs. This could be a domain name, such as “sybase.com”, or a machine name.

  • UseWindowsAuthentication (.NET Web service engine only) A “yes” or “no” value to determine whether to use “Integrated Windows Authentication.” The value you enter can be a boolean or a string. If this option is set to “yes,” you do not need to set the UserID, Password, or Domain options.

  • AuthenticationMode (.NET Web service engine only) A string value for the authentication mode you want to use. This can be “basic” or “digest”. AuthenticationMode values are described on the Microsoft MSDN Web site.

  • CertificateFile (.NET Web service engine only) A string value for the certificate file or files that you want to send from the Web service client to the server. The string value could include local files with a full path and URLs to remote certificate files. You must use a semicolon as a separator for multiple files.

  • Timeout A number for the maximum wait time in seconds.

    The default timeout value is 0, meaning that no limit to the connection time is set.

  • ConnectionCache (EasySoap Web service engine only) A boolean that determines whether the http connection of the proxy instance is kept alive after a call to the proxy. The default value is false. For Web services on EAServer, you must not change the default.

Returns

Long. Valid values are 0 for success, and 50 for failure. If multiple options are specified and the return value is 50, options specified before the failure are still valid.

Examples

Example 1

In this example, the application enables the logging function and attempts to connect to an endpoint for which no user ID, password, or timeout has been set.

lOpt=Conn.SetOptions("SoapLog=~"airportweather.log~"")

If you do not want to use escape characters before a second pair of quotation marks, you can use single quotation marks instead, or you can start an exterior string with single quotation marks and use double quotation marks around an interior string:

lOpt=Conn.SetOptions('SoapLog="airportweather.log"')

Usage

User ID and password values can be set in an endpoint used by the SoapConnection class or by including these values as arguments to the SetOptions method.

Priority is given to values set in an endpoint (port) that is passed as an argument to the CreateInstance method of the SoapConnection class. However, a default endpoint is used when an endpoint is not set in the CreateInstance method. In this case, priority is given to user ID and password values defined in the SetOptions method.

If the endpoint used by the SoapConnection class does not have user ID and password values, and you do not set a user ID or password with the SetOptions method, the SoapConnection class connects to a SOAP server without giving a user ID or password.

If a user ID is defined in either the endpoint or the SetOptions method but is not a password, the password value is taken to be an empty string.

When you set a timeout other than the default, an exception is thrown after the Web service connection times out. Even if you do not set a timeout value from the client, the Web server can still cause the request to time out on the server side.

If you include ConnectionCache as an argument in a SetOptions call, you must not use quotation marks to enclose the value that you set for this option.

See also




SetProxyServerOptions

Description

Sets the proxy address, user name, and password for the proxy server.

Syntax

conn.SetProxyServerOptions (string optionstring)

Argument

Description

conn

The name of the SoapConnection object that establishes the connection.

optionstring

A string containing comma-separated name/value pairs. The format is:

"address='proxy_endpoint '{, userID='name ', password='password '} "

The address is required and can have a format such as:

http://hostname:port/path

Specify values for userID and password if the proxy server requires them.

Returns

Long. Valid values are 0 for success, and 50 for failure.

Examples

Example 1

This example specifies a user name and password, as well as the proxy endpoint:

long ll_return
string ls_string
ls_string = "address='http://Srvr:8080/endpnt',"
ls_string += "userID='MyName', password='mypass'"
ll_return = Conn.SetProxyServerOptions (ls_string)

Usage

Use this function if the proxy server requires authentication. The user ID and password you can supply with the SetOptions function apply to the URL of the service, not the proxy server.

See also