Forum OpenACS Development: Re: XML request Versus SOAP response

Posted by Claudio Pasolini on
Hi Iuri,

I tried tclsoap many years ago, but in my opinion tsclws ( is a much better choice.

The only caveat is that if you have to call an existing web service you are limited to document/literal and rpc/encoded.



Posted by Russell Sorensen on
Are you interested in using a client to interact with an existing service, or are you trying to setup a server on OpenACS to respond to client requests?

The best tcl client is tclws as mentioned by Claudio Pasolini. I think my server is better overall. The software is available on gitHub:

You can see a service in action at:

The file you write to create the above service is this (saved as index.tcl somewhere under pageroot):

# Examples Using OpenACS data types:
# Regular expressions were taken from, and
# use is covered by their license.
<ws>namespace init ::openacs

# Initialize Schema
<ws>namespace schema ::openacs ""

### Simple Types

# Phone
<ws>type pattern openacs::phone {^\(?([1-9][0-9]{2})\)?(-|\.|\ )?([0-9]{3})(-|\.|\ )?([0-9]{4})};

# Email
<ws>type pattern openacs::email  {^[^@\t ]+@[^@.\t]+(\.[^@.\n ]+)+$};

# NaturalNum
<ws>type pattern openacs::naturalNum {^(0*)(([1-9][0-9]*|0))$} xsd::integer

# Operations for the service:
<ws>proc ::openacs::CheckEmail {
} {
    return [list "$Email" "True"]
} returns {Email:openacs::email IsEmail:boolean}

<ws>proc ::openacs::CheckPhone {
} {
    return [list $Phone True]
} returns {Phone:openacs::phone IsPhone:boolean}

<ws>proc ::openacs::CheckNaturalNumber {
} {
    return [list $NaturalNumber True]
} returns {NaturalNumber:openacs::naturalNum IsNaturalNum:boolean}

<ws>namespace finalize ::openacs

<ws>namespace freeze ::openacs

<ws>return ::openacs

Additional running examples are here:

You will be limited to document/literal but I have been considering putting in a json to json adapter.

These example services also expose some of the client functionality. If you click on one of the operation links, you are presented with an auto-generated form. Fill out the form and it is sent as a GET request to the server. This is converted into a client SOAP/document/literal format and resubmitted to the same url as a POST. I never got around to exploiting this, but it would be relatively straightforward to create a proxy service.