I’m trying to communication (with my Fez Cobra) with a service.asmx in SOAP which returns me a description associated to a code (2639 for exemple), including an image jpg.
But the service answer me with a XML description. And my XmlReader only allows me to read strings. So i read my image as a string and I do not know how to convert it to my byte[] which I use to draw my bimap.
I do not need a “normal” conversion from string to byte, as UTF8 or ASCII because in my string I already have the proper values for the byte array. So if I use those, the byte array is not good (for example, I received /9j/… so my string is “/9j/…” and I do not want my byte[] to look like {0x2F, 0x39, …} but as I look on other images loaded from my SD card {0xFF, 0xD8, 0xFF…}
Clue : I have a collegue which maked it works once, but he do not remember the line he wrotte. It was one line I guess, maybe with a “Convert” ?
And sorry because I forgot an other method I used, quite similar to yours. But the point is that this method also gives me an ascii conversion from char to byte.
So your byte array will be {0x41, 0x42, 0x43, 0x44} where I want it to be… I do not know but so it can be used for a bitmap…
So I need to copy the string into the byte, but wihout ascii conversion.
My other method:
public static byte[] ConvertStringToBytes(string input)
{
MemoryStream stream = new MemoryStream();
using (StreamWriter writer = new StreamWriter(stream))
{
writer.Write(input);
writer.Flush();
}
return stream.ToArray();
}
You need to figure out how you want to convert the string and show an example. There are plenty of ways beside regular ASCII to byte conversion. Here are some examples of converting a string “12”:
Yes because before the service becomes a service it was a WebServer.
But then it can send me directly the byte[]. Now it is changed into an Asmx Service, I have no choice that to received it through a SOAP enveloppe, which means XML. But the data in it is still the same.
Or maybe I have to find how to decode the XML part from the stream in a byte[] way to keep the stream ina byte[] and not be disturbed by the XMLReader and its ReadString()…
When I receive my byte[] through the SOAP XML Envelope in byte[] instead of XML, the byte[] is really encoded as a string {0x41, 0x42, 0x43, 0x44 } in your method.
So the UTF8 method are all right to recoved what is send by the service.
But then this byte[] is different from the one I received by the WebServer and makes the DrawImage go on exception…
So do you have any idead of what I have to do on this SOAP byte[] to draw my bitmap with ??
I think you have to investigate how to send binary data in a SOAP envelope. Forget about .NET MF for know and try to make a proof of concept using only .NET Framework application.
Well, unfortunately it seems it is the method “FromBase64String” which takes all this time : I have a breakpoint before and another one after to check the buffer I get and I do not get it…