Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ file service SOAP
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 1:19am
Edited 16-Apr-13 1:28am
cchubz at 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, 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 at 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 at 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
0 Sergey Alexandrovich Kryukov 9,578
1 OriginalGriff 8,420
2 Peter Leow 4,874
3 Kornfeld Eliyahu Peter 3,240
4 Maciej Los 2,356

Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 16 Apr 2013
Copyright © CodeProject, 1999-2015
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