c# 4.0 - c# send pdf file from web service -
i new c# , have web service generates pdf file containing barcode(using datamatrix). want send pdf file on client byte[]
the web service contract follows:
[webinvoke(method="get", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.bare ,uritemplate = "/mymethod?param1={param1}¶m2={param2}")] byte[] mymethod(string param1, string param2)
at client side, read response memory stream , convert array , write file.
memorystream ms = new memorystream(); httpwebrequest request = (httpwebrequest)webrequest.create(url); request.getresponse().getresponsestream().copyto(ms); byte[] responsebytes = ms.toarray(); httpcontext.current.response.outputstream.write(responsebytes, 0, responsebytes.length);
the data written file [37,80,25,....] actual byte[] sent web service.
i have gone through many answers here not figure out how actual bytes @ client side. appreciated.
i figured out answer myself.
i used memory stream @ server side , loaded byte[] it.
at client side, read memory stream , byte[] stored within it.
Comments
Post a Comment