Workflow Name: amset2createstore#

Constituent Services: InitAdminWsdl; AuthenticationService; RepositoryService#

Workflow Description#

This workflow illustrates the use of a security ticket obtained from the AuthenticationService to create a new store or workspace using the createStore method of the RepositoryService. This is an example of organising the SOAP security header inside the WSDL.

Technical Notes#

Platform: GlassFishESB V2.1 nightly build 10 June 2009, NetBeans IDE 6.5.1 Java: 1.6.0_10; Java HotSpot(TM) Client VM 11.0-b15 System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb).

Alfresco Labs 3.1 running on remote server, 64-bit Java 1.6.0_13, Tomcat 5 on Red Hat Enterprise Linux 5.

The Process#

Figure 2.1. CreateStore.bpel NetBeans process diagram


The BPEL Script#

The workflow scripts will be available from the AMSeT SourceForge repository so they won't all be reproduced here on the wiki. This first one might help those interested in the NetBeans BPEL Designer to see how the process diagram relates to the BPEL script.

Code snippet 2.1. CreateStore.bpel

<process
    name="CreateStore1Bpel"
    targetNamespace="http://taorluath.org/bpel/GetAuth1Bpel/CreateStore1Bpel"
    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:sxt="http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/Trace" 
    xmlns:sxed="http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/Editor"
    xmlns:tns="http://taorluath.org/bpel/GetAuth1Bpel/CreateStore1Bpel" xmlns:ns0="http://enterprise.netbeans.org/bpel/InitAdminWsdlWrapper" xmlns:ns1="http://enterprise.netbeans.org/bpel/AuthenticationServiceWrapper" xmlns:ns2="http://enterprise.netbeans.org/bpel/AdministrationServiceWrapper" xmlns:ns3="http://enterprise.netbeans.org/bpel/DateTimeServiceWrapper" xmlns:ns4="http://enterprise.netbeans.org/bpel/RepositoryServiceWrapper" xmlns:ns5="http://www.alfresco.org/ws/service/authentication/1.0" xmlns:ns6="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns7="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:sxxf="http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/XPathFunctions" xmlns:ns8="http://www.alfresco.org/ws/service/repository/1.0" xmlns:ns9="http://www.alfresco.org/ws/model/content/1.0" xmlns:sxed2="http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/Editor2">
    <import namespace="http://enterprise.netbeans.org/bpel/InitAdminWsdlWrapper" location="InitAdminWsdlWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://j2ee.netbeans.org/wsdl/AdminServiceBpel1/InitAdminWsdl" location="InitAdminWsdl.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://enterprise.netbeans.org/bpel/AuthenticationServiceWrapper" location="AuthenticationServiceWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://www.alfresco.org/ws/service/authentication/1.0" location="AuthenticationService.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://enterprise.netbeans.org/bpel/DateTimeServiceWrapper" location="DateTimeServiceWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://datetime.util.ws.taorluath.org/" location="DateTimeService.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://enterprise.netbeans.org/bpel/RepositoryServiceWrapper" location="RepositoryServiceWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <import namespace="http://www.alfresco.org/ws/service/repository/1.0" location="RepositoryService.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <partnerLinks>
        <partnerLink name="RepositoryPL" partnerLinkType="ns4:RepositoryServiceSoapPortLinkType" partnerRole="RepositoryServiceSoapPortRole"/>
        <partnerLink name="DateTimePL" partnerLinkType="ns3:DateTimeLinkType" partnerRole="DateTimeRole"/>
        <partnerLink name="AuthenticationPL" partnerLinkType="ns1:AuthenticationServiceSoapPortLinkType" partnerRole="AuthenticationServiceSoapPortRole"/>
        <partnerLink name="InitAdminPL" partnerLinkType="ns0:AdministrationServiceSoapPortLinkType" myRole="InitRole"/>
    </partnerLinks>
    <variables>
        <variable name="EndSessionOut" messageType="ns5:endSessionResponse"/>
        <variable name="EndSessionIn" messageType="ns5:endSessionRequest"/>
        <variable name="CreateStoreOut" xmlns:rep="http://www.alfresco.org/ws/service/repository/1.0" messageType="rep:createStoreResponse"/>
        <variable name="CreateStoreIn" xmlns:rep="http://www.alfresco.org/ws/service/repository/1.0" messageType="rep:createStoreRequest"/>
        <variable name="IncrementCurrentDateTimeOut" xmlns:tns="http://datetime.util.ws.taorluath.org/" messageType="tns:incrementCurrentDateTimeResponse"/>
        <variable name="IncrementCurrentDateTimeIn" xmlns:tns="http://datetime.util.ws.taorluath.org/" messageType="tns:incrementCurrentDateTime"/>
        <variable name="StartSessionOut" xmlns:auth="http://www.alfresco.org/ws/service/authentication/1.0" messageType="auth:startSessionResponse"/>
        <variable name="StartSessionIn" xmlns:auth="http://www.alfresco.org/ws/service/authentication/1.0" messageType="auth:startSessionRequest"/>
        <variable name="InitAdminWsdlOperationOut" xmlns:tns="http://j2ee.netbeans.org/wsdl/AdminServiceBpel1/InitAdminWsdl" messageType="tns:InitAdminWsdlOperationResponse"/>
        <variable name="InitAdminWsdlOperationIn" xmlns:tns="http://j2ee.netbeans.org/wsdl/AdminServiceBpel1/InitAdminWsdl" messageType="tns:InitAdminWsdlOperationRequest"/>
    </variables>
    <sequence>
        <receive name="ReceiveInit" createInstance="yes" partnerLink="InitAdminPL" operation="InitAdminWsdlOperation" xmlns:tns="http://j2ee.netbeans.org/wsdl/AdminServiceBpel1/InitAdminWsdl" portType="tns:InitAdminWsdlPortType" variable="InitAdminWsdlOperationIn">
            <documentation>This is a service owned by the BPEL process that receives initialisation data in a SOAP message.

