cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using webservice method consumer proxy with rawdata from abap

Former Member
0 Kudos

Hello Gurus,

I am struggling with an error using a proxy consumer service from ABAP. The proxy was generated using the WSDL from the web service provider. For a specific method we need to send a rawstring as seen bellow:

The file to be sent on this call is a ZIP file XAdES-BES signed and on BASE64. I’ve implemented the proper code to get the original file from local PC, and convert it to BASE64 before moving the content to the webservice structure and call the service proxy. At SOAMANAGER I also configured the webservice and the proper port with the WSDL:

The communication is working properly but my problem is with the binary content. When calling the webservice the response is that the structure of the file is wrong. I found it very strange since I used a tiny SOAPUI project with the same WSDL and it worked with no problem.

After debugging I could see that the content moved to the rawdata string before calling the proxy does not match the content that I can see from the call payload on web services util (srt_util)!

So the sample code for my method:

* get the file from the specified folder
call function 'GUI_UPLOAD'
exporting
filename               
= ld_zipfilename
filetype               
= 'BIN'
importing
filelength             
= zip_size
tables
data_tab               
= t_zip_data[]
exceptions
file_open_error        
= 1
file_read_error        
= 2
no_batch               
= 3
gui_refuse_filetransfer
= 4
invalid_type           
= 5
no_authority           
= 6
unknown_error          
= 7
bad_data_format        
= 8
header_not_allowed     
= 9
separator_not_allowed  
= 10
header_too_long        
= 11
unknown_dp_error       
= 12
access_denied          
= 13
dp_out_of_memory       
= 14
disk_full              
= 15
dp_timeout             
= 16
others                  = 17.


* convert to string
clear buffer_zip.
call function 'SCMS_BINARY_TO_STRING'
exporting
input_length
= zip_size
importing
text_buffer 
= buffer_string
tables
binary_tab  
= t_zip_data[]
exceptions
failed      
= 1
others       = 2.

* encode base 64
perform encode_base64 using buffer_string
buffer_zip
. 

form encode_base64 using in_string type string
out_string
type xstring.

data: l_sbuff     type string.

* convert the file to BASE64
call method cl_http_utility=>encode_base64
exporting
unencoded
= in_string
receiving
encoded  
= l_sbuff.

call function 'SCMS_STRING_TO_XSTRING'
exporting
text   = l_sbuff
importing
buffer = out_string
exceptions
failed
= 1
others = 2.


endform.                    "encode_base64

calling the webservice:

l_input-xxxx-dokument = buffer_zip.

try.
call method l_proxy_test->webservice
exporting
input  = l_input
importing
output = l_output.

catch cx_ai_soap_fault into lr_exc_soap_fault.

    endtry.

From my understanding rawstring should be the same as ABAP xstring. If I debug the program and check the content of the  l_input-dokument before calling the proxy I get binary content: “Izw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9InV0Zi04Ij8…” that is in fact correct

If I check the payload after call I can see that the binary content sent on the XML is not the same, in fact it is totally different: ”SXp3L2VHMXNJSFpsY25OcGIyNDlJakV1TUNJZ1pXNWpiMlJw…” !!

I’ve tried a lot of different conversions, changed configuration on the communication, port, etc and nothing seems to work. I really can’t figure out why the binary content on the call is not the same as I move to the webservice structure.

If I use the project from SOAP UI and send the proper binary content, that is “Izw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9InV0Zi04Ij8…” it works perfectly and the response is successfully.

Anyone has a clue what could be causing this?

Appreciate any kind of input.

Regards,

João Silva Pinto.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Anyone? Any clue would be appreciated.

Former Member
0 Kudos

Hi Pedro.

I'm developer .NET and I was with similar problem.

I needed from a WS to generate PDF file to use in a Website.

We can't use GUI_DOWNLAOD,  because this function must be called from GUI Interface Application.

But, you can export XSTRING (byte[] in C#, Java...) to convert it in other extension (ZIP, PDF etc) in you destination application.

My solution for this:

" Chama o converter de OTF

   CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

     EXPORTING

       src_spoolid              = i_spoolno

       no_dialog                = ' '

*     DST_DEVICE               =

       pdf_destination          = 'X'

     IMPORTING

       pdf_bytecount            = numbytes

       pdf_spoolid              = pdfspoolid

*     OTF_PAGECOUNT            =

       btc_jobname              = jobname

       btc_jobcount             = jobcount

       bin_file                 = lv_bin_file

     TABLES

       pdf                      = pdf

     EXCEPTIONS

       err_no_otf_spooljob      = 1

       err_no_spooljob          = 2

       err_no_permission        = 3

       err_conv_not_possible    = 4

       err_bad_dstdevice        = 5

       user_cancelled           = 6

       err_spoolerror           = 7

       err_temseerror           = 8

       err_btcjob_open_failed   = 9

       err_btcjob_submit_failed = 10

       err_btcjob_close_failed  = 11.

  " Gera o array de bytes ** Generates byte[].

   CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

     EXPORTING

       buffer     = lv_bin_file

     TABLES

       binary_tab = pdf.

  " Variavel export do tipo XSTRING ** Variable XSTRING

   e_binario = lv_bin_file.



I hope this has helped you.

Former Member
0 Kudos

Hey Euclides,

Thank you for your input. I already tried some conversions on the binary content as you mention.

My problem is that the binary content that I pass on to the ABAP proxy get's changed somehow before the call. As I showed on the printscreens above the binary content I see on the payload is different from the one I am providing to the structure when calling the proxy.

Regards.