The stub received bad data.

Help
Percy
2014-04-25
2014-04-28
  • Percy

    Percy - 2014-04-25

    I'm using j-interop to interact with an opc ae server. I'm getting the following error when calling a function.
    org.jinterop.dcom.common.JIException: The stub received bad data. Please check whether the API has been called in the right way, with correct parameter formation. [0x800706F7]
    at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:994)
    at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:945)
    at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:271)
    at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:156)
    at libpercy.opc_ae.IOPCEventServer.CreateEventSubscription(IOPCEventServer.java:35)
    at libpercy.opc_ae.COpcAeClient.connect(COpcAeClient.java:109)
    at libpercy.opc_ae.COpcAeClient.Connect(COpcAeClient.java:42)
    at CManager.<init>(CManager.java:18)
    at CManager.<clinit>(CManager.java:36)
    at CMain.main(CMain.java:10)
    Caused by: rpc.FaultException: Received fault. (unknown)
    at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:141)
    at rpc.Stub.call(Stub.java:113)
    at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:990)
    ... 9 more

    The prototype of this function is:
    virtual HRESULT STDMETHODCALLTYPE CreateEventSubscription(
    / [in] / BOOL bActive,
    / [in] / DWORD dwBufferTime,
    / [in] / DWORD dwMaxSize,
    / [in] / OPCHANDLE hClientSubscription,
    / [in] / REFIID riid,
    / [iid_is][out] / LPUNKNOWN ppUnk,
    /
    [out] / DWORD pdwRevisedBufferTime,
    / [out] / DWORD *pdwRevisedMaxSize) = 0;

    And my code is:
    public Object[] CreateEventSubscription(
    / [in] / Boolean bActive,
    / [in] / Integer dwBufferTime,
    / [in] / Integer dwMaxSize,
    / [in] / Integer hClientSubscription,
    / [in] / String riid
    )
    {
    JICallBuilder call_builder=new JICallBuilder();
    call_builder.reInit();
    call_builder.setOpnum(1);
    call_builder.addInParamAsInt(bActive?1:0, JIFlags.FLAG_NULL);
    call_builder.addInParamAsInt(dwBufferTime, JIFlags.FLAG_NULL);
    call_builder.addInParamAsInt(dwMaxSize, JIFlags.FLAG_NULL);
    call_builder.addInParamAsInt(hClientSubscription, JIFlags.FLAG_NULL);
    call_builder.addInParamAsUUID(riid, JIFlags.FLAG_NULL);
    call_builder.addOutParamAsType(IJIComObject.class, JIFlags.FLAG_NULL);
    call_builder.addOutParamAsType(Integer.class, JIFlags.FLAG_NULL);
    call_builder.addOutParamAsType(Integer.class, JIFlags.FLAG_NULL);
    Object[] ret=null;
    try {
    ret=Get_com_object().call(call_builder);
    } catch (JIException e) {
    e.printStackTrace();
    }
    return ret;
    }

     
    • Morten Andersen

      Morten Andersen - 2014-04-26

      Hi Percy,

      For OPC AE you might want to look into the openSCADA Utgard library. It uses j-Interop for the OPC communication. So you don't have to write the low level DCOM OPC calls yourself.

      http://openscada.org/projects/utgard/

      Best Regards
      Morten

       
      • Percy

        Percy - 2014-04-28

        openSCADA has implemented OPC DA, but I'm using OPC AE.

         
        Last edit: Percy 2014-04-28
  • Percy

    Percy - 2014-04-28

    Solved by myself. The line
    JICallBuilder call_builder=new JICallBuilder();
    should be changed to
    JICallBuilder call_builder=new JICallBuilder(true);

     
    Last edit: Percy 2014-05-02

Log in to post a comment.