SWIG - byte array as IN parameter

Hello J-Programmers!
It is about native calls.
I have a remaining problem for weeks.
SWIG is used to generate JNI code so as to build a Java interface of a home-made native library.
The goal is to "pass a byte[ ] from Java to C as an input parameter".
The problem is that SWIG keeps seeing it as an inout parameter and I can't managed to tune that.
Of course the program is working but clearly there is a useless back copy (see *)...
Here is the code result:
-- .h file
%include "typemaps.i"
%include "arrays_java.i"
UFIP_API bool VComWriteLoc (VCOMREF v, signed char buffer[], int size);
-- java module class
public static boolean VComWriteLoc(int v, byte[] buffer, int size)
-- wrap code
JNIEXPORT jboolean JNICALL Java_hep_fip_driver_FipUserLibJNI_VComWriteLoc(JNIEnv *jenv, jclass jcls, jint jarg1, jbyteArray jarg2, jint jarg3) {
jboolean jresult = 0 ;
int arg1 ;
signed char *arg2 ;
int arg3 ;
bool result;
jbyte *jarr2 ;
(void)jenv;
(void)jcls;
arg1 = (int)jarg1;
if (!SWIG_JavaArrayInSchar(jenv, &jarr2, &arg2, jarg2)) return 0;
arg3 = (int)jarg3;
result = (bool)VComWriteLoc(arg1,arg2,arg3);
jresult = (jboolean)result;
SWIG_JavaArrayArgoutSchar(jenv, jarr2, arg2, jarg2); // <--- useless back copy (*)
free(arg2);
return jresult;
Any idea?
Thanks in advance.
g2

re-Hello World!
Just some information about SWIG questions (SWIG-Java issues inclusive).
An active mailing list can be found directly from the SWIG site: www.swig.org :)
g2