In this case the initialisation data consists of the username and password for the Alfresco Authentication service.</documentation>
        </receive>
        <assign name="AssignInitData">
            <copy>
                <from variable="InitAdminWsdlOperationIn" part="adminusername"/>
                <to>$StartSessionIn.parameters/ns5:username</to>
            </copy>
            <copy>
                <from variable="InitAdminWsdlOperationIn" part="password"/>
                <to>$StartSessionIn.parameters/ns5:password</to>
            </copy>
            <copy>
                <from variable="InitAdminWsdlOperationIn" part="scheme"/>
                <to>$CreateStoreIn.parameters/ns8:scheme</to>
            </copy>
            <copy>
                <from variable="InitAdminWsdlOperationIn" part="address"/>
                <to>$CreateStoreIn.parameters/ns8:address</to>
            </copy>
        </assign>
        <invoke name="InvokeStartSession" partnerLink="AuthenticationPL" operation="startSession" xmlns:auth="http://www.alfresco.org/ws/service/authentication/1.0" portType="auth:AuthenticationServiceSoapPort" inputVariable="StartSessionIn" outputVariable="StartSessionOut"/>
        <assign name="AssignValidityPeriod">
            <copy>
                <from>4</from>
                <to>$IncrementCurrentDateTimeIn.parameters/timeIntervalMinutes</to>
            </copy>
        </assign>
        <invoke name="InvokeIncrementDateTime" partnerLink="DateTimePL" operation="incrementCurrentDateTime" xmlns:tns="http://datetime.util.ws.taorluath.org/" portType="tns:DateTime" inputVariable="IncrementCurrentDateTimeIn" outputVariable="IncrementCurrentDateTimeOut"/>
        <assign name="AssignStoreDetails">
            <copy>
                <from>$StartSessionOut.parameters/ns5:startSessionReturn/ns5:username</from>
                <to>$CreateStoreIn.securityHeader/ns6:UsernameToken/ns6:Username</to>
            </copy>
            <copy>
                <from>$StartSessionOut.parameters/ns5:startSessionReturn/ns5:ticket</from>
                <to>$CreateStoreIn.securityHeader/ns6:UsernameToken/ns6:Password</to>
            </copy>
            <copy>
                <from>$IncrementCurrentDateTimeOut.parameters/return</from>
                <to>$CreateStoreIn.securityHeader/ns7:Timestamp/ns7:Expires</to>
            </copy>
            <copy>
                <from>sxxf:current-dateTime()</from>
                <to>$CreateStoreIn.securityHeader/ns7:Timestamp/ns7:Created</to>
            </copy>
            <copy>
                <from>'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'</from>
                <to>$CreateStoreIn.securityHeader/ns6:UsernameToken/ns6:Password/@Type</to>
            </copy>
        </assign>
        <invoke name="InvokeCreateStore" partnerLink="RepositoryPL" operation="createStore" xmlns:rep="http://www.alfresco.org/ws/service/repository/1.0" portType="rep:RepositoryServiceSoapPort" inputVariable="CreateStoreIn" outputVariable="CreateStoreOut"/>
        <assign name="AssignEndSession">
            <copy>
                <from>$CreateStoreOut.parameters/ns8:createStoreReturn/ns9:scheme</from>
                <to variable="InitAdminWsdlOperationOut" part="propertyName"/>
            </copy>
            <copy>
                <from>$CreateStoreOut.parameters/ns8:createStoreReturn/ns9:address</from>
                <to variable="InitAdminWsdlOperationOut" part="value"/>
            </copy>
            <copy>
                <from>$StartSessionOut.parameters/ns5:startSessionReturn/ns5:ticket</from>
                <to>$EndSessionIn.parameters/ns5:ticket</to>
            </copy>
            <copy>
                <from>$StartSessionIn.parameters/ns5:username</from>
                <to variable="InitAdminWsdlOperationOut" part="user"/>
            </copy>
        </assign>
        <invoke name="InvokeEndSession" partnerLink="AuthenticationPL" operation="endSession" portType="ns5:AuthenticationServiceSoapPort" inputVariable="EndSessionIn" outputVariable="EndSessionOut"/>
        <reply name="ReplyInit" partnerLink="InitAdminPL" operation="InitAdminWsdlOperation" xmlns:tns="http://j2ee.netbeans.org/wsdl/AdminServiceBpel1/InitAdminWsdl" portType="tns:InitAdminWsdlPortType" variable="InitAdminWsdlOperationOut"/>
    </sequence>
