Hi Navaz -- 

Just to expand Shane's point a bit... HTTP is 8-bit clean, and there
should be no problem inserting binary data in CDATA sections as
suggested: 
        <binaryData><![CDATA[${byteString}]]></binaryData>

But if the binary data (in '${byteString}') ever contained ']]', the XML
will be no longer well-formed. This is put well here:
http://www.cdatazone.org/index.php?/archives/4-CDATA-and-encryptedbinary
-data.html

So it's preferable to hex or base-64 encode the data. However, as
base-64 encoding never uses ']' or even '&', you can skip the CDATA
altogether and do something like this: 
        
<base64EncodedBinaryData>${base64EncodedByteString}</base64EncodedBina
ryData>

Regards,
Sonam Chauhan
-----Original Message-----
From: Shane Petroff [mailto:[EMAIL PROTECTED] 
Sent: Friday, 20 June 2008 2:22 PM
To: JMeter Users List
Subject: Re: unable to send a SOAP request with byte[] - request doesn't
show in Jmeter at run.

Khan Navaz wrote:
> once I place the byte[] in vars.putObject() how can I retrieve it in
the
> SOAP request,
>   

(Large grain of salt) I've never used either SOAP or Beanshell, but I 
don't see how you can append straight binary data into a SOAP request 
regardless of how you retrieve it. CDATA is _Character_ data by 
definition. If you want to pass binary over http, you'll have to encode 
it (presumably base64).


> Sebb, take your time you dont have to reply in 2 sec, pls read the
whole
> chain. For god sake dont send in hurry.
>   

Glass houses and rocks...

> On Thu, Jun 19, 2008 at 5:30 PM, sebb <[EMAIL PROTECTED]> wrote:
>
>   
>> On 20/06/2008, Khan Navaz <[EMAIL PROTECTED]> wrote:
>>     
>>> I am a newbie, I tried
>>>  <binaryData><![CDATA[vars.getObject("byteString")]]></binaryData>
>>>
>>>       
>> That's not a beanshell function call.
>>
>>     
>>>  also tried vars.getObject("byteString") in Request - Pre processor
bean
>>>  shell, it doesnt work :(
>>>       
>> Have you checked the log?
>>
>>     
>>>  also the jmeter.log has NUL NUL sometimes.
>>>       
>> If you want a sensible reply to that you'll have to provide a bit
more
>> detail.
>>
>>     
>>>  On Thu, Jun 19, 2008 at 4:42 PM, sebb <[EMAIL PROTECTED]> wrote:
>>>
>>>  > On 20/06/2008, Khan Navaz <[EMAIL PROTECTED]> wrote:
>>>  > > *BeanShell:*
>>>  > >  String file =
>>>  > >
Path+"/data/abcService/common/deep_foldered_images_in_zip.zip";
>>>  > >  byte[] byteArray;
>>>  > >  byte[] byteString;
>>>  > >
>>>  > >   try {
>>>  > >     byteArray = IOUtils.toByteArray(new FileInputStream(file));
>>>  > >       } catch (IOException e){
>>>  > >     e.printStackTrace();
>>>  > >   }
>>>  > >
>>>  > >  vars.putObject("byteString",byteArray);
>>>  > >
>>>  > >  *SOAP Request:*
>>>  > >  <soapenv:Envelope xmlns:soapenv="
>>>  > http://schemas.xmlsoap.org/soap/envelope/";
>>>  > >  xmlns:sec="http://schemas.xmlsoap.org/ws/2002/07/secext";>
>>>  > >    <soapenv:Header>
>>>  > >       .........
>>>  > >    </soapenv:Header>
>>>  > >    <soapenv:Body>
>>>  > >       <add>
>>>  > >          <binaryData><![CDATA[${byteString}]]></binaryData>
>>>  >
>>>  > Variable references can only be strings.
>>>  >
>>>  > You'll need to use a beanshell function to recover the data:
>>>  >
>>>  > vars.getObject("byteString")
>>>  >
>>>  > >       </add>
>>>  > >    </soapenv:Body>
>>>  > >  </soapenv:Envelope>
>>>  > >
>>>  > >  *C:\home\y\logs\jmeter\jmeter.log*
>>>  > >  2008/06/19 15:34:13 ERROR - jmeter.threads.JMeterThread:
>>>  > >  java.lang.ClassCastException: [B cannot be cast to
java.lang.String
>>>  > >  at
>>>  >
org.apache.jmeter.threads.JMeterVariables.get(JMeterVariables.java:98)
>>>  > >  at
>>>  > >
>>>  >
>>>       
>>
org.apache.jmeter.engine.util.SimpleVariable.toString(SimpleVariable.jav
a:53)
>>     
>>>  > >  at
>>>  > >
>>>  >
>>>       
>>
org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.
java:133)
>>     
>>>  > >  at
>>>  > >
>>>  >
>>>       
>>
org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.
java:97)
>>     
>>>  > >  at
>>>  > >
>>>  >
>>>       
>>
org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(F
unctionProperty.java:85)
>>     
>>>  > >  at
>>>  > >
>>>  >
>>>       
>>
org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(Ab
stractTestElement.java:200)
>>     
>>>  > >  at
>>>  > >
>>>  >
>>>       
>>
org.apache.jmeter.protocol.http.sampler.SoapSampler.getXmlData(SoapSampl
er.java:66)
>>     
>>>  > >  at
>>>  > >
>>>  >
>>>       
>>
org.apache.jmeter.protocol.http.sampler.SoapSampler$2.getContentLength(S
oapSampler.java:202)
>>     
>>>  > >  at
>>>  >
>>>       
>>
org.apache.commons.httpclient.methods.EntityEnclosingMethod.getRequestC
>>     
>>>  > >
>>>  >
>>>
>>>       
>>>>
---------------------------------------------------------------------
>>>>         
>>>  > To unsubscribe, e-mail:
[EMAIL PROTECTED]
>>>  > For additional commands, e-mail:
[EMAIL PROTECTED]
>>>  >
>>>  >
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>     
>
>   


-- 
Shane


The information contained in this email and any attached files are strictly
private and confidential. This email should be read by the intended addressee
only.  If the recipient of this message is not the intended addressee, please
call Corporate Express Australia Limited on +61 2 9335 0555 or Corporate Express
New Zealand Limited on +64 9 279 2555 and promptly delete this email and any
attachments.  The intended recipient of this email may only use, reproduce,
disclose or distribute the information contained in this email and any attached
files with Corporate Express' permission. If you are not the intended addressee,
you are strictly prohibited from using, reproducing, disclosing or distributing
the information contained in this email and any attached files.  Corporate
Express advises that this email and any attached files should be scanned to
detect viruses. Corporate Express accepts no liability for loss or damage
(whether caused by negligence or not) resulting from the use of any attached
files.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to