Pipeline variables and parameters

When I call a service B from service A, the pipeline of service A is available to service B. If input parameter of service B has same name as of pipeline variable. e.g. a variable POHeader exists in service A pipeline before call to service B and the input parameter of service B has same name and structure as POHeader. The variable gets automatically mapped to service B input parameter.

How does webMethods handles this POHeader variable? Are there 2 instances of POHeader in memory or it is just passed by reference?
How does service A pipeline variables made available to service B - separate copy of variables or reference to original variables? If reference to original variables then when we drop the variables in service B, then is only the reference dropped or the original variables are also dropped?

If I have POHeader structure consisting of 25 variables, but the service B requires only 3 of those variables, then what is the best practice -

  1. to pass complete POHeader structure and let service B extract required 3 parameters or
  2. to pass only the 3 parameters

One thought I have with respect to option 2 above is passing 3 parameters only will make 3 more variables created in memory and passed as value, thus increasing the memory requirements. Also it will require me to drop these variables after call to service B.
Where as with option 1 the structure will be passed by reference, hence reducing the memory requirement. But the code readability may decrease as another developer will not know the 3 variables actually utilised without going through code / comment (if any).
But with option 2, if tomorrow I need to add one more parameter, then the complete service signature changes and all the dependent services are affected by it.

What is the best practice?

-Vandy

This is straight out of the Developer’s guide:
“The Integration Server copies by value when the source or target variable is a String. (An exception to this behavior is that when executing a link from a String to an Object, the Integration Server copies by reference.)
When executing links between all other types of variables, the Integration Server copies by reference. Copying by reference significantly reduces the memory and time required for executing a link at run time.”

I’d say that 3 parameters are few enough that you should pass them separately. However, if you see your service maybe needing any other variables from the POHeader structure in the future, then you may just want to pass the whole structure now to save yourself some time in the future.