AnsweredAssumed Answered

Invalid reposiroty id - CMIS using webservice

Question asked by nikes on Feb 10, 2010
Latest reply on Mar 19, 2010 by nikes
Dear all,

I am using follow java program to access Alfresco using CMIS Webservice API


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 compiles well but when I execute it throws following exception for repository ID even though I am supplying
proper repository id.


Error:

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>0<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)


Any help would be appreciated.

Outcomes