06-14-06 12:16 AM
BizTalk picks up a file from a directory, sends it contents to a web
service, and the web service is supposed to write the contents to a file.
I'm doing something wrong because the output file written by the webservice
isn't the same as the input file. I've created a method which gets the
binary data from an incomming message of type XmlDocument and Base64 encodes
it. The webservice decodes the base64 encode string and saves the file. I'm
not sure what is going wrong. when I debut it. I know that the byte array
is the same length before encoding as after encoding, so characters must be
getting stripped out. Any ideas?
public static string Encode64(Microsoft.XLANGs.BaseTypes.XLANGMessage
rawMessage)
{
System.IO.StreamReader pReader = new
System.IO.StreamReader((System.IO.Stream)rawMessage[0].RetrieveAs(typeof
(System.IO.Stream)));
return
System.Convert.ToBase64String(pReader.CurrentEncoding.GetBytes(pReader.ReadT
oEnd()));
}
[WebMethod]
public string SendBinary(string strFileName, string strData)
{
byte[] binData = System.Convert.FromBase64String(strData);
string strFileWrite =
System.IO.Path.Combine(this.Context.Request.PhysicalApplicationPath,
System.IO.Path.GetFileName(strFileName));
System.IO.FileStream pWrite = System.IO.File.OpenWrite(strFileWrite);
try
{
pWrite.Write(binData,0,binData.Length);
}
finally
{
pWrite.Flush();
pWrite.Close();
}
}
"BizTalkVirtuoso" <ben.mcfarlin@biztalkvirtuoso.com> wrote in message
news:1150222074.760326.187530@g10g2000cwb.googlegroups.com...
> Exactly. Also use the BinaryReader object to get the byte array from
> the Stream.
>
> Ben McFarlin
> Microsoft BizTalk Server Consultant
> www.biztalkvirtuoso.com
>
[ Post a follow-up to this message ]
|