Click here to Skip to main content
13,044,115 members (83,581 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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:\\" ), 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);

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 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.

Posted 16-Apr-13 0:19am
Updated 16-Apr-13 0:28am
cchubz 17-Apr-13 1:37am
thank you very much José, you rocked..

For others wondering: The solution is simple.
C++ side (managed)
System::Convert::ToBase64String(array<unsigned char>, 0, length)

then in java part

José is right about the soap standard about binary base64 encoding.


1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


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.

Matthew Faithfull 16-Apr-13 6:33am
Nice but the obvious question is why? Why is the base64 encoding necessary?
Binary files could have characters that are not allowed by soap protocol.
Matthew Faithfull 16-Apr-13 8:48am
Thanks José, now many people can learn from your answer and I can vote it up.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 16 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100