Search code examples
androidwcfksoap2

How to send multiple parameter from android to wcf server using ksoap2


I am making a application using wcf web service.

I want to send multiple parameter but only thing I know is like this

request.addProperty("Fahrenheit",txtData.getText().toString());

So how to do that?

Below is part of my wcf code.

public string GetFirstName(byte[] source, int height, int width)
    {
        Bitmap bitmap = ImageTypeConverter.ArrayToImage(source, height, width);
        bitmap.Save(Environment.CurrentDirectory + "test" + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);

        return "ImageSaveComplete";
    }

As you see I want to pass byte array and integer value.

Please let me know the answer.


Solution

  • To send multiple parameters, strings, integers, etc:

    SoapObject request = new SoapObject(NAMESPACE, METHOD);
    
        PropertyInfo variableHeight = new PropertyInfo(); 
    
        variableHeight.setName("height");
        variableHeight.setValue(value); // your variable value
        variableHeight.setType(Integer.class); // if its string type change to String.class
        request.addProperty(variableHeight);
    
        PropertyInfo variableWidth = new PropertyInfo();
    
        variableWidth.setName("width");
        variableWidth.setValue(value);
        variableWidth.setType(Integer.class);
        request.addProperty(variableWidth);
    

    But for sending byte arrays im not sure, look at this : http://code.google.com/p/ksoap2-android/issues/detail?id=116