Similar Messages

  • Error when using byte array in web service model interface

    Hello everybody,
    I'm using a web service model in my web dynpro application. The web service requires a byte array as import parameter.
    When starting the web dynpro application the following error occurs:
    com.sap.tc.webdynpro.services.exceptions.WDTypeNotFoundException: type java:byte not found
    at com.sap.tc.webdynpro.services.datatypes.core.DataTypeBroker.getDataType(DataTypeBroker.java:216)
    I'm using byte arrays several times in my application --> no problem. So why does the error say "byte not found" when using the web service?
    Thanks for your help!
    regards
    Christian

    Hi,
    maybe this is the problem. The type is byte and not binary.
    But I have the same problem as mentioned in the other thread: I can't change the type.
    The type in the WSDL of my web service is "base64binary". Is there maybe a possibility to import a jar-file for this type?
    Christian

  • How to pass byte array / binary data to a webservice as parameter in osb

    i have a webservice that has a byte array input parameter. i tried to use this WS in a message flow via service-callout. the problem i encountered is the following: since webservice call by using service-callout requires you to use an xml input as part of soap message, i insert both of $body/ctx:binary-content and $body/ctx:binary-content/@ref variables individually into this xml-message to pass binary-data to WS. When i debug the code, i see that it make calls to WS with $body/ctx:binary-content/@ref parameter, but the byte array passed is empty(not NULL)...
    note: i tried java-callut instead of service-called and used $body/ctx:binary-content as input parameter it worked. i think, this is because java-callout doesnt need an xml input and enable to take variables as is...
    can anybody help me to solve the problem with service-callout please?
    here is the input i use to call ws with service-callout method...
    <iso2Xml xmlns="http://www.mycompany.com.tr">
    <request>{$body/ctx:binary-content/@ref}</request>
    </iso2Xml>
    and this is my WS's signature:
    @WebMethod
    public String iso2Xml(byte[] request)

    Hi
    See this thread
    /message/2187817#2187817 [original link is broken]
    Kind Regards
    Mukesh

  • Problem with string constructor when using byte array as parameter

    I am creating a string using constructor and passing byte array as parameter.This byte array i am getting from MessageDigest's digest() method,i.e. a hash value.
    The problem is when i iterate through byte array i can able to print all the values in byte array.But when i construct a string from that byte array and printing that string ,that is printing some unknown characters.
    I don't know whether i need to pass charsequence to the constructor and the type of charsequence.Can anybody help me?
    Thanks in advance

    Is there some problem today? I'm getting this sort of thing all over.
    I already told you and so did Kayaman. Don't. String is not a holder for binary data. You have to Base-64 encode it. If you don't you cannot reconstruct the original binary digest value, so putting it into a database is completely utterly and entirely pointless.
    Is that clear enough?

  • How to add byte[] array based Image to the SQL Server without using parameter

    how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
    I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that  sql accepts byte [] array like sql  image type
    not using cmd.ParametersAdd() method
    here is Isle() method content

    SQL Server binary constants use a hexadecimal format:
    https://msdn.microsoft.com/en-us/library/ms179899.aspx
    You'll have to build that string from a byte array yourself:
    byte[] bytes = ...
    StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
    foreach (var b in bytes)
    builder.Append(b.ToString("X2"));
    string binhex = builder.ToString();
    That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
    data.

  • Convert XML data to byte array...

    Hello All,
    In my application, i have an XML file and the corresponding XSD file. This XML file is having some date, which i want to convert into an byte[] and then save it in a file. 
    How i can convert the XML data in the byte[]? Here as an example of the xml file and the byte[] data which i want to save in a file.
    <?xml version="1.0" encoding="utf-8"?>
    <HeadersInfo>
    <header>
    <id>0</id>
    <Name>H1</Name>
    </header>
    <header>
    <id>1</id>
    <Name>H2</Name>
    </header>
    </HeasersInfo>
    In the above example 'id' field is of type 'uint' and 'name' field is of type 'string' with max length of '5'. So in this case my byte array should be as shown below:
    00 00 00 01 48 31 00 00 00
    00 00 00 02 48 32 00 00 00
    Here underlines values are for the 'id' parameter where as values in bold are for 'Name' parameter for all the header values in sequence. Name parameter is null (0x00) padded.
    Thanks in advance,
    IamHuM

    Hi,
    the following example extract the id, name values using LINQ To Xml and writes it to a memory stream using a binary writer and returns the result as a byte array:
    internal static byte[] GetXmlAsByteArray()
    var document = XDocument.Parse("<HeadersInfo>"
    + " <header><id>1</id><Name>H1</Name></header>"
    + " <header><id>2</id><Name>H2</Name></header>"
    // additional testing
    + " <header><id>32767</id><Name>H1234</Name></header>"
    + " <header><id>305419896</id><Name>H56789</Name></header>"
    + "</HeadersInfo>");
    const int NameLength = 5; // Max length for a name
    byte[] zeroBytes = new byte[NameLength]; // Helper to fill name
    using (var ms = new MemoryStream())
    using (var writer = new BinaryWriter(ms))
    // write each header
    foreach (var header in document.Root.Elements("header"))
    int id = (int)header.Element("id");
    string name = (string)header.Element("Name");
    byte[] nameBytes = System.Text.Encoding.UTF8.GetBytes(name);
    Console.WriteLine("id: {0}, Name: {1}", id, name);
    // Write id
    writer.Write(GetUIntBytes((uint)id));
    // Write name NameLength (5) max, otherwise padded
    if (nameBytes.Length > NameLength)
    writer.Write(nameBytes, 0, NameLength);
    else
    writer.Write(nameBytes, 0, nameBytes.Length);
    if (nameBytes.Length < NameLength)
    writer.Write(zeroBytes, 0, NameLength - nameBytes.Length);
    byte[] result = ms.ToArray();
    // dump array
    foreach (var value in result)
    Console.Write("{0:X2} ", value);
    Console.WriteLine();
    return result;
    public static byte[] GetUIntBytes(uint value)
    if (BitConverter.IsLittleEndian)
    // swap bytes
    value = ((value & 0x00ff) << 24)
    | ((value & 0xff00) << 8)
    | ((value & 0x00ff0000) >> 8)
    | ((value & 0xff000000) >> 24);
    return BitConverter.GetBytes(value);
    For a general purpose solution you should create a class and split the example into separate methods to extract the data and write the values (integers, strings).
    Regards, Elmar

  • Convert byte array to table of int

    [http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print|http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print] Hello friends.
    I'm pretty new with PL/SQL.
    I have code that run well on MSSQL and I want to convert it to PL/SQL with no luck.
    The code converts byte array to table of int.
    The byte array is actually array of int that was converted to bytes in C# for sending it as parameter.
    The TSQL code is:
    CREATE FUNCTION dbo.GetTableVarchar(@Data image)
    RETURNS @DataTable TABLE (RowID int primary key IDENTITY ,
    Value Varchar(8000))
    AS
    BEGIN
    --First Test the data is of type Varchar.
    IF(dbo.ValidateExpectedType(103, @Data)<>1) RETURN
    --Loop thru the list inserting each
    -- item into the variable table.
    DECLARE @Ptr int, @Length int,
    @VarcharLength smallint, @Value Varchar(8000)
    SELECT @Length = DataLength(@Data), @Ptr = 2
    WHILE(@Ptr<@Length)
    BEGIN
    --The first 2 bytes of each item is the length of the
    --varchar, a negative number designates a null value.
    SET @VarcharLength = SUBSTRING(@Data, @ptr, 2)
    SET @Ptr = @Ptr + 2
    IF(@VarcharLength<0)
    SET @Value = NULL
    ELSE
    BEGIN
    SET @Value = SUBSTRING(@Data, @ptr, @VarcharLength)
    SET @Ptr = @Ptr + @VarcharLength
    END
    INSERT INTO @DataTable (Value) VALUES(@Value)
    END
    RETURN
    END
    It's taken from http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print.
    The C# code is:
    public byte[] Convert2Bytes(int[] list)
    if (list == null || list.Length == 0)
    return new byte[0];
    byte[] data = new byte[list.Length * 4];
    int k = 0;
    for (int i = 0; i < list.Length; i++)
    byte[] intBytes = BitConverter.GetBytes(list);
    for (int j = intBytes.Length - 1; j >= 0; j--)
    data[k++] = intBytes[j];
    return data;
    I tryied to convert the TSQL code to PL/SQL and thats what I've got:
    FUNCTION GetTableInt(p_Data blob)
    RETURN t_array --t_array is table of int
    AS
    l_Ptr number;
    l_Length number;
    l_ID number;
    l_data t_array;
    BEGIN
         l_Length := dbms_lob.getlength(p_Data);
    l_Ptr := 1;
         WHILE(l_Ptr<=l_Length)
         loop
              l_ID := to_number( DBMS_LOB.SUBSTR (p_Data, 4, l_ptr));
              IF(l_ID<-2147483646)THEN
                   IF(l_ID=-2147483648)THEN
                        l_ID := NULL;
                   ELSE
                        l_Ptr := l_Ptr + 4;
                        l_ID := to_number( DBMS_LOB.SUBSTR(p_Data, 4,l_ptr));
                   END IF;
                   END IF;
    l_data(l_data.count) := l_ID;
              l_Ptr := l_Ptr + 4;
         END loop;
         RETURN l_data;
    END GetTableInt;
    This isn't work.
    This is the error:
    Error report:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    06502. 00000 - "PL/SQL: numeric or value error%s"
    I think the problem is in this line:
    l_ID := to_number( DBMS_LOB.SUBSTR (p_Data, 4, l_ptr));
    but I don't know how to fix that.
    Thanks,
    MTs.

    I'd found the solution.
    I need to write:
    l_ID := utl_raw.cast_to_binary_integer( DBMS_LOB.SUBSTR(p_Data, 4,l_ptr));
    instead of:
    l_ID := to_number( DBMS_LOB.SUBSTR (p_Data, 4, l_ptr));
    The performance isn't good, it's take 2.8 sec to convert 5000 int, but it's works.

  • Problem in using the install()'s byte array values?

    I tried to pass the values to the OwnerPIN object at the time of initialization. But when I try to install the applet I will get 6A80 error code . Can anybody tell me why I am getting this message. And if i use some different data values for pin.update() then I wont come across those error codes
    public static void install(byte[] bArray, short bOffset, byte bLength)     {          
              // GP-compliant JavaCard applet registration
              new SampleApp(bArray, (short) (bOffset), bLength);                    
         private SampleApp(byte[] bArray, short bOffset, byte bLength){
              pin = new OwnerPIN(PIN_TRY_LIMIT, MAX_PIN_SIZE);
              pin.update(bArray,bOffset, bLength);          
                    register();
    cm>  install -i a00000006203010c0601 -l -q C9#(1122331122331122) a00000006203010c06 a00000006203010c0601
    => 80 E6 0C 00 2E 09 A0 00 00 00 62 03 01 0C 06 0A    ..........b.....
        A0 00 00 00 62 03 01 0C 06 01 0A A0 00 00 00 62    ....b..........b
        03 01 0C 06 01 01 10 0A C9 08 11 22 33 11 22 33    ..........."3."3
        11 22 00 00
    ( 5411 usec)
    <= 6A 80

    GP 2.1.1, A.2 GlobalPlatform on a Java Card, Installation:
    Installation
    In Section 3.1 - The Method install of the Java Card� 2.1.1 Runtime Environment (JCRE) Specifications,
    the parameters passed to the method are defined to be initialization parameters from the contents of the incoming
    byte array parameter.
    In the definition of the install method of the Class Applet of the Java Card� 2.1.1 Application Programming
    Interface, the install parameters to be supplied must be in the format defined by the applet.
    This specification expands on this requirement and further defines the content of the install parameters. This
    expansion affects both the implementation of an OPEN and the behavior of a Java Card applet developed for a
    GlobalPlatform card. It does not affect the definition of the install method of the Class Applet of the Java
    Card� 2.1.1 Application Programming Interface specification.
    The install parameters shall identify the following data, present in the INSTALL [for install] command (see
    Section 9.5.2.3.2 - Data Field for INSTALL [for install]):
    � The instance AID,
    � The Application Privileges and,
    � The Application Specific Parameters.
    [While the APDU command contains install parameters representing TLV coded system and application specific parameters, the
    application only requires knowledge of the Application Specific Parameters i.e. only LV of the TLV coded structure �C9� are
    present as parameters.]
    The OPEN is responsible for ensuring that the parameters (bArray, bOffset and bLength) contain the
    following information:
    The array, bArray, shall contain the following consecutive LV coded data:
    _� Length of the instance AID,_
    _� The instance AID,_
    _� Length of the Application Privileges,_
    _� The Application Privileges,_
    _� Length of the Application Specific Parameters and,_
    _� The Application Specific Parameters._
    The byte, bOffset, shall contain an offset within the array pointing to the length of the instance AID.
    The byte, bLength, shall contain a length indicating the total length of the above-defined data in the array.
    The applet is required to utilize the instance AID as a parameter when invoking the register (byte []
    bArray, short bOffset, byte bLength) method of the Class Applet of the Java Card� 2.1.1
    Application Programming Interface specification.

  • How to get password as string back from encrypted password byte array.

    Hi All,
    I am storing encrypted password and enc key in the database.(Code included encryptPassword method for encryption and validatePassword method for validating of password). Problem is that for some reason i need to show user's password to the user as a string as he/she entered. But i am not able to convert the encrypted password from D/B to original String.
    Tell me if any body know how to get the string password back from the encrypted password byte array after seeing my existing encryption code.
    //********* Code
    private Vector encryptPassword(byte[] arrPwd)
    try
    // parameter arrPwd is the password as entered by the user and to be encrypted.
    byte[] encPwd = null;
    byte[] key = null;
    /* Generate a key pair */
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN");
    SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
    keyGen.initialize(1024, random);
    KeyPair pair = keyGen.generateKeyPair();
    PrivateKey priv = pair.getPrivate();
    PublicKey pub = pair.getPublic();
    /* Create a Signature object and initialize it with the private key */
    Signature dsa = Signature.getInstance("SHA1withDSA", "SUN");
    dsa.initSign(priv);
    /* Update and sign the data */
    dsa.update(arrPwd, 0, 12);
    /* Now that all the data to be signed has been read in, generate a signature for it */
    encPwd = dsa.sign();
    /* Now realSig has the signed password*/
    key = pub.getEncoded();
    Vector vtrPwd = new Vector(2);
    vtrPwd.add(encPwd);
    vtrPwd.add(key);
    return vtrPwd;
    catch (Exception e)
    private boolean validatePassword(byte[] arrPwd,byte[] encPwd,byte[] key) throws RemoteException
    try
    // arrPwd is the byte array of password entered by user.
    // encPwd is the encrypted password retreived from D/B
    // key is the array of key through which the password was encrypted and stored.
    X509EncodedKeySpec KeySpec = new X509EncodedKeySpec(key);
    KeyFactory keyFactory = KeyFactory.getInstance("DSA", "SUN");
    PublicKey pubKey = keyFactory.generatePublic(KeySpec);
    /* Encrypt the user-entered password using the key*/
    Signature sig = Signature.getInstance("SHA1withDSA", "SUN");
    sig.initVerify(pubKey);
    /* Update and sign the password*/
    sig.update(arrPwd, 0, 12);
    return sig.verify(encPwd);
    catch (Exception e)
    Help upto any extent would be appreciated.
    Thanx
    Moti Singh

    Hi All,
    I am storing encrypted password and enc key in the
    database.(Code included encryptPassword method for
    encryption and validatePassword method for validating
    of password). Problem is that for some reason i need
    to show user's password to the user as a string as
    he/she entered. But i am not able to convert the
    encrypted password from D/B to original String.No, you are not encrypting the password in your code, you are merely signing it.
    Tell me if any body know how to get the string
    password back from the encrypted password byte array
    after seeing my existing encryption code.It is impossible to retrieve the original text out of a signature.
    You should read up on some encryption basics in order to understand the difference between signing and encrypting. Then you can find examples of how to encrypt something here: http://java.sun.com/j2se/1.4/docs/guide/security/jce/JCERefGuide.html.
    Actually there is one class specifically for keeping keys secure, KeyStore http://java.sun.com/j2se/1.4/docs/api/java/security/KeyStore.html
    - Daniel

  • Byte array exception in web dynpro

    Hi all,
    I am developing a web dynpro application using a webservice model. The model expects a parameter in the form a byte array.
    But  unfortunately when I get the following exception when i lauch the web dypro application. Anyone of you, plz help me.
    Error stack trace:
    com.sap.tc.webdynpro.services.exceptions.WDTypeNotFoundException: type java:byte not found
         at com.sap.tc.webdynpro.services.datatypes.core.DataTypeBroker.getDataType(DataTypeBroker.java:216)
         at com.sap.tc.webdynpro.progmodel.context.AttributeInfo.init(AttributeInfo.java:449)
         at com.sap.tc.webdynpro.progmodel.context.NodeInfo.initAttributes(NodeInfo.java:688)
         at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:673)
         at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:678)
         at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:678)
         at com.sap.tc.webdynpro.progmodel.context.Context.init(Context.java:38)
         at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:199)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.init(ClientComponent.java:346)
         at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:342)
         at com.sap.tc.webdynpro.clientserver.task.Task.createApplication(Task.java:217)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:494)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:54)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:241)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:139)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:101)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:38)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:377)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:257)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:322)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:300)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:699)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:224)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:140)
    Thanks in Advance
    Satish

    Hi VS,
    I think I haven't explained it clearly.
    I have used the file upload component to get the data from a file.. and of course with a context attribute of binary type. I have to assign this byte[] to the web service model method parameter. But to my fascination, the webdynpro application crashes on start throwing the above mentioned exception.
    Any Idea??
    thanks
    satish

  • How to encrypt byte array with out padding using RSA in Java?

    I've modulus and public exponent as byte[] array, so I'm trying to convert into BigIntegers and then create public key and then Cipher. Here is the example code:
    With this I'm always getting different encrypted bytes, is it because of padding. I dont want to use any padding so what parameter I need to pass along with RSA? I've modulus byte[] array size 64 bytes. I believe I'll get 64 encrypted bytes. I've content size of 32 bytes to be encrypted.
    --------code begin ---------------------------
    BigInteger bexponent = new BigInteger(pubExpo);
    BigInteger bmodulus = new BigInteger(modulus);
    KeyFactory keyFactory = KeyFactory.getInstance("RSA");
    RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(bmodulus, bexponent);
    RSAPublicKey pubKey = (RSAPublicKey)keyFactory.generatePublic(pubKeySpec);
    Cipher c = Cipher.getInstance("RSA");
    c.init(Cipher.ENCRYPT_MODE, pubKey);
    return c.doFinal(content);
    --------code end---------------------------

    With this I'm always getting different encrypted
    bytes, is it because of padding. Yes, if you're using PKCS1Padding (which is the default in SunJCE if you don't specify it). Have a look at the PKCS1 spec if you haven't seen it already.
    http://www.rsasecurity.com/rsalabs/pkcs
    Section 7.2.1 talks about type 2 padding, which uses random bytes as the PS string.
    I dont want to use
    any padding so what parameter I need to pass along
    with RSA? NOPADDING. You should be able to find this out by look at the "Supported Paddings" parameter in your provider's database. Which of course, means you'll need to supply the right number of bytes to the Cipher.

  • Error passing byte array in soap request

    Hi,
    i am trying to pass byte arrays (and also java.lang.Byte array) as parameter in
    a soap request.
    to do so i have defined a simple web service under weblogic 7.0.
    then i test it through the WebLogic Webservice standard testing home page.
    the value field for testing my web service is already filled by weblogic with:
    <bytes xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:type="xsd:base64Binary">aopd</bytes>
    i only need to invoke my web service to test it.
    then an exception is raised:
    javax.xml.soap.SOAPException: failed to deserialize xml:weblogic.xml.schema.binding.DeserializationException:
    error decoding base64binary - with nested exception: [java.io.IOException: Error
    in encoded stream] javax.xml.soap.SOAPException: failed to deserialize xml:weblogic.xml.schema.binding.DeserializationException:
    error decoding base64binary - with nested exception: [java.io.IOException: Error
    in encoded stream] at weblogic.webservice.core.DefaultPart.toJava(DefaultPart.java:301)
    at weblogic.webservice.tools.pagegen.SampleInstance.getJavaObject(SampleInstance.java:130)
    at weblogic.webservice.server.servlet.ServletBase.getJavaParams(ServletBase.java:296)
    at weblogic.webservice.server.servlet.ServletBase.invokeOperation(ServletBase.java:239)
    at weblogic.webservice.server.servlet.WebServiceServlet.invokeOperation(WebServiceServlet.java:306)
    at weblogic.webservice.server.servlet.ServletBase.handleGet(ServletBase.java:198)
    at weblogic.webservice.server.servlet.ServletBase.doGet(ServletBase.java:124)
    at weblogic.webservice.server.servlet.WebServiceServlet.doGet(WebServiceServlet.java:224)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    any idea?

    Hi,
    Looks like a known bug (CR087883).
    Thanks,
    Bruce
    cyrille puget wrote:
    Hi,
    i am trying to pass byte arrays (and also java.lang.Byte array) as parameter in
    a soap request.
    to do so i have defined a simple web service under weblogic 7.0.
    then i test it through the WebLogic Webservice standard testing home page.
    the value field for testing my web service is already filled by weblogic with:
    <bytes xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:type="xsd:base64Binary">aopd</bytes>
    i only need to invoke my web service to test it.
    then an exception is raised:
    javax.xml.soap.SOAPException: failed to deserialize xml:weblogic.xml.schema.binding.DeserializationException:
    error decoding base64binary - with nested exception: [java.io.IOException: Error
    in encoded stream] javax.xml.soap.SOAPException: failed to deserialize xml:weblogic.xml.schema.binding.DeserializationException:
    error decoding base64binary - with nested exception: [java.io.IOException: Error
    in encoded stream] at weblogic.webservice.core.DefaultPart.toJava(DefaultPart.java:301)
    at weblogic.webservice.tools.pagegen.SampleInstance.getJavaObject(SampleInstance.java:130)
    at weblogic.webservice.server.servlet.ServletBase.getJavaParams(ServletBase.java:296)
    at weblogic.webservice.server.servlet.ServletBase.invokeOperation(ServletBase.java:239)
    at weblogic.webservice.server.servlet.WebServiceServlet.invokeOperation(WebServiceServlet.java:306)
    at weblogic.webservice.server.servlet.ServletBase.handleGet(ServletBase.java:198)
    at weblogic.webservice.server.servlet.ServletBase.doGet(ServletBase.java:124)
    at weblogic.webservice.server.servlet.WebServiceServlet.doGet(WebServiceServlet.java:224)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    any idea?

  • How Do I Load An Animated GIF Into PictureBox Control From Byte Array?

    I'm having a problem with loading an animated GIF int a picturebox control in a C# program after it has been converted to a base64 string, then converted to a byte array, then written to binary, then converted to a base64 string again, then converted to
    a byte array, then loaded into a memory stream and finally into a picturebox control.
    Here's the step-by-step code I've written:
    1. First I open an animated GIF from a file and load it directly into a picturebox control. It animates just fine.
    2. Next I convert the image in the picturebox control (pbTitlePageImage) to a base64 string as shown in the code below:
                    if (pbTitlePageImage.Image != null)
                        string Image2BConverted;
                        using (Bitmap bm = new Bitmap(pbTitlePageImage.Image))
                            using (MemoryStream ms = new MemoryStream())
                                bm.Save(ms, ImageFormat.Jpeg);
                                Image2BConverted = Convert.ToBase64String(ms.ToArray());
                                GameInfo.TitlePageImage = Image2BConverted;
                                ms.Close();
                                GameInfo.TitlePageImagePresent = true;
                                ProjectNeedsSaving = true;
    3. Then I write the base64 string to a binary file using FileStream and BinaryWriter.
    4. Next I get the image from the binary file using FileStream and BinaryReader and assign it to a string variable. It is now a base64 string again.
    5. Next I load the base64 string into a byte array, then I load it into StreamReader and finally into the picturebox control (pbGameImages) as shown in the code below:
    byte[] TitlePageImageBuffer = Convert.FromBase64String(GameInfo.TitlePageImage);
                            MemoryStream memTitlePageImageStream = new MemoryStream(TitlePageImageBuffer, 0, TitlePageImageBuffer.Length);
                            memTitlePageImageStream.Write(TitlePageImageBuffer, 0, TitlePageImageBuffer.Length);
                            memTitlePageImageStream.Position = 0;
                            pbGameImages.Image = Image.FromStream(memTitlePageImageStream, true);
                            memTitlePageImageStream.Close();
                            memTitlePageImageStream = null;
                            TitlePageImageBuffer = null;
    This step-by-step will work with all image file types except animated GIFs (standard GIFs work fine). It looks like it's just taking one frame from the animation and loading it into the picturebox. I need to be able to load the entire animation. Does any of
    the code above cause the animation to be lost? Any ideas?

    There is an ImageAnimator so you may not need to use byte array instead.
    ImageAnimator.Animate Method
    http://msdn.microsoft.com/en-us/library/system.drawing.imageanimator.animate(v=vs.110).aspx
    chanmm
    chanmm

  • How can I pass an empty array to a parameter of type PLSQLAssociativeArray

    How can I pass an empty array to a parameter of type PLSQLAssociativeArray in VB? I defined the parameter like this
    Dim myArray() as String = new String() {}
    Dim myPara as new Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray
    myPara = 0
    myPara.Value = myArray
    When I execute my stored procedure giving the above parameter, I got error saying OracleParameter.Value is invalid.
    I have tried to give it the DBNull.Value, but it doesn't work either.
    Note: everything works fine as long as myArray has some item in there. I just wonder how I can make it works in case I have nothing.
    Thank you,

    How can I pass an empty array to a parameter of type PLSQLAssociativeArray in VB? I defined the parameter like this
    Dim myArray() as String = new String() {}
    Dim myPara as new Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray
    myPara = 0
    myPara.Value = myArray
    When I execute my stored procedure giving the above parameter, I got error saying OracleParameter.Value is invalid.
    I have tried to give it the DBNull.Value, but it doesn't work either.
    Note: everything works fine as long as myArray has some item in there. I just wonder how I can make it works in case I have nothing.
    Thank you,

  • Converting ASCII text (byte array ending in null) to a String

    Hi all,
    I am trying to convert a null terminated ascii string stored in a byte array to a java String. When I pass the byte array to the String constructor it
    does not detect/interpret the null as a terminator for the ascii string. Is this something I have to manually program in? ie Check for where the null is and then
    pass that subarray of everything before the null to the String constructor?
    example of problem
    //               A   B  C   D   null   F   (note F is junk in the array, and should be ignored since it is after null)
    byte[] asciiArray = { 65, 66, 67, 68, 0,  70 };
    System.out.println(new String(asciiArray, "UTF-8"));
    //this prints ABCD"sqare icon"F

    Why do you expect the null character to terminate the string? If you come from a C or C++ background, you need to understand that java.lang.String is not just a mere character array. It's a full-fledged Java object that knows its length without having any need for null terminator. So Ascii 0 is just another character for String object. To achieve what you want to do, you have to manually loop through the byte array and stop when you encounter a null character.

Maybe you are looking for