How to pass an image to Jmeter web service call - web-services

Hi I m using JMeter to test a web service and I want to pass an image to that POST type web- Service using Jmeter.
Actually that Web Service takes the image in the form of byte array and I want that I will pass image to jmeter either by referencing image path or any other possible way and that image should be converted to byte array and that byte array I can pass to the WEB Service.
Please note that I know how to call the web service with simple parameter.

Check out
Need to send Byte Array through Webservice in jmeter question for solution
and How to use BeanShell: JMeter's favorite built-in component for explanation

Related

Test webservice method for object types of data

I have a web service containing a method with object type data. When I want to test this method using the webservice api it suggests like,
The test form is only available for methods with primitive types as parameters.
So, I am not able to test the service by passing object type data.
Is there any way simpler to test such method ? Any links, blogs etc ?
I am using .NET technology.
One way is to write an integration test that points to your web service and sends a request to it.
It depends on the technology you're using, but in the .Net world you would generate a proxy and call methods on it from the test.
The is an add-in for firefox than can be useful for you.
HTTP Resource Test
You can tailor your own http request.
Just need to know how your object type data is XML serialized and create a XML SOAP request.

Send Complex data to Restful Web Service -- API design

I am trying to convert some of the SOAP based web services to Restful web services. In one of our existing SOAP based web service, we pass in a RequstDTO and the web service returns a ResponseDTO. The RequestDTO and ResponseDTO are both complex Java classes, which contain other custom JavaBean classes inside. It is a "READ" operation, so it naturally maps to the "GET" REST operation. Converting the ResponseDTO into XML or JSON has no issue. But I am not sure how to convert the RequestDTO into RESTful API.
The URL is going to be quite long, if I convert all the data in the RequestDTO into the query string. RESTful web service is usually consumed by application, thus the browser URL length limitation does not really apply. But a short URL is still preferred in most cases.
Some attributes in the RequestDTO might have PHI sensitive information and I prefer not to put them in the URL.
One solution is to embed the request data in the request body, even though it is a GET operation. But based on my research, such way is discouraged
http://tech.groups.yahoo.com/group/rest-discuss/message/9962
So what is the alternative? What is the right way to design this?
Im not exactly sure why you would need to pass the requestDTO to make the REST call.
Normally you just do something like this
GET /Resource/id
Now if the resource you want is like a secondary resource.. Example, you have a User and credit cards belonging to a user.
GET /User/{user_id}
GET /User/{user_id}/CreditCards/{credit_card_id}
And of course this can be nested however many times you want.

SOAP Web Service basics

am new on WS.
some simple questions in my mind, please try to solve it.
i did a demo WS for Calculator on calculator(), where it has one UI where i enter values for it, internally pass it to WS. Ok i got answer/output. but if i want to create only webservice which take/give xml data or just give xml data. how can i create it.
i found some WS URL's about some fame company. is it used by using by opening Connection. how they define this URL? am using MyEclipse10 when i went to create new WS, needed to use Java Bean class for create it. ok, if i create myWS url then how it ll get call? because it is JavaBean?
and if just want to create WS then i need not required to create New WS client?
i dont know it is simple or may be foolish question, when i walk on WS i stop here. i feel like , without basic knowledge started to build it.
please, clear it.
Thanx.
MyEclipse (as well as Eclipse, IBM D Developer, etc) let you create a Java Web service server in one of two ways:
Bottom up Java Bean: you supply a bean, it turns it into a WSDL (and generates the corresponding stub code)
Top down WSDL: you supply a WSDL, and it generates the corresponding stub code
When a company creates a web page, they set up a web server and publish some HTML pages on it.
When a company publishes a WSDL, they also set up a web server ... and publish an XML WSDL on it.
The URL you go to in order to read a WSDL is just an ordinary HTTP web server, that happens to be serving an XML WSDL at that location.
The WSDL specifies where the service can be found, and what operations and data types the service uses. A WSDL you create, or a WSDL that's published by some other company.
'Hope that helps

Spring webservices how to pass file bytes

I am trying to write a spring webservices which will be used to pass a file as byte[] value. Is this possible using webservice? Can anybody show an example in any website? I have searched a lot and i could not find one. PLease help.
You have several options:
mtom specification, supported e.g. in jaxb, looks like in spring-ws as well: Stream MTOM Web Services in Spring Web Services Framework
there are special data types in xml-schema to handle with binary data, see: JAXB (un)marshalling of xsd types: xsd:base64Binary and xsd:hexBinary
finally you can serialize this data yourself to text format (e.g. using base64) and pass as part of the request using simple xsd:string type

Windows Phone 7 - Upload file (Image)

I have been trying to upload an image from WP7 to a server for a few days now but it's not going too well.
I can easily get the input stream for the image and convert it to a byte array but I can't figure out how to send the byte array...Does it have to be done using a web service?
I've been struggling to send the byte array using the web service because the maxReceivedMessageSize is always set to 65536 and I have tried so many ways to increase the size of it.
The maxReceivedMessageSize is easy to fix in the configuration on the server.
Another way you could do it is to just make an asp.net mvc action which accepts a post, and just post it as a file.
Have a look at these other questions on the same subject:
Uploading an image using C# and WebRequest?
and
Upload files with HTTPWebrequest (multipart/form-data)