I am new to Alfresco cmis api for webservice.
I am using Alfresco community 3.2r2 version.
I am using following standalone java program to connect to alfresco
but it throws exception saying
"invalid repository id" even though I am supplying valid repository
id.
Code:
-----------------------------------------------------------------------------------------------------------
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.message.SOAPHeaderElement;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.ws.security.message.token.UsernameToken;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.message.WSSecHeader;
import org.apache.ws.security.util.WSSecurityUtil;
import org.w3c.dom.Document;
import org.apache.ws.security.message.token.Timestamp;
public class CMISTest {
public static void main(String [] args) {
try {
String endpoint = "http://localhost:8080/alfresco/cmis/
RepositoryService";
String repID = "46f8b242-9f61-423b-b824-c6118f470f01";
Service serv = new Service();
Call call = (Call) serv.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName(new QName("http://www.cmis.org/2008/05",
"getTypeChildren"));
call.addParameter( "id",new QName("http://www.w3.org/2001/
XMLSchema","string"),ParameterMode.IN);
call.setReturnType( new QName("http://www.w3.org/2001/
XMLSchema","string"));
//call.setUsername("admin");
//call.setPassword("admin");
SOAPEnvelope se = new SOAPEnvelope(); // dummy envelope to create
Header
Document doc = se.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.setMustUnderstand(true);
secHeader.insertSecurityHeader(doc);
UsernameToken username = new
UsernameToken(Boolean.TRUE,doc,WSConstants.PASSWORD_TEXT);
username.setName("admin");
username.setPassword("admin");
Timestamp ts = new Timestamp(true, doc,900000);
WSSecurityUtil.prependChildElement(doc, secHeader.getSecurityHeader(),
username.getElement(), true);
WSSecurityUtil.prependChildElement(doc, secHeader.getSecurityHeader(),
ts.getElement(), true);
SOAPHeaderElement she = new
SOAPHeaderElement(secHeader.getSecurityHeader());
call.addHeader(she);
String ret = (String) call.invoke(new Object[] {repID});
System.out.println(ret);
} catch (Exception e) {
e.printStackTrace();
}
}
}
---------------------------------------------------------------
It is throwing following exception..
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultSubcode:
faultString: Invalid repository id
faultActor:
faultNode:
faultDetail:
{http://docs.oasis-open.org/ns/cmis/messaging/200908/}
cmisFault:<type>i
validArgument</type><code>0</code><message>Invalid repository id</
message>
Invalid repository id
at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilde
.java:222)
at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder
java:129)
at
org.apache.axis.encoding.DeserializationContext.endElement(Deseriali
ationContext.java:1087)
at
org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Sourc
)
at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unkno
n Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
$FragmentConten
Dispatcher.dispatch(Unknown Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(U
known Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)
at org.apache.xerces.jaxp.SAXParserImpl
$JAXPSAXParser.parse(Unknown Sou
ce)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at
org.apache.axis.encoding.DeserializationContext.parse(Deserializatio
Context.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:
696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at
org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnder
tandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:
206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at CMISTest.main(CMISTest.java:50)
------------------------------------------------------
Am I missing any parameter in program? Or is there any bug in Alfresco
3.2r2?
Kindly guide.
Thanks,
Nikesh
Can you double check the repId. What repId do you get back from getRepositories().
Also, can you try the same code against cmis.alfresco.com?
I don't see the same issue with a CXF client. I'll try your test code.
Regards,
Dave
> --
> You received this message because you are subscribed to the Google Groups "CMIS Interoperability" group.
> To post to this group, send email to cmis-i...@googlegroups.com.
> To unsubscribe from this group, send email to cmis-interop...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cmis-interop?hl=en.
>
This is what I did.
Entered URL: http://localhost:8080/alfresco/s/cmis
It sent back me response containing collections, atom links and
cmisra:repositoryInfo element.
I took cmis:repositoryId value from cmisra:repositoryInfo and copied
in java program. and also tried "getRepositoryInfo" as operation name
but getting same exception.
If I pass cmis.alfresco.com, what credentials should I pass? Do i have
to register on alfresco website?
Thanks,
Nikesh
user: admin, password: admin
Dave
I used operation name as getRepositories, but how to print its
repository id?
Did you get chance to try the code I posted?
Please let me know your findings. I am still getting the same error.
One more question is,
If I go with Apache Axis2/ Apache CXF, what type of changes I will
have to do in case
I change repository from Alfresco to filenet/documentum/sharepoint etc
Thanks,
Nikesh