cancel
Showing results for 
Search instead for 
Did you mean: 

Using the Web services interface

ucorda
Champ in-the-making
Champ in-the-making
I have been trying to use the Web services interface, but I have encountered a few difficulties

1) There is a mismatch between the implementation status as defined at http://wiki.alfresco.com/wiki/Alfresco_Draft_Implementation_Status and the actual operations made available via the WSDL files. For example, RepositoryService.wsdl declares 4 operations, while the implementation status document lists more than 4 and at the same time does not list getRepositories (which is included in the wsdl file)

2) I tried the getRepositories operation, by sending out this SOAP message:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:q0="http://www.cmis.org/2008/05" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <q0:getRepositories/>
  </soapenv:Body>
</soapenv:Envelope>

but I receive the following SOAP fault response:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsseSmiley Frustratedecurity xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-23366617">
        <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2008-09-16T23:24:41.031Z</wsu:Created>
        <wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2008-09-16T23:29:41.031Z</wsu:Expires>
      </wsu:Timestamp>
    </wsseSmiley Frustratedecurity>
  </soap:Header>
  <soap:Body>
    <soap:Fault>
      <faultcode xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">ns1:InvalidSecurity</faultcode>
      <faultstring>An error was discovered processing the &lt;wsseSmiley Frustratedecurity&gt; header</faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

(not sure where the wsse header is coming from)

3) I tried to use getRepositoryInfo, which requires the input parameter repositoryID, but I have no idea where to get that information from. I set up my Alfresco server following exactly the Alfresco Tutorial PDF document. How do I get a repositoryID using the Web GUI?
15 REPLIES 15

ucorda
Champ in-the-making
Champ in-the-making
Thinking a little more about issue 2, it looks like your CMIS implementation for the WS interface expects a WS-Security header in the SOAP request.

If that is the case, it would really help if you guys could provide some documentation in this area, including which security tokens to use, examples, etc. This is particularly necessary given the fact that the CMIS spec does not address security and leaves that aspect to the various implementations.

davidc
Star Contributor
Star Contributor
Hi,

If you checkout the Labs from svn HEAD, you'll find a Java CMIS Web Service client.

It's located in projects/remote-api/source/sample/JavaCmisTest.

There's the source code and a build script for creating a stand-alone client.

ucorda
Champ in-the-making
Champ in-the-making
Thank you, David. That works fine.

Of course, I would like to get the same results with my own WS client. This is what I send out from my WS client:

POST /alfresco/cmis/RepositoryService HTTP/1.1
Host: localhost
Accept: application/soap+xml,multipart/related,text/*
User-Agent: IBM WebServices/1.0
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Connection: Keep-Alive
Content-Type: text/xml; charset=utf-8
Content-Length: 747
Date: Fri, 19 Sep 2008 21:17:05 GMT

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header>
      <wsseSmiley Frustratedecurity soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsse:UsernameToken>
            <wsse:Username>admin</wsse:Username>
            <wsseSmiley Tongueassword Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</wsseSmiley Tongueassword>
         </wsse:UsernameToken>
      </wsseSmiley Frustratedecurity>
   </soapenv:Header>
   <soapenv:Body>
      <p606:getRepositories xmlnsSmiley Tongue606="http://www.cmis.org/2008/05'/>
   </soapenv:Body>
</soapenv:Envelope>

In response, I get this SOAP fault: "An error was discovered processing the <wsseSmiley Frustratedecurity> header".

Is my SOAP request message incorrect? If it is, could you please show me what the correct request should look like?

Thank you,
Ugo Corda

davidc
Star Contributor
Star Contributor
The first message sent by the sample WS client is…

Encoding: UTF-8
Headers: {content-length=[1737], connection=[keep-alive], cache-control=[no-cache], host=[localhost:8080], user-agent=[Java/1.5.0_13], pragma=[no-cache], content-type=[text/xml; charset=UTF-8], accept=[*], soapaction=[""]}
Messages:
Message:

Payload:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soap:mustUnderstand="1"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-2802048"><wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2008-09-23T09:40:08.828Z</wsu:Created><wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2008-09-23T09:45:08.828Z</wsu:Expires></wsu:Timestamp><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" wsu:Id="UsernameToken-826697"><wsse:Username xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">admin</wsse:Username><wsse:Password xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">EPno7gYsqvt3H84BUfY/rJkPHuU=</wsse:Password><wsse:Nonce xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">mu6wI6ib1CNia+6mBWGFsA==</wsse:Nonce><wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2008-09-23T09:40:08.824Z</wsu:Created></wsse:UsernameToken></wsse:Security></soap:Header><soap:Body><ns1:getRepositories xmlns:ns1="http://www.cmis.org/2008/05" /></soap:Body></soap:Envelope>

The response is…

Encoding: UTF-8
Headers: {}
Messages:
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-10854270"><wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2008-09-23T09:40:09.384Z</wsu:Created><wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2008-09-23T09:45:09.384Z</wsu:Expires></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><ns1:getRepositoriesResponse xmlns:ns1="http://www.cmis.org/2008/05"><ns1:repository><ns1:repositoryID>&lt;Unknown</ns1:repositoryID><ns1:repositoryName>Main Repository</ns1:repositoryName></ns1:repository></ns1:getRepositoriesResponse></soap:Body></soap:Envelope>

It turned out to be more difficult than I thought to log this information.  An update on HEAD makes this easier.  I suggest updating at which point you can set the following log4j.properties value to trace in/out messages:

log4j.logger.org.apache.cxf=info

onewnan
Champ in-the-making
Champ in-the-making
Nice, I missed this code when I first installed the project.  FYI to compile and debug JavaCmisTest under eclipse as it's own project I had to download a few libs:

opensaml-1.0.1.jar
velocity-1.4.jar
velocity-dep-1.4.jar

ucorda
Champ in-the-making
Champ in-the-making
Thank you, David. Now I see what the problem is. You guys expect a WSS UserName token which uses the PasswordDigest type of password, while I was using the PasswordText type.

I am creating the client using the IBM WebSphere/Rational set of tools, and they only support the PasswordText type of password.

I strongly suggest you guys also accept the PasswordType token, otherwise the basic reason for using the Web services interface, i.e. interoperability with various clients, would be nullified.

Thank you,
Ugo

ucorda
Champ in-the-making
Champ in-the-making
Sorry, I actually meant "I strongly suggest you guys also accept the PasswordText type of username token".

davidc
Star Contributor
Star Contributor
Thanks for the suggestion.  We'll add that capability, hopefully, in the short term.

onewnan
Champ in-the-making
Champ in-the-making
Earlier in the thread the question was asked but not answered, how do we get the repositoryId to use as input for CMIS operations?  It would seem we could get the information something like this


        GetRepositoryInfo parameteers = new GetRepositoryInfo();
        List<CmisRepositoryEntryType> entries = servicesPort.getRepositories();  // RepositoryServicePort
        defaultRepositoryId = entries.get(0).getRepositoryID();
        defaultRepositoryName = entries.get(0).getRepositoryName();
        parameteers.setRepositoryId(defaultRepositoryId);

However, when using the resulting  defaultRepositoryId or defaultRepositoryName as the repositoryId input to getProperties, the operation returns a SOAP fault indicating invalid repository ID.  Where can we locate the correct ID for getProperties?