cancel
Showing results for 
Search instead for 
Did you mean: 

createFolder fails with 'Type Id property required'

safroe
Champ in-the-making
Champ in-the-making
Hi there,

I am trying to create a folder using the webservice bindings (generated by JAX-WS RI 2.1.6 and JDK 6) and I always get this error:

Exception in thread "main" org.oasis_open.docs.ns.cmis.ws._200908.CmisException: Type Id property required
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
   at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:130)
   at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
   at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
   at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
   at $Proxy41.createFolder(Unknown Source)
   at com.globolog.teamup.uag.client.CMISClient.main(CMISClient.java:61)

The soap call looks like this:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Header>
      <wsse:Security
         xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
         S:mustUnderstand="1">
         <wsu:Timestamp
            xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsu:Created>2010-07-28T12:13:58.881Z</wsu:Created>
            <wsu:Expires>2010-07-28T12:22:18.881Z</wsu:Expires>
         </wsu:Timestamp>
         <wsse:UsernameToken>
            <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">admin</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </S:Header>
   <S:Body>
      <createFolder xmlns="http://docs.oasis-open.org/ns/cmis/messaging/200908/"
         xmlns:ns2="http://docs.oasis-open.org/ns/cmis/core/200908/"
         xmlns:ns3="http://www.alfresco.org">
         <repositoryId>1fe8cf3a-58c3-40ba-916a-993c863c05a4</repositoryId>
         <properties>
            <ns2:cmisPropertyId propertyDefinitionId="cmis:objectTypeId">
               <ns2:value>cmis:folder</ns2:value>
            </ns2:cmisPropertyId>
         </properties>
         <folderId>workspace://SpacesStore/a869c344-f5cb-4b9d-bf42-2c74de9a44c3
         </folderId>
      </createFolder>
   </S:Body>
</S:Envelope>

Obtaining a repository id works fine (including authentication), however creating a folder or document does not. I've searched a lot and found a bug report in JIRA (http://issues.alfresco.com/jira/browse/ALF-2637), but this should be already fixed in 3.3g. Tested against cmis.alfresco.com and my local svn build -> still does not work.

My code:

ApplicationContext context = new ClassPathXmlApplicationContext();
      XmlBeanFactory factory = new XmlBeanFactory(context.getResource(APPLICATION_CONTEXT_XML));
      WebServiceFactory wsFactory = (WebServiceFactory) factory.getBean("webServiceFactory");
      
      RepositoryServicePort repositoryServicePort = wsFactory.getRepositoryServicePort();
      
      List<CmisRepositoryEntryType> repositoryList = repositoryServicePort.getRepositories(null);
      String repositoryId = repositoryList.get(0).getRepositoryId();
      CmisRepositoryInfoType repositoryInfo = repositoryServicePort.getRepositoryInfo(repositoryId, null);
      
      ObjectServicePort objectServicePort = wsFactory.getObjectServicePort();
      ObjectFactory objectFactory = new ObjectFactory();
      
      CmisPropertiesType properties = objectFactory.createCmisPropertiesType();
      List<Object> propertyList = properties.getAny();
      CmisPropertyId propertyId = objectFactory.createCmisPropertyId();
      propertyId.setPropertyDefinitionId("cmis:objectTypeId");
      propertyId.getValue().add("cmis:folder");
      propertyList.add(propertyId);
      
      Holder<String> idHolder = new Holder<String>();
      objectServicePort.createFolder(repositoryId, properties, repositoryInfo.getRootFolderId(), null, null, null, null, idHolder);

Do you have any clue how to solve this? Many thanks in advance…
1 REPLY 1

safroe
Champ in-the-making
Champ in-the-making
Solved: JAX-WS does not properly generate the CMIS types. I had to add an @XmlRootElement(name = "xxx") annotation manually, i.e. @XmlRootElement(name="propertiesType") for the type CmisPropertiesType.