Forum OpenACS Development: XML request Versus SOAP response

Collapse
Posted by Iuri Sampaio on

Hi there, A third party webservice receives an XML post request and returns a SOAP response, rsrs!

Whether I like or not, I must parse that SOAP into OACS. Assuming that the idea of manipulating that SOAP structure manually is simply the worst and last option to choose, ...

what would be the best tool to manipulate that SOAP response?

  1. Perhaps TDOM?
  2. rl_json
  3. install xml-rpc
  4. Reusing OACS source in a customized pkg . Which pieces?

The samples of XML requests and SOAP responses are bellow

Best wishes, I

 #?xml version="1.0" encoding="UTF-8"?
  #OTA_VehAvailRateRQ# xmlns="http://www.opentravel.org/OTA/2003/05"# 
#POS#
 #Source#
 # ...#/OTA_VehAvailRateRQ#
#soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"##soap:Body##OTA_VehAvailRateRS Target="Test" xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 https://xml.movida.com.br/movida/ws3/wsdl/OTA_VehAvailRateRS.xsd" SequenceNmbr="1" CorrelationID="0-0.88" PrimaryLangID="br" Version="5.000"##Success/#
#VehAvailRSCore#
...
#/soap:Body##/soap:Envelope#
Collapse
Posted by Maurizio Martignano on
Is the following worth to be considered
http://tclsoap.sourceforge.net/
?

Hope it helps,
Maurizio

Collapse
Posted by Claudio Pasolini on
Hi Iuri,

I tried tclsoap many years ago, but in my opinion tsclws (https://core.tcl-lang.org/tclws/doc/Release_2.6.2/docs/index.html) 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.

Ciao,

Claudio

Collapse
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:

https://github.com/russell-todd-sorensen/twist

You can see a service in action at:
https://www.semitasker.com/twist/ws/openacs/

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 openacs.org, and
# use is covered by their license.
<ws>namespace init ::openacs

# Initialize Schema
<ws>namespace schema ::openacs "https://www.semitasker.com/twist/ws/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 {
    {Email:openacs::email}
} {
    return [list "$Email" "True"]
} returns {Email:openacs::email IsEmail:boolean}

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

<ws>proc ::openacs::CheckNaturalNumber {
    {NaturalNumber:openacs::naturalNum}
} {
    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:
https://www.semitasker.com/twist/ws/datetime/
https://www.semitasker.com/twist/ws/mywebservice/
https://www.semitasker.com/twist/ws/stockquoter/
https://www.semitasker.com/twist/ws/stockquoter2/

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.

Collapse
Posted by Iuri Sampaio on
Hi all,
The service's in place already. It's a legacy from third parties, and I'm using OpenACS (i.e. a custom package), as middleware to intermediate the communication between webserver and frontend application.

I'm going to study tclws. That's for sure. Perhaps not in this case, because I've already started parsing SOAP schema, coverting it to a json format,delivering it to the frontend.

I'm defintely using tclws as a server in my next project, or as a third option for webservice's integration.
1. JSON i.e. a custom version from intranet-rest ]PO[
2. XML-RPC OpenACS pkg
3. and now TCLWS

Thanks guys for the advices!

Best wishes,
I