Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/03/2009, 17:34
enrrike
 
Fecha de Ingreso: septiembre-2006
Mensajes: 55
Antigüedad: 18 años, 6 meses
Puntos: 0
Mensaje Respuesta: WebService que retorene PDF

Hola miguelillo2:

Gracias por la respuesta me sirvio de mucho, ya solucione el problema, el metodo que se usa para convertir el reporte pdf a string es

public void EncodeWithString()
{
System.IO.FileStream inFile;
byte[] binaryData;

try {
inFile = new System.IO.FileStream(inputFileName,
System.IO.FileMode.Open,
System.IO.FileAccess.Read);
binaryData = new Byte[inFile.Length];
long bytesRead = inFile.Read(binaryData, 0,
(int)inFile.Length);
inFile.Close();
}
catch (System.Exception exp) {
// Error creating stream or reading from it.
System.Console.WriteLine("{0}", exp.Message);
return;
}

// Convert the binary input into Base64 UUEncoded output.
string base64String;
try {
base64String =
System.Convert.ToBase64String(binaryData,
0,
binaryData.Length);
}
catch (System.ArgumentNullException) {
System.Console.WriteLine("Binary data array is null.");
return;
}

// Write the UUEncoded version to the output file.
//System.IO.StreamWriter outFile;
//try {
// outFile = new System.IO.StreamWriter(outputFileName,
// false,
// System.Text.Encoding.ASCII);
// outFile.Write(base64String);
// outFile.Close();
//}
//catch (System.Exception exp) {
// Error creating stream or writing to it.
// System.Console.WriteLine("{0}", exp.Message);
//}
}

esto es sacado de la ayuda de visual: http://msdn.microsoft.com/en-us/library/dhx0d524.aspx

Luego ya el cliente que consume el Servicio Web va utilizar algo asi:

string stringbytes = servicio.RetornarPDFString(parametro);

byte[] a = Convert.FromBase64String(stringbytes);
System.IO.MemoryStream rptStream = new System.IO.MemoryStream(a);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment;filename=reporte.pdf");
Response.BinaryWrite(rptStream.ToArray());
Response.End();