</process>

Input/Output#

Code snippet 2.2. CreateStore SOAP Request

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header>
        <Security
            xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:msgns="http://www.alfresco.org/ws/service/repository/1.0">
            <ns7:Timestamp xmlns:ns7="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                <ns7:Created>2009-06-11T18:13:15.82+00:00</ns7:Created>
                <ns7:Expires>2009-06-11T18:17:15.00+00:00</ns7:Expires>
            </ns7:Timestamp>
            <UsernameToken>
                <Username>admin</Username>
                <ns0:Password
                    Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"
                    xmlns="http://www.alfresco.org/ws/service/authentication/1.0"
                    xmlns:msgns="http://www.alfresco.org/ws/service/authentication/1.0"
                    xmlns:ns0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns1="http://www.alfresco.org/ws/service/repository/1.0">TICKET_0fe92e1046afcd1c7f2b1b4aa81660e0ef348e91</ns0:Password>
            </UsernameToken>
        </Security>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <createStore
            xmlns="http://www.alfresco.org/ws/service/repository/1.0" xmlns:msgns="http://www.alfresco.org/ws/service/repository/1.0">
            <msgns:scheme>workspace</msgns:scheme>
            <msgns:address>kryptonite</msgns:address>
        </createStore>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The RepositoryService WSDL#

The code snippet below shows how the SOAP security header can be created through the WSDL.

Code snippet 2.2. RepositoryService WSDL

