cancel
Showing results for 
Search instead for 
Did you mean: 

.NET WCF and createDocument

newtechfool
Champ in-the-making
Champ in-the-making
I am having a problem adding documents to Alfresco using the createDocument method. I am using the public Alfresco 4.x CMIS Content Repository for testing (http://cmis.alfresco.com/)

I can query, view, delete, update etc. I can also add documents using the code below to other CMIS vendor repositories, but with Alfresco I get an error:
Property cmisSmiley SurprisedbjectTypeId must be set!

The following is sample code to reproduce issue:
       Dim ws As New WS_CMIS.ObjectServicePortClient(….)        ws.ClientCredentials.UserName.UserName = "admin"        ws.ClientCredentials.UserName.Password = "admin"        Dim props As New cmisPropertiesType()        Dim propName As New cmisPropertyString        propName.propertyDefinitionId = "cmis:name"        propName.value = New String() {"Test"}        Dim propClass As New cmisPropertyString        propClass.propertyDefinitionId = "cmis:objectTypeId"        propClass.value = New String() {"cmis:document"}        props.Items = New cmisProperty() {propClass, propName}        Dim stream As New cmisContentStreamType()        stream.stream = FileUpload1.FileBytes        stream.mimeType = FileUpload1.PostedFile.ContentType        stream.filename = FileUpload1.FileName        stream.length = FileUpload1.PostedFile.ContentLength        ws.createDocument("371554cd-ac06-40ba-98b8-e6b60275cca7", props, "workspace://SpacesStore/87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1", stream, enumVersioningState.major, Nothing, Nothing, Nothing, Nothing)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I have checked forums, but have not been able to find an answer.
5 REPLIES 5

jpotts
World-Class Innovator
World-Class Innovator
I see you creating the props variable and adding propClass and propName to it, but I don't see where you are passing props to the createDocument method.

Jeff

newtechfool
Champ in-the-making
Champ in-the-making
Sorry I had replaced my variables with literal strings before posting the code, and the "props" parameter had been deleted. I updated the code above to include the props argument that I am passing.

This same code snippet works with an IBM P8 CM system, but fails with Alfesco.

newtechfool
Champ in-the-making
Champ in-the-making
I did a Fiddler trace, and the cmisSmiley SurprisedbjectTypeId value is being passed to Alfresco, but I get the error saying that it is not being passed.

Request:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">  <s:Header>    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">      <u:Timestamp u:Id="_0">        <u:Created>2012-03-28T22:08:03.235Z</u:Created>        <u:Expires>2012-03-28T22:13:03.235Z</u:Expires>      </u:Timestamp>      <o:UsernameToken u:Id="uuid-dec73595-c2fe-47c9-8a82-ccb3e98af4cb-18">        <o:Username>admin</o:Username>        <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</o:Password>      </o:UsernameToken>    </o:Security>  </s:Header>  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">    <createDocument xmlns="http://docs.oasis-open.org/ns/cmis/messaging/200908/">      <repositoryId>371554cd-ac06-40ba-98b8-e6b60275cca7</repositoryId>      <properties>        <propertyString propertyDefinitionId="cmis:objectTypeId" xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/">          <value>cmis:document</value>        </propertyString>        <propertyString propertyDefinitionId="cmis:name" xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/">          <value>HJ Test</value>        </propertyString>      </properties>      <folderId>workspace://SpacesStore/87b2f129-3ad0-4a46-a6ea-05ecbfb54aa1</folderId>      <contentStream>        <length>2338411</length>        <mimeType>application/pdf</mimeType>        <filename>cmis-spec-v1.0.pdf</filename>        <stream>TRUNCATED</stream>      </contentStream>      <versioningState>major</versioningState>      <addACEs xsi:nil="true"/>      <removeACEs xsi:nil="true"/>      <extension xsi:nil="true"/>    </createDocument>  </s:Body></s:Envelope>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Response:
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">  <S: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">        <Created>2012-03-28T22:08:13Z</Created>        <Expires>2012-03-29T22:08:13Z</Expires>      </Timestamp>    </Security>  </S:Header>  <S:Body>    <S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">      <faultcode>S:Server</faultcode>      <faultstring>Property cmis:objectTypeId must be set!</faultstring>      <detail>        <ns2:cmisFault xmlns:ns2="http://docs.oasis-open.org/ns/cmis/messaging/200908/" xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/">          <ns2:type>invalidArgument</ns2:type>          <ns2:code>0</ns2:code>          <ns2:message>Property cmis:objectTypeId must be set!</ns2:message>          <stacktrace:stacktrace xmlns:stacktrace="http://chemistry.apache.org/opencmis/exception" xmlns="http://chemistry.apache.org/opencmis/exception">            org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Property cmis:objectTypeId must be set!            at org.alfresco.opencmis.CMISConnector.getObjectTypeIdProperty(CMISConnector.java:2524)            at org.alfresco.opencmis.AlfrescoCmisService.createDocument(AlfrescoCmisService.java:1198)            at org.apache.chemistry.opencmis.server.support.CmisServiceWrapper.createDocument(CmisServiceWrapper.java:666)            at org.apache.chemistry.opencmis.server.impl.webservices.ObjectService.createDocument(ObjectService.java:79)            at sun.reflect.GeneratedMethodAccessor5324.invoke(Unknown Source)            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)            at java.lang.reflect.Method.invoke(Method.java:597)            at com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:246)            at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)            at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)            at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)            at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598)            at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557)            at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542)            at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439)            at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)            at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:471)            at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)            at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)            at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129)            at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160)            at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75)            at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)            at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)            at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:427)            at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:384)            at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)            at java.lang.Thread.run(Thread.java:662)          </stacktrace:stacktrace>        </ns2:cmisFault>        <ns2:exception xmlns:ns2="http://jax-ws.dev.java.net/" class="org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException" note="To disable this feature, set com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace system property to false">          <message>Property cmis:objectTypeId must be set!</message>          <ns2:stackTrace>            <ns2:frame class="org.apache.chemistry.opencmis.server.impl.webservices.AbstractService" file="AbstractService.java" line="205" method="convertException"/>            <ns2:frame class="org.apache.chemistry.opencmis.server.impl.webservices.ObjectService" file="ObjectService.java" line="89" method="createDocument"/>            <ns2:frame class="sun.reflect.GeneratedMethodAccessor5324" line="unknown" method="invoke"/>            <ns2:frame class="sun.reflect.DelegatingMethodAccessorImpl" file="DelegatingMethodAccessorImpl.java" line="25" method="invoke"/>            <ns2:frame class="java.lang.reflect.Method" file="Method.java" line="597" method="invoke"/>            <ns2:frame class="com.sun.xml.ws.api.server.InstanceResolver$1" file="InstanceResolver.java" line="246" method="invoke"/>            <ns2:frame class="com.sun.xml.ws.server.InvokerTube$2" file="InvokerTube.java" line="146" method="invoke"/>            <ns2:frame class="com.sun.xml.ws.server.sei.EndpointMethodHandler" file="EndpointMethodHandler.java" line="257" method="invoke"/>            <ns2:frame class="com.sun.xml.ws.server.sei.SEIInvokerTube" file="SEIInvokerTube.java" line="93" method="processRequest"/>            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="598" method="__doRun"/>            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="557" method="_doRun"/>            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="542" method="doRun"/>            <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="439" method="runSync"/>            <ns2:frame class="com.sun.xml.ws.server.WSEndpointImpl$2" file="WSEndpointImpl.java" line="243" method="process"/>            <ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit" file="HttpAdapter.java" line="471" method="handle"/>            <ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter" file="HttpAdapter.java" line="244" method="handle"/>            <ns2:frame class="com.sun.xml.ws.transport.http.servlet.ServletAdapter" file="ServletAdapter.java" line="135" method="handle"/>            <ns2:frame class="com.sun.xml.ws.transport.http.servlet.WSServletDelegate" file="WSServletDelegate.java" line="129" method="doGet"/>            <ns2:frame class="com.sun.xml.ws.transport.http.servlet.WSServletDelegate" file="WSServletDelegate.java" line="160" method="doPost"/>            <ns2:frame class="com.sun.xml.ws.transport.http.servlet.WSServlet" file="WSServlet.java" line="75" method="doPost"/>            <ns2:frame class="javax.servlet.http.HttpServlet" file="HttpServlet.java" line="637" method="service"/>            <ns2:frame class="javax.servlet.http.HttpServlet" file="HttpServlet.java" line="717" method="service"/>            <ns2:frame class="org.apache.catalina.core.ApplicationFilterChain" file="ApplicationFilterChain.java" line="290" method="internalDoFilter"/>            <ns2:frame class="org.apache.catalina.core.ApplicationFilterChain" file="ApplicationFilterChain.java" line="206" method="doFilter"/>            <ns2:frame class="org.alfresco.web.app.servlet.GlobalLocalizationFilter" file="GlobalLocalizationFilter.java" line="58" method="doFilter"/>            <ns2:frame class="org.apache.catalina.core.ApplicationFilterChain" file="ApplicationFilterChain.java" line="235" method="internalDoFilter"/>            <ns2:frame class="org.apache.catalina.core.ApplicationFilterChain" file="ApplicationFilterChain.java" line="206" method="doFilter"/>            <ns2:frame class="org.apache.catalina.core.StandardWrapperValve" file="StandardWrapperValve.java" line="233" method="invoke"/>            <ns2:frame class="org.apache.catalina.core.StandardContextValve" file="StandardContextValve.java" line="191" method="invoke"/>            <ns2:frame class="org.apache.catalina.authenticator.AuthenticatorBase" file="AuthenticatorBase.java" line="470" method="invoke"/>            <ns2:frame class="org.apache.catalina.core.StandardHostValve" file="StandardHostValve.java" line="127" method="invoke"/>            <ns2:frame class="org.apache.catalina.valves.ErrorReportValve" file="ErrorReportValve.java" line="102" method="invoke"/>            <ns2:frame class="org.apache.catalina.core.StandardEngineValve" file="StandardEngineValve.java" line="109" method="invoke"/>            <ns2:frame class="org.apache.catalina.connector.CoyoteAdapter" file="CoyoteAdapter.java" line="298" method="service"/>            <ns2:frame class="org.apache.coyote.ajp.AjpAprProcessor" file="AjpAprProcessor.java" line="427" method="process"/>            <ns2:frame class="org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler" file="AjpAprProtocol.java" line="384" method="process"/>            <ns2:frame class="org.apache.tomcat.util.net.AprEndpoint$Worker" file="AprEndpoint.java" line="1584" method="run"/>            <ns2:frame class="java.lang.Thread" file="Thread.java" line="662" method="run"/>          </ns2:stackTrace>          <ns2:cause class="org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException" note="To disable this feature, set com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace system property to false">            <message>Property cmis:objectTypeId must be set!</message>            <ns2:stackTrace>              <ns2:frame class="org.alfresco.opencmis.CMISConnector" file="CMISConnector.java" line="2524" method="getObjectTypeIdProperty"/>              <ns2:frame class="org.alfresco.opencmis.AlfrescoCmisService" file="AlfrescoCmisService.java" line="1198" method="createDocument"/>              <ns2:frame class="org.apache.chemistry.opencmis.server.support.CmisServiceWrapper" file="CmisServiceWrapper.java" line="666" method="createDocument"/>              <ns2:frame class="org.apache.chemistry.opencmis.server.impl.webservices.ObjectService" file="ObjectService.java" line="79" method="createDocument"/>              <ns2:frame class="sun.reflect.GeneratedMethodAccessor5324" line="unknown" method="invoke"/>              <ns2:frame class="sun.reflect.DelegatingMethodAccessorImpl" file="DelegatingMethodAccessorImpl.java" line="25" method="invoke"/>              <ns2:frame class="java.lang.reflect.Method" file="Method.java" line="597" method="invoke"/>              <ns2:frame class="com.sun.xml.ws.api.server.InstanceResolver$1" file="InstanceResolver.java" line="246" method="invoke"/>              <ns2:frame class="com.sun.xml.ws.server.InvokerTube$2" file="InvokerTube.java" line="146" method="invoke"/>              <ns2:frame class="com.sun.xml.ws.server.sei.EndpointMethodHandler" file="EndpointMethodHandler.java" line="257" method="invoke"/>              <ns2:frame class="com.sun.xml.ws.server.sei.SEIInvokerTube" file="SEIInvokerTube.java" line="93" method="processRequest"/>              <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="598" method="__doRun"/>              <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="557" method="_doRun"/>              <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="542" method="doRun"/>              <ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="439" method="runSync"/>              <ns2:frame class="com.sun.xml.ws.server.WSEndpointImpl$2" file="WSEndpointImpl.java" line="243" method="process"/>              <ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit" file="HttpAdapter.java" line="471" method="handle"/>              <ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter" file="HttpAdapter.java" line="244" method="handle"/>              <ns2:frame class="com.sun.xml.ws.transport.http.servlet.ServletAdapter" file="ServletAdapter.java" line="135" method="handle"/>              <ns2:frame class="com.sun.xml.ws.transport.http.servlet.WSServletDelegate" file="WSServletDelegate.java" line="129" method="doGet"/>              <ns2:frame class="com.sun.xml.ws.transport.http.servlet.WSServletDelegate" file="WSServletDelegate.java" line="160" method="doPost"/>              <ns2:frame class="com.sun.xml.ws.transport.http.servlet.WSServlet" file="WSServlet.java" line="75" method="doPost"/>              <ns2:frame class="javax.servlet.http.HttpServlet" file="HttpServlet.java" line="637" method="service"/>              <ns2:frame class="javax.servlet.http.HttpServlet" file="HttpServlet.java" line="717" method="service"/>              <ns2:frame class="org.apache.catalina.core.ApplicationFilterChain" file="ApplicationFilterChain.java" line="290" method="internalDoFilter"/>              <ns2:frame class="org.apache.catalina.core.ApplicationFilterChain" file="ApplicationFilterChain.java" line="206" method="doFilter"/>              <ns2:frame class="org.alfresco.web.app.servlet.GlobalLocalizationFilter" file="GlobalLocalizationFilter.java" line="58" method="doFilter"/>              <ns2:frame class="org.apache.catalina.core.ApplicationFilterChain" file="ApplicationFilterChain.java" line="235" method="internalDoFilter"/>              <ns2:frame class="org.apache.catalina.core.ApplicationFilterChain" file="ApplicationFilterChain.java" line="206" method="doFilter"/>              <ns2:frame class="org.apache.catalina.core.StandardWrapperValve" file="StandardWrapperValve.java" line="233" method="invoke"/>              <ns2:frame class="org.apache.catalina.core.StandardContextValve" file="StandardContextValve.java" line="191" method="invoke"/>              <ns2:frame class="org.apache.catalina.authenticator.AuthenticatorBase" file="AuthenticatorBase.java" line="470" method="invoke"/>              <ns2:frame class="org.apache.catalina.core.StandardHostValve" file="StandardHostValve.java" line="127" method="invoke"/>              <ns2:frame class="org.apache.catalina.valves.ErrorReportValve" file="ErrorReportValve.java" line="102" method="invoke"/>              <ns2:frame class="org.apache.catalina.core.StandardEngineValve" file="StandardEngineValve.java" line="109" method="invoke"/>              <ns2:frame class="org.apache.catalina.connector.CoyoteAdapter" file="CoyoteAdapter.java" line="298" method="service"/>              <ns2:frame class="org.apache.coyote.ajp.AjpAprProcessor" file="AjpAprProcessor.java" line="427" method="process"/>              <ns2:frame class="org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler" file="AjpAprProtocol.java" line="384" method="process"/>              <ns2:frame class="org.apache.tomcat.util.net.AprEndpoint$Worker" file="AprEndpoint.java" line="1584" method="run"/>              <ns2:frame class="java.lang.Thread" file="Thread.java" line="662" method="run"/>            </ns2:stackTrace>          </ns2:cause>        </ns2:exception>      </detail>    </S:Fault>  </S:Body></S:Envelope>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

jpotts
World-Class Innovator
World-Class Innovator
I think the problem is this little bit:
<propertyString propertyDefinitionId="cmis:objectTypeId" xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/">    <value>cmis:document</value></propertyString>‍‍‍
The objectTypeId is not a String, it is an ID. Therefore it needs to look like this:
<propertyId propertyDefinitionId="cmis:objectTypeId" xmlns="http://docs.oasis-open.org/ns/cmis/core/200908/">    <value>cmis:document</value></propertyId>‍‍‍
Can you change the following:
Dim propClass As New cmisPropertyString‍
To:
Dim propClass As New cmisPropertyId‍
And see if that fixes things?

Jeff

newtechfool
Champ in-the-making
Champ in-the-making
Yes, that fixed the problem. I am able to add documents to IBM P8 with the same code after the change, so it must not care if you specify the cmisSmiley SurprisedbjectTypeId as a String or Id.

Thanks for resolving this for me.