Share this page

# JavaHTTP.sendSerialized

Serializes an object and sends it synchronously on HTTP with the given options.

Java over HTTP Vuser Functions

    public static Object sendSerialized(Object obj, int fileNumber, String serializerName, String stepName, String urlAddress, String[] options, boolean performErrorChecking) throws HttpException, IOException

## Arguments

Argument | Description
--- | ---
obj | An object.
fileNumber | The ordinal number of the header file.
serializerName | The serialization method.
stepName | The name of the step, as it appears in the test tree. Any text can be used.
urlAddress | The URL of the service that receives the object.
options | The invocation options to be passed to the server.
performErrorChecking | true to perform validation. If not passed, uses the value of the system property, validateNoException.

Common options are:

"Method=POST",

"Resource=0",

"RecContentType=application/x-java-serialized-object",

"Referer=",

"Mode=HTML",

"EncType=application/x-java-serialized-object",

## 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 Function Reference 26.1 All View Local Help Center View Online Help Center Version: