Difference between revisions of "WebServices ASE"

From SybaseWiki
Jump to: navigation, search
m
m
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Installation==
 
==Installation==
  
Based on an Linux installation using ASE version 15.0 (ebf 12780), here are some steps to install WebServices on an existing database server.
+
Based on an Linux installation using ASE version 15.0.2, here are some steps to install WebServices on an existing database server.
  
 
* Run the aseplugin executable (located in $SYBASE/ASEP/bin). Pass the parameter -i for interactive mode (not -I as stated in the Sybase documentation)
 
* Run the aseplugin executable (located in $SYBASE/ASEP/bin). Pass the parameter -i for interactive mode (not -I as stated in the Sybase documentation)
 
* Answer all the questions.
 
* Answer all the questions.
* During the installation an sp_configure "enable webservices",1 is done
 
 
* The script $SYBASE/$SYBASE_WS/bin/installws is loaded into the database server, basically installing the procedures sp_webservices and sp_get_unique_table into the sybsystemprocs database.
 
* The script $SYBASE/$SYBASE_WS/bin/installws is loaded into the database server, basically installing the procedures sp_webservices and sp_get_unique_table into the sybsystemprocs database.
* At the end a properties file is generated in $SYBASE/$SYBASE_WS/props. You can manualy changed this file.
+
* At the end a properties file "ws.properties" is generated in $SYBASE/$SYBASE_WS/props. You can manualy change this file.
* When you specified a non-default consumer port, please change the properties file afterwards with the right port number.
+
* The installation software does not set all non-default configuration values to the value that has been specified during the installation. Check the generated ws.properties file to verify it is correct. A sample is provided here:
* Modify the properties file to indicate the location of the interfaces file. Put the location in the line starting with "com.sybase.ase.ws.interfaces".
+
  
==Starting / Stopping==
+
com.sybase.ase.ws.name = ASE1_WS
Starting or stopping the producer
+
com.sybase.ase.ws.producer.httpport = 8181
* run the runws / stopws script, but do not supply a "-v" argument.
+
com.sybase.ase.ws.consumer.cisport = 8183
* For better debugging when you run into problems, change the runws script so that the output generated by the producer is not being written to /dev/null, but write it into a file.
+
com.sybase.ase.ws.logfilename = /opt/sybase/admin/ASE1_WS/webservice.log
 +
com.sybase.ase.ws.producer.jettylogfile = /opt/sybase/admin/ASE1_WS/http.log
 +
com.sybase.ase.ws.interfaces = /opt/sybase/ase1502/interfaces
 +
com.sybase.ase.ws.libtcl = /opt/sybase/ase1502/OCS-15_0/config/libtcl.cfg
 +
com.sybase.ase.ws.ui.activate = true
 +
com.sybase.ase.ws.producer.tuning.maxthreads = 250
 +
com.sybase.ase.ws.producer.tuning.minthreads = 45
 +
com.sybase.ase.ws.producer.tuning.maxidletime = 60000
 +
com.sybase.ase.ws.producer.tuning.ssl.maxthreads = 125
 +
com.sybase.ase.ws.producer.tuning.ssl.minthreads = 10
 +
com.sybase.ase.ws.producer.tuning.ssl.maxidletime = 60000
 +
com.sybase.ase.ws.producer.ssl.password =
 +
com.sybase.ase.ws.producer.ssl.httpsport =
 +
com.sybase.ase.ws.producer.ssl.keystore =
 +
com.sybase.ase.ws.producer.ssl.keypassword =
 +
 
 +
* Enable web services in ASE by enabling it:
 +
sp_configure "enable webservices",1
 +
 
 +
==Configure WebServices for SSL==
 +
When SSL has been configured you can make secure connections and also use your browser for configuration purposes. Configure SSL by running configssl. You are asked to enter 2 passwords. Configssl automatically modifies the ws.properties file to reflect the new settings.
 +
$SYBASE/$SYBASE_WS/bin/configssl -d <hostname>
 +
The ws.properties file now has ssl entries.
 +
com.sybase.ase.ws.producer.ssl.password = F0AA463AB062113FE6376956E2FF2665
 +
com.sybase.ase.ws.producer.ssl.httpsport = 8182
 +
com.sybase.ase.ws.producer.ssl.keystore = /opt/sybase/admin/ASE1_WS/keystore   
 +
com.sybase.ase.ws.producer.ssl.keypassword = F0AA463AB062113FE6376956E2FF2665
 +
 
 +
==Starting==
 +
Start webservices like this:
 +
$SYBASE/$SYBASE_WS/bin/runws -Usa_webservices -P webs01 -SASE1 -f /opt/sybase/admin/ASE1_WS/ASE1_WS.properties
 +
Some notes
 +
* Keep a space between the -P and the actual password.
 +
* The login specified, in this case sa_webservices, should have sa_role.
 +
* Look in the file specified at com.sybase.ase.ws.logfilename if there were any errors during start-up.
 +
 
 +
==Using the GUI to test the setup==
 +
When in the ws.properties file com.sybase.ase.ws.ui.activate has been set to true, you can use a browser to access the WebServices server. The URLs that you can use are, for example, http://prd-syb-ase1:8181 and https://prd-syb-ase1:8182. The gui allows you to to view the configuration settings, log files and test web methods. It looks like this:
 +
 
 +
[[Image:asewebservices.gif]]
 +
 
 +
==Using the runexecute client==
 +
The runexecute script (located in $SYBASE/$SYBASE_WS/samples/apacheclient) can be used to further test your setup. To run a simple test, like retrieving the @@version global variable from an ASE, do this:
 +
chmod +x $SYBASE/$SYBASE_WS/samples/apacheclient/runexecute
 +
<nowiki>$SYBASE/$SYBASE_WS/samples/apacheclient/runexecute "http://prd-syb-ase1:8181/services/ase" ASE1 peter peter01 "header=yes" all 1 "select @@version"</nowiki>
 +
In the Sybase documentation a wrong portnumber is used in combination with the runexecute client, use 8181 in stead of 8183. The output should like like this: [[runexecute sample output]].
 +
 
 +
==Exposing a WebService==
 +
When you want to expose a WebService built into your ASE database and thereby make it available to the outside world, follow these steps.
 +
* Define a new server called ws that maps to the WebServices engine. This server ws must be defined in the interfaces file before you can use it.
 +
sp_addserver ws,sds
 +
* Grant the user that will manage the webservices the role "webservices_role"
 +
grant role webservices_role to <login>
 +
* Create a service with the "create service" statement. This type of statement looks very much like a stored procedure definition.
 +
create service GetCustomer_service
 +
        secure ssl, userpath "GetCustomer" type xml
 +
        (@id_customer int)
 +
as
 +
 +
select name, phone
 +
from customer
 +
where id_customer = @id_customer
 +
* Deploy the new service
 +
sp_webservices "deploy","GetCustomer_service"
 +
 
 +
Now the service has been created and it's available.
 +
 
 +
To see the definition for the outside world (the wsdl) use your browser and open this url:
 +
<nowiki>http://<hostname>:8181/services/<database-name>/GetCustomer?wsdl</nowiki>
 +
 
 +
==Stopping==
 +
Stop webservices like this:
 +
$SYBASE/$SYBASE_WS/bin/stopws -Usa_webservices -P webs01 -SASE1 -f /opt/sybase/admin/ASE1_WS/ASE1_WS.properties
  
 
[[Category:ASE]]
 
[[Category:ASE]]

Latest revision as of 16:57, 4 January 2008

Installation

Based on an Linux installation using ASE version 15.0.2, here are some steps to install WebServices on an existing database server.

  • Run the aseplugin executable (located in $SYBASE/ASEP/bin). Pass the parameter -i for interactive mode (not -I as stated in the Sybase documentation)
  • Answer all the questions.
  • The script $SYBASE/$SYBASE_WS/bin/installws is loaded into the database server, basically installing the procedures sp_webservices and sp_get_unique_table into the sybsystemprocs database.
  • At the end a properties file "ws.properties" is generated in $SYBASE/$SYBASE_WS/props. You can manualy change this file.
  • The installation software does not set all non-default configuration values to the value that has been specified during the installation. Check the generated ws.properties file to verify it is correct. A sample is provided here:
com.sybase.ase.ws.name = ASE1_WS
com.sybase.ase.ws.producer.httpport = 8181
com.sybase.ase.ws.consumer.cisport = 8183
com.sybase.ase.ws.logfilename = /opt/sybase/admin/ASE1_WS/webservice.log
com.sybase.ase.ws.producer.jettylogfile = /opt/sybase/admin/ASE1_WS/http.log
com.sybase.ase.ws.interfaces = /opt/sybase/ase1502/interfaces
com.sybase.ase.ws.libtcl = /opt/sybase/ase1502/OCS-15_0/config/libtcl.cfg
com.sybase.ase.ws.ui.activate = true
com.sybase.ase.ws.producer.tuning.maxthreads = 250
com.sybase.ase.ws.producer.tuning.minthreads = 45
com.sybase.ase.ws.producer.tuning.maxidletime = 60000
com.sybase.ase.ws.producer.tuning.ssl.maxthreads = 125
com.sybase.ase.ws.producer.tuning.ssl.minthreads = 10
com.sybase.ase.ws.producer.tuning.ssl.maxidletime = 60000
com.sybase.ase.ws.producer.ssl.password =
com.sybase.ase.ws.producer.ssl.httpsport =
com.sybase.ase.ws.producer.ssl.keystore =
com.sybase.ase.ws.producer.ssl.keypassword =
  • Enable web services in ASE by enabling it:
sp_configure "enable webservices",1

Configure WebServices for SSL

When SSL has been configured you can make secure connections and also use your browser for configuration purposes. Configure SSL by running configssl. You are asked to enter 2 passwords. Configssl automatically modifies the ws.properties file to reflect the new settings.

$SYBASE/$SYBASE_WS/bin/configssl -d <hostname>

The ws.properties file now has ssl entries.

com.sybase.ase.ws.producer.ssl.password = F0AA463AB062113FE6376956E2FF2665
com.sybase.ase.ws.producer.ssl.httpsport = 8182
com.sybase.ase.ws.producer.ssl.keystore = /opt/sybase/admin/ASE1_WS/keystore    
com.sybase.ase.ws.producer.ssl.keypassword = F0AA463AB062113FE6376956E2FF2665

Starting

Start webservices like this:

$SYBASE/$SYBASE_WS/bin/runws -Usa_webservices -P webs01 -SASE1 -f /opt/sybase/admin/ASE1_WS/ASE1_WS.properties

Some notes

  • Keep a space between the -P and the actual password.
  • The login specified, in this case sa_webservices, should have sa_role.
  • Look in the file specified at com.sybase.ase.ws.logfilename if there were any errors during start-up.

Using the GUI to test the setup

When in the ws.properties file com.sybase.ase.ws.ui.activate has been set to true, you can use a browser to access the WebServices server. The URLs that you can use are, for example, http://prd-syb-ase1:8181 and https://prd-syb-ase1:8182. The gui allows you to to view the configuration settings, log files and test web methods. It looks like this:

Asewebservices.gif

Using the runexecute client

The runexecute script (located in $SYBASE/$SYBASE_WS/samples/apacheclient) can be used to further test your setup. To run a simple test, like retrieving the @@version global variable from an ASE, do this:

chmod +x $SYBASE/$SYBASE_WS/samples/apacheclient/runexecute
$SYBASE/$SYBASE_WS/samples/apacheclient/runexecute "http://prd-syb-ase1:8181/services/ase" ASE1 peter peter01 "header=yes" all 1 "select @@version"

In the Sybase documentation a wrong portnumber is used in combination with the runexecute client, use 8181 in stead of 8183. The output should like like this: runexecute sample output.

Exposing a WebService

When you want to expose a WebService built into your ASE database and thereby make it available to the outside world, follow these steps.

  • Define a new server called ws that maps to the WebServices engine. This server ws must be defined in the interfaces file before you can use it.
sp_addserver ws,sds
  • Grant the user that will manage the webservices the role "webservices_role"
grant role webservices_role to <login>
  • Create a service with the "create service" statement. This type of statement looks very much like a stored procedure definition.
create service GetCustomer_service
       secure ssl, userpath "GetCustomer" type xml
       (@id_customer int)
as

select name, phone
from customer
where id_customer = @id_customer
  • Deploy the new service
sp_webservices "deploy","GetCustomer_service"

Now the service has been created and it's available.

To see the definition for the outside world (the wsdl) use your browser and open this url:

http://<hostname>:8181/services/<database-name>/GetCustomer?wsdl

Stopping

Stop webservices like this:

$SYBASE/$SYBASE_WS/bin/stopws -Usa_webservices -P webs01 -SASE1 -f /opt/sybase/admin/ASE1_WS/ASE1_WS.properties