The following operations are supported. For a formal definition, please review the Service Description.

Web Service Links

Namespace Children of ::wsdb::bindings::openacsSoapBind

Namespace Code for ::wsdb::bindings::openacsSoapBind

namespace eval ::wsdb::bindings::openacsSoapBind {
    variable handleRequest ::wsdb::bindings::openacsSoapBind::HandleRequest
    variable portTypeName openacsPortType
    variable portTypeNamespace ::openacs

    variable soapActionArray
         set soapActionArray(https://a.mx.highfivediet.com/openacs/CheckNaturalNumberOperation) CheckNaturalNumberOperation
         set soapActionArray(https://a.mx.highfivediet.com/openacs/CheckEmailOperation) CheckEmailOperation
         set soapActionArray(https://a.mx.highfivediet.com/openacs/CheckPhoneOperation) CheckPhoneOperation
         set soapActionArray(https://a.ns.highfivediet.com/openacs/CheckEmailOperation) CheckEmailOperation
         set soapActionArray(https://a.ns.highfivediet.com/openacs/CheckNaturalNumberOperation) CheckNaturalNumberOperation
         set soapActionArray(https://www.highfivediet.com.highfivediet.com/openacs/CheckEmailOperation) CheckEmailOperation
         set soapActionArray(https://www.highfivediet.com.highfivediet.com/openacs/CheckNaturalNumberOperation) CheckNaturalNumberOperation
         set soapActionArray(https://home.highfivediet.com/openacs/CheckEmailOperation) CheckEmailOperation
         set soapActionArray(https://home.highfivediet.com/openacs/CheckNaturalNumberOperation) CheckNaturalNumberOperation
         set soapActionArray(https://a.ns.highfivediet.com/openacs/CheckPhoneOperation) CheckPhoneOperation
         set soapActionArray(https://highfivediet.com/openacs/CheckEmailOperation) CheckEmailOperation
         set soapActionArray(https://highfivediet.com/openacs/CheckNaturalNumberOperation) CheckNaturalNumberOperation
         set soapActionArray(https://www.highfivediet.com.highfivediet.com/openacs/CheckPhoneOperation) CheckPhoneOperation
         set soapActionArray(https://home.highfivediet.com/openacs/CheckPhoneOperation) CheckPhoneOperation
         set soapActionArray(https://highfivediet.com/openacs/CheckPhoneOperation) CheckPhoneOperation
    variable soapActionMap {https://highfivediet.com/openacs/CheckEmailOperation CheckEmailOperation https://highfivediet.com/openacs/CheckPhoneOperation CheckPhoneOperation https://highfivediet.com/openacs/CheckNaturalNumberOperation CheckNaturalNumberOperation}

}

Procedures in ::wsdb::bindings::openacsSoapBind


proc ::wsdb::bindings::openacsSoapBind::HandleRequest {
    requestID
} {
    variable soapActionArray
    variable portTypeName
    variable portTypeNamespace

    while {1} {
        # Response Code Default: Client Error
        set code 400
        log Debug "HandleRequest Running............."
        # 1. Figure out what operation is being performed
        set requestNamespace ::request::$requestID
        
        # SOAP Envelope reference
        set soapEnvelope "${requestNamespace}::response::Envelope"
        
        # Get requestArgs
        foreach {serverName service port binding address} [set ${requestNamespace}::requestArgs] { }
        # Get requestHeaders
        array set requestHeaders [set ${requestNamespace}::requestHeaders]
        # Does SOAPAction Header exist?
        if {[info exists requestHeaders(SOAPAction)]} {
            set SOAPAction [string trim $requestHeaders(SOAPAction) "\"'"]
            if {[info exists soapActionArray($SOAPAction)]} {
                set operation  $soapActionArray($SOAPAction)
            } else {
                set operation "SOAPAction Header doesn't correspond to Operation"
                log Error "SOAPAction='$SOAPAction' not found in '[array get soapActionArray]'"
                log Error "HandleRequest SOAPAction = '$SOAPAction' $operation"
                # Should return an error here

                set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
                ::wsdl::bindings::soap::appendFaultDetails $soapFault Client "SOAPAction '$SOAPAction' Not Associated with an Operation"
                break
            }
        } else {
            set operation "No SOAPAction Header Found..."
            set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
            ::wsdl::bindings::soap::appendFaultDetails $soapFault Client "SOAPAction header is missing, no way to identify operation."
            break
        }

        log Debug "HandleRequest operation = $operation"

        # Actual tcl namespace of operation 
        set operationNamespace "::wsdb::operations::${portTypeNamespace}::${operation}"
        log Debug "HandleRequest operationNamespace = $operationNamespace"
        log Debug "HandleRequest vars in ns: [info vars ${operationNamespace}::*]"
        
        
        # Do some XML Stuff:
        set requestFilename [set ${requestNamespace}::postFilename]
        set requestFD [open $requestFilename r]
        set requestXML [read $requestFD]
        close $requestFD
        # to dom doc
        dom parse $requestXML requestDoc
        $requestDoc documentElement requestRoot
        
        # Info on document:
        ######### ENVELOPE ###########
        foreach nodeInfo {nodeName namespaceURI prefix localName childNodes} {
            set envelope($nodeInfo) [$requestRoot $nodeInfo]
            log Debug "domNode $nodeInfo (Envelope) = '$envelope($nodeInfo)'"
        }
        
        # Check that the namespaceURI is correct
        if {"$envelope(namespaceURI)" ne "http://schemas.xmlsoap.org/soap/envelope/"} {
            # Need to return error 
            log Error "HandleRequest: VersionMismatch on SOAP Envelope id:$requestID"
        
            set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
        
            ::wsdl::bindings::soap::appendFaultDetails $soapFault VersionMismatch {
                SOAP Envelope Version Mismatch: 
                Correct SOAP Version is http://schemas.xmlsoap.org/soap/envelope/}
        
            break
        }

        # Check Element localname is Envelope
        if {"$envelope(localName)" ne "Envelope"} {
            # Need to return error
            log Error "HandleRequest documentElement not SOAP Envelope for $requestID"

            set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
            ::wsdl::bindings::soap::appendFaultDetails $soapFault Client {Root element was not Envelope}

            break
        }
        
        ########### BODY ############
        # Check Envelope children
        set envelope(childCount) [llength $envelope(childNodes)]
        
        if {"$envelope(childCount)" > 2 
            || "$envelope(childCount)" < 1
        } {
            # Error
            log Error "HandleRequest SOAP Envelope $envelope(childCount) children"
            set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
            ::wsdl::bindings::soap::appendFaultDetails $soapFault Client "Incorrect number of children 
 in SOAP Envelope: $envelope(childCount) children"

            break
        }

        # GET body and discard headers
        if {"$envelope(childCount)" == 2 } {
            # Handle Header//Just skip headers for now
            set BodyNode [lindex $envelope(childNodes) 1]
        }
        if  {"$envelope(childCount)" == 1 } {
            set BodyNode [lindex $envelope(childNodes) 0]

        }
        foreach nodeInfo {nodeName namespaceURI prefix localName childNodes} {
            set body($nodeInfo) [$BodyNode $nodeInfo]
            log Debug "domNode (Body) $nodeInfo = '$body($nodeInfo)'"
        }

        ########### BODY CONTENT ##########
        set body(childCount) [llength $body(childNodes)]
        if {"$body(childCount)" != 1} {
            # Error
            log Error "HandleRequest SOAP Body incorrect Child Node Count"
            set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
            ::wsdl::bindings::soap::appendFaultDetails $soapFault Client "Incorrect number of children 
 in SOAP Body: $body(childCount) children"

            break
        }

        set DocumentNode [lindex $body(childNodes) 0]
        foreach nodeInfo {nodeName namespaceURI prefix localName} {
            set document($nodeInfo) [$DocumentNode $nodeInfo]
            log Debug "domNode $nodeInfo (Document) = '$document($nodeInfo)'"
        }

        # Convert to internal format:
        set instanceNS "${requestNamespace}::input"

        ::xml::instance::newXMLNS $instanceNS [$DocumentNode asList] "1"
        set XMLdocumentElementList [namespace children $instanceNS]

        if {[llength $XMLdocumentElementList] != 1} {
            # Need to return error here
            set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
            ::wsdl::bindings::soap::appendFaultDetails $soapFault Client "Incorrect number of children 
 in documentElement: [llength $XMLdocumentElementList] children, should be 1"

            break
        } else {
            set XMLdocumentElement [lindex $XMLdocumentElementList 0]
        }

        log Debug "HandleRequest request children: [namespace children $instanceNS]"
        log Debug "HandleRequest XML = [::xml::instance::toXMLNS $XMLdocumentElement]"

        # tDom doc is gone:
        # This may not be necessary:
        rename $requestDoc ""
        
        # Check document has correct targetNamespace for service
        set targetNamespace [set ::wsdb::servers::${serverName}::targetNamespace]
        if {![::xml::instance::checkXMLNS $XMLdocumentElement $targetNamespace]} {
            log Error "HandleRequest incorrect request namespace " 
            set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
            ::wsdl::bindings::soap::appendFaultDetails $soapFault Client "Incorrect targetNamespace
  for WSDL service, should be $targetNamespace"

            break
        
        } else {
            log Debug "HandleRequest correct request namespace '$targetNamespace'"
        }

        # Check document type is valid
        # Document is input message, so we need to find that signature
        set inputMessageType [::wsdl::operations::getInputMessageType $portTypeNamespace $operation]
        
        if {"$inputMessageType" eq ""} {
            # Return Error Here...
            log Error "HandleRequest inputMessageType Not found for $portTypeNamespace $operation"
            set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
            ::wsdl::bindings::soap::appendFaultDetails $soapFault Client "inputMessageType Not found for $portTypeNamespace $operation"
            break
        }

        log Debug "HandleRequest: validating messageType '${inputMessageType}'"
        log Debug "HandleRequest: validating with '::wsdb::elements::${portTypeNamespace}::${inputMessageType}::validate'"

        if {![ValidateInputMessage $operation $XMLdocumentElement]} {
            log Error "HandleRequest input document invalid"
        
            # Return Error for fault...How?
            set soapFault [::wsdl::bindings::soap::createFault ${requestNamespace}::response]
            ::wsdl::bindings::soap::appendFaultDetails $soapFault Client "Invalid Document"  "[::xml::instance::printErrors $XMLdocumentElement 5]"

            break
        }

        log Debug "HandleRequest: invoking '[set ::wsdb::operations::${portTypeNamespace}::${operation}::invoke]'"
        # Document is valid...Invoke command
        set responseMessage [InvokeOperation $operation $XMLdocumentElement ${requestNamespace}::output]
        # Set default namespace on message
        ::xml::element::setAttribute "$responseMessage" "xmlns" "$targetNamespace"

        # Create response document
        set soapBody [::wsdl::bindings::soap::createBody ${requestNamespace}::response ]

        # append a reference to responseMessage to SOAP Body
        ::xml::element::appendRef $soapBody $responseMessage

        set code 200
        break
    }

    # Going to return a list {status content-type headersList document}
    return [list $code "text/xml" {} [::xml::document::print ${requestNamespace}::response]]
    }


proc ::wsdb::bindings::openacsSoapBind::InvokeOperation {
    operation
    documentElement
    outputReference
} {
    variable portTypeNamespace
    return [[set ::wsdb::operations::${portTypeNamespace}::${operation}::invoke]  $documentElement $outputReference]
    }


proc ::wsdb::bindings::openacsSoapBind::log {
    level
    args
} {

    variable Method

    switch -exact -- $Method {
        "puts" {
            puts stderr "$level TWS:[join $args " "]"
        }
        "ns" {
            ns_log $level "TWS:[join $args " "]"
        }
    }
}


proc ::wsdb::bindings::openacsSoapBind::ValidateInputMessage {
    operation
    documentElement
} {
    variable portTypeNamespace
    set inputMessageType [::wsdl::operations::getInputMessageType $portTypeNamespace $operation]

    return [[set ::wsdb::elements::${portTypeNamespace}::${inputMessageType}::validate]  $documentElement]
    }