As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
package cmis; import java.awt.BorderLayout; import java.awt.Image; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.Iterator; import javax.activation.DataHandler; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.client.ServiceClient; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; import org.apache.axis2.databinding.types.xsd.QName; import org.apache.axis2.jaxws.description.xml.handler.ObjectFactory; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CmisContentStreamType; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CmisExtensionType; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CmisPropertiesType; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CmisProperty; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CmisPropertyString; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CreateFolder; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.CreateFolderResponse; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.GetContentStream; import org.oasis_open.docs.ns.cmis.ws._200908.ObjectServiceStub.GetContentStreamResponse; import com.sun.org.apache.bcel.internal.Constants; public class ObjectClient { private static EndpointReference targetEPR = new EndpointReference("http://172.22.41.129:8080/alfresco/cmis/NavigationService"); public static void main(String[] args) throws Exception { ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("D:\\Softwares\\axis2-1.5.1-bin\\axis2-1.5.1\\repository","D:\\Softwares\\axis2-1.5.1-bin\\axis2-1.5.1\\repository\\modules\\client.axis2.xml"); ObjectServiceStub stub = new ObjectServiceStub(ctx, "http://localhost:8080/alfresco/cmis/ObjectService"); GetContentStream cs = new ObjectServiceStub.GetContentStream(); cs.setRepositoryId("46f8b242-9f61-423b-b824-c6118f470f01"); //cs.setObjectId("workspace://SpacesStore/31defa0d-991a-48bf-8300-8e4a6b83d7ba"); cs.setObjectId("workspace://SpacesStore/b6d8dfd2-8afe-467e-9764-3bfd26bd829f"); //cs.setObjectId("f7912a3d-1bc2-4cbd-9ab5-4960c8720bd7"); cs.setStreamId(""); cs.setOffset(BigInteger.ZERO); cs.setLength(BigInteger.valueOf(500000)); CmisExtensionType et = new CmisExtensionType(); cs.setExtension(et); GetContentStreamResponse csr = stub.getContentStream(cs); CmisContentStreamType cst = csr.getContentStream(); System.out.println("File Name : " + cst.getFilename()); DataHandler dh = cst.getStream(); System.out.println("Content type " + dh.getContentType()); int x; InputStream is = dh.getInputStream(); /*while ((x = is.read())!= -1) { System.out.print(x); }*/ /*DataInputStream in = new DataInputStream(is); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console System.out.println (strLine); }*/ Image img = ImageIO.read(is); JFrame frame = new JFrame(); JLabel label = new JLabel(new ImageIcon(img)); frame.getContentPane().add(label, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }//end main }//end class
private void test(){ try { org.cmis.www._2008._05.ObjectServiceStub stub = new org.cmis.www._2008._05.ObjectServiceStub(SERVICE_URL); stub._getServiceClient().addHeader(securityHeader); org.cmis.www._2008._05.ObjectServiceStub.GetContentStream cs = new org.cmis.www._2008._05.ObjectServiceStub.GetContentStream(); cs.setRepositoryId(repositoryId); cs.setDocumentId("workspace://SpacesStore/4dd547c7-e13f-41cf-83b8-ee508843917c"); org.cmis.www._2008._05.ObjectServiceStub.GetContentStreamResponse contResp = stub.getContentStream(cs); DataHandler dh = contResp.getContentStream().getStream(); //dh.getContent(); }catch(AxisFault af){ System.out.println(af.getMessage()); }catch(RemoteException rex){ }catch(PermissionDeniedException pex){ }catch(OperationNotSupportedException oex){ }catch(org.cmis.www._2008._05.RuntimeException ruex){ }catch(ObjectNotFoundException onex){ }catch(UpdateConflictException uex){ }catch(StorageException sex){ }catch(InvalidArgumentException tex){ }catch(StreamNotSupportedException stex){ }catch(OffsetException ofex){ } }
<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"></wsu:Timestamp><wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><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></soapenv:Header> <soapenv:Body> <ns1:getContentStream xmlns:ns1="http://www.cmis.org/2008/05"> <ns1:repositoryId>84ccfe80-b325-4d79-ab4d-080a4bdd045b</ns1:repositoryId> <ns1:documentId>workspace://SpacesStore/4dd547c7-e13f-41cf-83b8-ee508843917c</ns1:documentId> </ns1:getContentStream> </soapenv:Body> </soapenv:Envelope>
INFO: OMException in getSOAPBuilder org.apache.axiom.om.OMException: SOAP message MUST NOT contain a Document Type Declaration(DTD) at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createDTD(StAXSOAPModelBuilder.java:423) at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:244) at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:161) at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:110) at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:682) at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:215) at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145) at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108) at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at org.cmis.www._2008._05.ObjectServiceStub.getContentStream(ObjectServiceStub.java:2190) at com.asconline.CMISFrame.test(CMISFrame.java:1070) at com.asconline.CMISFrame.<init>(CMISFrame.java:158) at com.asconline.CMISFrame.main(CMISFrame.java:389)