使用c ++将文件从客户端发送到Web服务

问题描述:

您好!我有一个c ++客户端源代码如下:

hello! i have a c++ client source code as follows :

// prepare request data
Client_Operation::Client_OperationServiceRequest^ request = gcnew Client_Operation::Client_OperationServiceRequest();
System::IO::FileStream^ wcstream = gcnew System::IO::FileStream (gcnew System::String ( "D:\\sample.zip" ), System::IO::FileMode::Open);
System::IO::BinaryReader^ wcbin = gcnew System::IO::BinaryReader (wcstream );
request->fileBytes = wcbin->ReadBytes (wcstream->Length);

// call service
Client_Operation::Client_OperationService^ service = gcnew Client_Operation::Client_OperationService();
Client_Operation::Client_OperationServiceResponse^ response = service->clientRequest( request);



这些源代码可以读取并发送一个zip文件到Web服务(服务器使用java)。

在客户端,sample.zip中的数据被正确读取并存储到request-> fileBytes。



但是,request-> fileBytes的值在何时更改在服务器端检索。

有没有人知道如何将zip文件字节发送到服务器?



对不起,我是c ++的新手所以我很难修理这个。



任何评论/建议都非常感谢。



谢谢!


these source codes are suppose to read and send a zip file to the web service (the server is using java).
in the client side, data in sample.zip are read properly and stored to request->fileBytes.

however, value of request->fileBytes changes when retrieved in server side.
does anyone know how to send zip file bytes to server?

im sorry, i am new to c++ so im having a hard time fixing this one.

any comment/suggestion is highly appreciated.

thanks!

您好,



您需要在base64中对文件进行编码,然后再将其发送给webservice。

从网络服务端(服务器端),需要从base64解码文件。



干杯,

JAFC
Hi,

You will need to encode your file in base64 BEFORE send it to the webservice.
From the webservice side (server side), it is necessary to decode the file from base64.

Cheers,
JAFC