Web Service Samples for WSS / WSSE

cancel
Showing results for 
Search instead for 
Did you mean: 

Web Service Samples for WSS / WSSE

resplin
Intermediate
0 0 3,052

{{Obsolete}}

Please note that this API has been superceded by CMIS (specifically, the CMIS SOAP binding).  It's use is no longer recommended. This functionality was removed from Alfresco in 5.0.b.


Constructing the WSSE headers



<process name='alfresco
...
xmlns:ns4='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
xmlns:ns5='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>

<variables>
  <variable name='wsseHeader' element='ns4:Security'/>
  <variable name='wstimestamp' element='ns5:Timestamp'/>
</variables>

<sequence name='main'>
    <assign name='makeWSSEHeaders'>
      <copy>
        <from expression='xp20:current-dateTime()'/>
        <to variable='wstimestamp' query='/ns5:Timestamp/ns5:Created'/>
      </copy>
      <copy>
        <from expression='xp20:current-dateTime()'/>
        <to variable='wstimestamp' query='/ns5:Timestamp/ns5:Expires'/>
      </copy>
      <bpelx:append>
        <bpelx:from variable='wstimestamp' query='/ns5:Timestamp'/>
        <bpelx:to variable='wsseHeader' query='/ns4:Security'/>
      </bpelx:append>
      <bpelx:append>
        <bpelx:from>
          <wsse:UsernameToken xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
                              xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
            <wsse:Username>admin</wsse:Username>
            <wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'/>
          </wsse:UsernameToken>
        </bpelx:from>
        <bpelx:to variable='wsseHeader' query='/ns4:Security'/>
      </bpelx:append>
      <bpelx:append>
        <bpelx:from expression='ora:getNodeValue(bpws:getVariableData('startSession_Output','parameters','/ns1:startSessionResponse/ns1:startSessionReturn/ns1:ticket'))'/>
        <bpelx:to variable='wsseHeader' query='/ns4:Security/ns4:UsernameToken/ns4:Password'/>
      </bpelx:append>
    </assign>
    <invoke name='repo' partnerLink='repository-service' portType='ns6:RepositoryServiceSoapPort' operation='query' inputVariable='repo_query_InputVariable'
            outputVariable='repo_query_OutputVariable' bpelx:inputHeaderVariable='wsseHeader'/>

  </sequence>
</process>

Starting a Session



<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<env:Body>
  <startSession xmlns='http://www.alfresco.org/ws/service/authentication/1.0'>
   <username>admin</username>
   <password>admin</password>
  </startSession>
</env:Body>
</env:Envelope>

Calling RepositoryService using the WSSE headers



<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<env:Header>
  <Security xmlns='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
   <Timestamp xmlns='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' ans1:Id='' xmlns:ans1='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' xmlns:ns1='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
    <ans1:Created>2007-08-01T12:13:37+01:00</ans1:Created>
    <ans1:Expires>2007-08-01T12:13:37+01:00</ans1:Expires>
   </Timestamp>
   <UsernameToken xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
    <Username>admin</Username>
    <Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>TICKET_de9b08df-4017-11dc-8ec5-41f7efb0a5f7</Password>
   </UsernameToken>
  </Security>
</env:Header>
<env:Body>
  <query xmlns='http://www.alfresco.org/ws/service/repository/1.0' xmlns:ns3='http://www.alfresco.org/ws/model/content/1.0'>
   <store>
    <ns1:scheme xmlns:ns1='http://www.alfresco.org/ws/model/content/1.0'>workspace</ns1:scheme>
    <ns2:address xmlns:ns2='http://www.alfresco.org/ws/model/content/1.0'>SpacesStore</ns2:address>
   </store>
   <query>
    <ns3:language xmlns:ns3='http://www.alfresco.org/ws/model/content/1.0'>lucene</ns3:language>
    <ns4:statement xmlns:ns4='http://www.alfresco.org/ws/model/content/1.0'>@cm\:name:'Alfresco-Tutorial.pdf'</ns4:statement>
   </query>
   <includeMetaData>true</includeMetaData>
  </query>
</env:Body>
</env:Envelope>

Use ContentService with Lucene Query with WSSE headers



<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<env:Header>
  <Security xmlns='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
   <Timestamp xmlns='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' ans1:Id='' xmlns:ans1='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' xmlns:ns1='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
    <ans1:Created>2007-08-01T12:13:37+01:00</ans1:Created>
    <ans1:Expires>2007-08-01T12:20:37+01:00</ans1:Expires>
   </Timestamp>
   <UsernameToken xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
    <Username>admin</Username>
    <Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>TICKET_de9b08df-4017-11dc-8ec5-41f7efb0a5f7</Password>
   </UsernameToken>
  </Security>
</env:Header>
<env:Body>
  <read xmlns='http://www.alfresco.org/ws/service/content/1.0'>
   <items>
    <store xmlns='http://www.alfresco.org/ws/model/content/1.0'>
     <scheme>workspace</scheme>
     <address>SpacesStore</address>
    </store>
    <query xmlns='http://www.alfresco.org/ws/model/content/1.0'>
     <language>lucene</language>
     <statement>@cm\:name:'Alfresco-Tutorial.pdf'</statement>
    </query>
   </items>
   <property>{http://www.alfresco.org/model/content/1.0}content</property>
  </read>
</env:Body>
</env:Envelope>


Use ContentService with uuid with WSSE headers



<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<env:Header>
  <Security xmlns='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
   <Timestamp xmlns='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' ans1:Id='' xmlns:ans1='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' xmlns:ns1='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
    <ans1:Created>2007-08-01T12:00:28+01:00</ans1:Created>
    <ans1:Expires>2007-08-01T12:05:28+01:00</ans1:Expires>
   </Timestamp>
   <UsernameToken xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
    <Username>admin</Username>
    <Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>TICKET_088d539c-4016-11dc-8ec5-41f7efb0a5f7</Password>
   </UsernameToken>
  </Security>
</env:Header>
<env:Body>
  <read xmlns='http://www.alfresco.org/ws/service/content/1.0'>
   <items>
    <nodes xmlns='http://www.alfresco.org/ws/model/content/1.0'>
     <store>
      <scheme>workspace</scheme>
      <address>SpacesStore</address>
     </store>
     <uuid>635c49e6-0af5-11dc-9bc5-2ddbdefb608b</uuid>
    </nodes>
   </items>
   <property>{http://www.alfresco.org/model/content/1.0}content</property>
  </read>
</env:Body>
</env:Envelope>

Use ContentService with path with WSSE headers



<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<env:Header>
  <Security xmlns='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
   <Timestamp xmlns='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' ans1:Id='' xmlns:ans1='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' xmlns:ns1='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
    <ans1:Created>2007-08-01T12:00:28+01:00</ans1:Created>
    <ans1:Expires>2007-08-01T12:05:28+01:00</ans1:Expires>
   </Timestamp>
   <UsernameToken xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
    <Username>admin</Username>
    <Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>TICKET_088d539c-4016-11dc-8ec5-41f7efb0a5f7</Password>
   </UsernameToken>
  </Security>
</env:Header>
<env:Body>
  <read xmlns='http://www.alfresco.org/ws/service/content/1.0'>
   <items>
    <nodes xmlns='http://www.alfresco.org/ws/model/content/1.0'>
     <store>
      <scheme>workspace</scheme>
      <address>SpacesStore</address>
     </store>
     <path>/app:company_home/app:guest_home/cm:Alfresco-Tutorial.pdf</path>
    </nodes>
   </items>
   <property>{http://www.alfresco.org/model/content/1.0}content</property>
  </read>
</env:Body>
</env:Envelope>