views:

804

answers:

2

I am trying to sent a byte array from my Blackberry application to a .NET webservice (asmx).

I am using the Sun Java Wireless Toolkit (WTK) 2.5.2 to generate the webservice stubs to use within the Blackberry solution. The WTK project settings are producing the stubs using the JSR 172 specification.

I have created the Webservice using .NET 2005, using the following method:

[WebMethod]
public string UploadImage(byte[] Data, string Name)
{
  //do stuff
}

I generate the stubs from the WSDL of this webservice but I am receiving: "error: Found unknown simple type: byte[]". I've used this method of generating stubs and I've not received any errors before, granted all input variables have been simple types but I've used this to return arrays of custom objects. When I check the WSDL file the type is base64Binary.

Is there something I can use other than the byte array to pass the data in? Or is there some sort of setting that I am missing to allow the webservice to take it a byte array? Any help is greatly appreciated.

+1  A: 

The best thing to do is probably just specify the parameter as a String. Base64 is ASCII representation of binary data.

chrish
+1  A: 

Hi fermin,

you have the declare your method with String instead of byte[]. Than you can use the following snippet on the client side:

byte[] chunk = ...; String data= Base64OutputStream.encodeAsString(chunk, 0, chunk.length, false, false); UploadImage(data, name)

and on the server side you can use:

byte[] byteArray; byteArray = Base64.decode(data);

hope that helps

bibodo