Share this page

# XmlBasedBinMemoObjectParsing.xml2binFile

Reads an XML from a file, converts it to a byte array, and loads the byte array into a new .bin file.

Java over HTTP Vuser Functions

    public static void xml2binFile(String xmlFilename, String binFilename)

## Arguments

Argument | Description
--- | ---
xmlFilename | The name of the file containing the XML to be converted into a byte array. This file must be located in the same folder as the Vuser script.
binFilename | The name of the new file into which the byte array is loaded.

## Parameterization

Parameterization is not applicable to this function.

## Example

This is an example of a Java over HTTP action.

Copy code

    import com.thoughtworks.xstream.*;
    import java.io.*;
    import java.util.ArrayList;
    import javaHttpJ.*;
    import javaHttpJ.parsers.*;
    import javaHttpJ.replay.*;
    import lrapi.*;
    import org.springframework.remoting.support.RemoteInvocation;
    import org.springframework.remoting.support.RemoteInvocationResult;

    public class Actions
    {
    public int init(){
    global_init();
    return 0;
    }

    public int end(){return 0;}

    static final Object lock = new Object(); static boolean ready = false;

    public static void global_init() {
    if (ready == false)
    synchronized (lock) {
    if (ready == false) {
    RemoteInvocationBA0=
        XmlBasedBinMemoObjectParsing.xml2bin("requestBody2.xml");
    RemoteInvocationBA1=
        XmlBasedBinMemoObjectParsing.xml2bin("requestBody3.xml");
    RemoteInvocationBA2=
        XmlBasedBinMemoObjectParsing.xml2bin("requestBody4.xml");
    RemoteInvocationBA3=
        XmlBasedBinMemoObjectParsing.xml2bin("requestBody5.xml");
    ready = true;
    }
    }
    }
    public int action() throws Throwable{
        String ENDFORM = "ENDFORM";
        String LAST = "LAST";
        String ENDITEM = "ENDITEM";
        String ITEMDATA = "ITEMDATA";
        String STARTHIDDENS = "STARTHIDDENS";
        String ENDHIDDENS = "ENDHIDDENS";
        String CONNECT     = "CONNECT";
        String RECEIVE = "RECEIVE";
        String RESOLVE     = "RESOLVE";
        String REQUEST = "REQUEST";
        String RESPONSE     = "RESPONSE";
        String EXTRARES = "EXTRARES";
        int _webresult;

        try{
        lr.think_time(0);
        _webresult = lrapi.web.url("launch.html",
            "URL=http://my_server:8080/jpetstore/java/launch.html", new String[]{
            "Resource=0",
            "RecContentType=text/html",
            "Referer=",
            "Snapshot=t1.inf",
            "Mode=HTML",
            EXTRARES,
            "Url=/favicon.ico", "Referer=", ENDITEM,
            "Url=launch.jnlp", "Referer=", ENDITEM,
            "Url=lib/spring.jar", "Referer=", ENDITEM,
            "Url=lib/spring-mock.jar", "Referer=", ENDITEM,
            "Url=lib/struts-1.2.9.jar", "Referer=", ENDITEM,
            "Url=lib/axis.jar", "Referer=", ENDITEM,
            "Url=lib/commons-logging-4.0.6.jar", "Referer=", ENDITEM,
            "Url=lib/hsqldb.jar", "Referer=", ENDITEM,
            "Url=lib/AbsoluteLayout.jar", "Referer=", ENDITEM,
            "Url=lib/hessian-3.0.20.jar", "Referer=", ENDITEM,
            "Url=javaoverhttp1.jar", "Referer=", ENDITEM,
            "Url=lib/axis-jaxrpc-1.4.jar", "Referer=", ENDITEM,
            "Url=lib/spring-aspects.jar", "Referer=", ENDITEM,
            "Url=lib/javax.servlet-5.1.11.jar", "Referer=", ENDITEM,
            "Url=clientContext.xml", "Referer=", ENDITEM,
                "Url=client.properties", "Referer=", ENDITEM,
                LAST});
        ////////////////////// requestBody2.xml //////////////////////
        RemoteInvocation RemoteInvocation_getUsernameList2 =
            (RemoteInvocation) JavaHTTP.readObject(RemoteInvocationBA0);
        // 2 is the number of the header file
        // record time response is at file responseBody2.xml
        RemoteInvocationResult RemoteInvocationResult_ArrayList2 =
            (RemoteInvocationResult)
            JavaHTTP.sendSerialized(RemoteInvocation_getUsernameList2, 2,
            "ObjectsDeserializerDefaultImpl",
            "OrderService-httpinvoker",
            "URL=http://my_server/jpetstore/remoting/OrderService-httpinvoker",
            new String[]{
                "Method=POST",
                "Resource=0",
                "RecContentType=application/x-java-serialized-object",
                "Referer=",
                "Mode=HTML",
                "EncType=application/x-java-serialized-object",
                LAST});
        ////////////////////// requestBody3.xml //////////////////////
        RemoteInvocation RemoteInvocation_getCategoryList3 =
            (RemoteInvocation) JavaHTTP.readObject(RemoteInvocationBA1);
        // 3 is the number of the header file, record time response
        // is at file responseBody3.xml
        RemoteInvocationResult RemoteInvocationResult_ArrayList3 =
            (RemoteInvocationResult)
            JavaHTTP.sendSerialized(RemoteInvocation_getCategoryList3, 3,
            "ObjectsDeserializerDefaultImpl",
            "OrderService-httpinvoker_2",
            "URL=http://my_server/jpetstore/remoting/OrderService-httpinvoker",
            new String[]{
                "Method=POST",
                "Resource=0",
                "RecContentType=application/x-java-serialized-object",
                "Referer=",
                "Mode=HTML",
                "EncType=application/x-java-serialized-object",
                LAST});
        ////////////////////// requestBody4.xml //////////////////////
        RemoteInvocation RemoteInvocation_getOrdersByUsername4 =
            (RemoteInvocation) JavaHTTP.readObject(RemoteInvocationBA2);
        // 4 is the number of the header file,
        // record time response is at file responseBody4.xml
        RemoteInvocationResult RemoteInvocationResult_ArrayList4 =
            (RemoteInvocationResult)
            JavaHTTP.sendSerialized(
            RemoteInvocation_getOrdersByUsername4, 4,
            "ObjectsDeserializerDefaultImpl",
            "OrderService-httpinvoker_3",
            "URL=http://my_server/jpetstore/remoting/OrderService-httpinvoker",
            new String[]{
                "Method=POST",
                "Resource=0",
                "RecContentType=application/x-java-serialized-object",
                "Referer=",
                "Mode=HTML",
                "EncType=application/x-java-serialized-object",
                LAST});
        ////////////////////// requestBody5.xml //////////////////////
        RemoteInvocation RemoteInvocation_getUsernameList5 =
            (RemoteInvocation) JavaHTTP.readObject(RemoteInvocationBA3);
        // 5 is the number of the header file,
        // record time response is at file responseBody5.xml
        RemoteInvocationResult RemoteInvocationResult_ArrayList5 =
            (RemoteInvocationResult)
        JavaHTTP.sendSerialized(RemoteInvocation_getUsernameList5, 5,
            "ObjectsDeserializerDefaultImpl",
            "OrderService-httpinvoker_4",
            "URL=http://my_server/jpetstore/remoting/OrderService-httpinvoker",
            new String[]{
                "Method=POST",
                "Resource=0",
                "RecContentType=application/x-java-serialized-object",
                "Referer=",
                "Mode=HTML",
                "EncType=application/x-java-serialized-object",
                LAST});
        }catch(Exception e){
            e.printStackTrace();
            return -1;
        }
        return 0;
    }

    static byte[] RemoteInvocationBA0;
    static byte[] RemoteInvocationBA1;
    static byte[] RemoteInvocationBA2;
    static byte[] RemoteInvocationBA3;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: