You are here

CS : Adding New Webservices

Submitted by admin on Mon, 09/07/2009 - 11:05

Forums:

We use Sakai - and if you know what you're doing (and sometimes even if you don't) you can add new SOAP calls, enabling you to write scripts to manipulate the system, and run maintenience.

There are a couple APIs that are exposed in Luminis via SOAP, the Targeted Announcement API comes to mind, simply because I've used it.

Has anyone use any of the other APIs, and/or created new SOAP calls ?

I would LOVE some user APIs - sililar to -

cptool list user xxxxx -a

cptool set user xxxxx yyyyy='zzzzz'

cptool list sessions (-c)

extensible services like would make manageing the system much more enjoyable.

thoughts ?

 -Jon

 

Luminis Version:

What's the Targeted Announcement API and how can I find some good examples of it in use and some technical documentation on how to "get at it" ?

Jim,

In my experience, documentation on this subject is very limited.

One of our ColdFusion developers wrote a CF component that publishes targeted announcements using the SOAP API.  He allowed me to share his code:

<cfcomponent>
    <cffunction name="fLumTAAPI" access="public" returntype="any">
        <cfargument name="LumWSDL" type="string" required="yes">
        <cfargument name="mSubject" type="string" required="yes">
        <cfargument name="mBody" type="string" required="yes">
        <cfargument name="Recipients" type="array" required="yes">
        <cfargument name="Expiration" type="date" required="no">
        <cfargument name="username" type="string" required="yes">
        <cfargument name="password" type="string" required="yes">
       
       
        <cfif isDefined('arguments.Expiration')>
            <cfset dTime = #arguments.Expiration#>
            <cfset xmlTime = dateformat(dTime, 'yyyy-mm-dd') & 'T' & timeformat(dTime, 'HH:mm:ss')>
            <!---From CFC - <cfdump var="#xmlTime#">--->
        </cfif>
       
        
            <cfsavecontent variable="localscope.soapRequest">
                <?xml version="1.0" encoding="UTF-8"?>
                <cfoutput>
                    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:pipeline.sct.com:webservice:ta:200306:soap" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
                      <soapenv:Header>
                      </soapenv:Header>
                      <soapenv:Body>
                         <urn:sendMessage soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
                            <message xsi:type="urn:NewMessage" xmlns:urn="urn:pipeline.sct.com:webservice:ta:200306:xsd">
                              
                               <recipients xsi:type="urn:ArrayOfRecipient" soapenc:arrayType="urn:Recipient[]">
                                    <cfloop from="1" to="#arraylen(arguments.Recipients)#" index="i">
                                    <Recipient>
                                        <type>#arguments.Recipients[i][1]#<!---USERNAME,ROLE,ACADEMIC_MAJOR---></type>
                                        <value>#arguments.Recipients[i][2]#</value>
                                    </Recipient>
                                    </cfloop>
                                </recipients>
                               <!------>
                               <deliveryAgent xsi:type="urn:DeliveryAgent">PORTAL</deliveryAgent>
                               <subject xsi:type="xsd:string">#arguments.mSubject#</subject>
                               <body xsi:type="xsd:string">#arguments.mBody#</body>
                              
                               <cfif isDefined('arguments.Expiration')><expirationDateTime xsi:type="xsd:dateTime">#xmlTime#</expirationDateTime></cfif>
                            </message>
                         </urn:sendMessage>
                      </soapenv:Body>
                    </soapenv:Envelope>
                </cfoutput>
            </cfsavecontent>
           
            <cfhttp url="#arguments.LumWSDL#" resolveurl="NO" port="80" username="#arguments.username#" password="#arguments.password#" method="post">
                    <cfhttpparam type="header" name="SOAPAction" value="">
                    <cfhttpparam type="header" name="content-type" value="text/xml">
                    <cfhttpparam type="header" name="charset" value="utf-8">
                    <cfhttpparam type="header" name="Content-Length" value="#len(trim(localscope.soapRequest))#">
                    <cfhttpparam type="xml" name="body" value="#trim(localscope.soapRequest)#">
            </cfhttp>
       
       
       
        <!---<cfdump var="#cfhttp.FileContent#">--->
        <cfreturn xmlParse(cfhttp.FileContent)>
   
    </cffunction>
</cfcomponent>

 

This component takes the WSDL address, subject, body and other variables as parameters, generates the SOAP XML and sends it over a http request.  You don't need to do anything to enable this service on the Luminis side except for create an account with admin permissions with which you can submit the SOAP request.  The WSDL file you need to submit the request to is at https://yourLuminisServer.edu/ws/webservice/ta/200306/soap/TargetedAnnou...

I hope this helps.  Let me know if I can clarify/help further.

Vladimir Mollov