Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Error in Writing a binary file

sai kumar
2011-11-14
2012-11-29
  • sai kumar
    sai kumar
    2011-11-14

    Hi ,
    Please help us in providing some code samples for writing binary data using ADODB.Stream.

    We tried as below and encountered some exceptions .

        JIComServer comServer= new JIComServer(JIProgId.valueOf("ADODB.Stream"), hostname, dcomSession);

        IJIComObject comUnknown = comServer.createInstance();

        IJIDispatch dispatch = ((IJIDispatch)JIObjectFactory.narrowObject(comUnknown.queryInterface("00020400-0000-0000-c000-000000000046")));
       
        String rfile=remoteFilePath+File.separator+remoteFileName;
       
        Byte bytesToWrite = new Byte { new Byte((byte)1), new Byte(Byte.MAX_VALUE), new Byte(Byte.MAX_VALUE) };
       
        JIVariant file = dispatch.callMethodA("Write", new Object { new JIArray( bytesToWrite)});
       
    ====================================
    Exception is
    ====================================

    org.jinterop.dcom.impls.automation.JIAutomationException: Exception occurred. 
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.invoke(JIDispatchImpl.java:333)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.callMethodA(JIDispatchImpl.java:520)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.callMethodA(JIDispatchImpl.java:526)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.callMethodA(JIDispatchImpl.java:477)
    at WMIFileManager.createRemoteExecFile(WMIFileManager.java:97)
    at WMIFileManager.main(WMIFileManager.java:124)
    Caused by: org.jinterop.dcom.common.JIRuntimeException: Exception occurred. 
    at org.jinterop.dcom.core.JICallBuilder.readResult(JICallBuilder.java:1079)
    at org.jinterop.dcom.core.JICallBuilder.read(JICallBuilder.java:957)
    at ndr.NdrObject.decode(NdrObject.java:36)
    at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:137)
    at rpc.Stub.call(Stub.java:113)
    at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:901)
    at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:856)
    at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:266)
    at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:153)
    at org.jinterop.dcom.impls.automation.JIDispatchImpl.invoke(JIDispatchImpl.java:315)
    … 5 more