<wsdl:definitions name="repository-service" targetNamespace="http://www.alfresco.org/ws/service/repository/1.0" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:cml="http://www.alfresco.org/ws/cml/1.0" xmlns:cms="http://www.alfresco.org/ws/model/content/1.0" xmlns:headers="http://www.alfresco.org/ws/headers/1.0" xmlns:rep="http://www.alfresco.org/ws/service/repository/1.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" >

   <!-- ************************************** -->

   <!-- Copyright Alfresco Software, Inc. 2005 -->

   <!-- ************************************** -->


    <wsdl:types>

        <schema elementFormDefault="qualified" targetNamespace="http://www.alfresco.org/ws/service/repository/1.0" xmlns="http://www.w3.org/2001/XMLSchema" >

            <xsd:import namespace="http://www.alfresco.org/ws/headers/1.0" schemaLocation="headers.xsd"/>
            <xsd:import namespace="http://www.alfresco.org/ws/cml/1.0" schemaLocation="cml.xsd"/>
            <xsd:import namespace="http://www.alfresco.org/ws/model/content/1.0" schemaLocation="types.xsd"/>
            <xsd:import schemaLocation="oasis-200401-wss-wssecurity-secext-1.0.xsd" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
            <element name="createStore">
         	    <complexType>
                    <sequence>
                        <element name="scheme" type="xsd:string"/>
                        <element name="address" type="xsd:string"/>
                    </sequence>
                </complexType>
            </element>

            <element name="createStoreResponse">
                <complexType>
                    <sequence>
                        <element name="createStoreReturn" type="cms:Store"/>
                    </sequence>
                </complexType>
            </element>
         
            ...
            ...
            ...

        </schema>

    </wsdl:types>


    <wsdl:message name="Headers">

        <wsdl:documentation>Defines the SOAP headers used by this service.</wsdl:documentation>

        <wsdl:part element="rep:QueryConfiguration" name="QueryConfiguration"/>

    </wsdl:message>

   
    <wsdl:message name="createStoreRequest">
    
        <!-- The Security element in the createStoreRequest is defined in the oasis-200401-wss-wssecurity-secext-1.0.xsd schema.-->

        <wsdl:part element="rep:createStore" name="parameters"/>
        <wsdl:part element="wsse:Security" name="securityHeader"/>

    </wsdl:message>


    <wsdl:message name="createStoreResponse">

        <wsdl:part element="rep:createStoreResponse" name="parameters"/>

    </wsdl:message>

   ...
   ...
   ...
   
    <wsdl:portType name="RepositoryServiceSoapPort">

        <wsdl:operation name="createStore">

            <wsdl:documentation>Creates a new repository store.</wsdl:documentation>

            <wsdl:input message="rep:createStoreRequest" name="createStoreRequest"/>

            <wsdl:output message="rep:createStoreResponse" name="createStoreResponse"/>

            <wsdl:fault message="rep:RepositoryFault" name="RepositoryFault"/>

        </wsdl:operation>

        ...
        ...
        ...
        
    </wsdl:portType>

   
    <wsdl:binding name="RepositoryServiceSoapBinding" type="rep:RepositoryServiceSoapPort">

        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

        <wsdl:operation name="createStore">

            <wsdlsoap:operation soapAction="http://www.alfresco.org/ws/service/repository/1.0/createStore"/>

            <wsdl:input name="createStoreRequest">
            
                <!-- The Security element is placed in the SOAP header element.-->

                <wsdlsoap:header message="rep:createStoreRequest" part="securityHeader" use="literal"/>
                <wsdlsoap:body parts="parameters" use="literal"/>

            </wsdl:input>

            <wsdl:output name="createStoreResponse">

                <wsdlsoap:body use="literal"/>

            </wsdl:output>

            <wsdl:fault name="RepositoryFault">

                <wsdlsoap:fault name="RepositoryFault" namespace="http://www.alfresco.org/ws/service/repository/1.0" use="literal"/>

            </wsdl:fault>

        </wsdl:operation>

        ...
        ...
        ...

    </wsdl:binding>


    <wsdl:service name="RepositoryService">

        <wsdl:documentation>Provides read and write operations against a repository.  </wsdl:documentation>

        <wsdl:port binding="rep:RepositoryServiceSoapBinding" name="RepositoryService">

            <wsdlsoap:address location="http://localhost:5050/alfresco/api/RepositoryService"/>

        </wsdl:port>

    </wsdl:service>

   
</wsdl:definitions>

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
png
amset2createstore.png 70.8 kB 1 11-Jun-2009 19:20 clayton
« This page (revision-) was last changed on 11-Jun-2009 20:10 by clayton