[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Basic authentication fails probably because of Base64 enconding



I would try putting the "varying" keyword in the keywords

C                   parm email            50                           varying

Thank you
Sunil

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mirco Andreon
Sent: Tuesday, December 04, 2012 10:15 AM
To: HTTPAPI and FTPAPI Projects
Subject: Re: Basic authentication fails probably because of Base64 enconding

*I found the real problem*: I was treating SOAP request and response as if they wrapped XML as a string (with < and > encoding) and not as real XML. So it is even simpler than I thought.
I'm sorry if I made loose your time reading about my issue...

Anyway this is the *last question*:
I have an input param for my program:

    C                   parm email            50

I use it in HTTP authentication:

    http_setAuth( HTTP_AUTH_BASIC : %trim(email) : '');

but seems like %trim doesn't work... it passes a string like 
'aaa@xxxxxxx         ' followed by invalid chars...
Moreover, if they pass an empty string for email param, I would like to *set a default value *for it ('bubi@xxxxxxxxxxx'). I tried this:

    if %trim(email) = *blanks;
       email = 'bubi@xxxxxxxxxxx';
    endif;

but doesn't enter if-block.
Could give me an hint? I'm new to RPGLE. Thanks!

Mirco Andreon
==========================================
Il 04/12/2012 14:11, Mirco Andreon ha scritto:

>     More info: it seems not to be an encoding problem. If I try with a
>     string literal instead of a variable
>     http_setAuth( HTTP_AUTH_BASIC : '[1]bubi@xxxxxxxxxxx' : '');
>     the encoding is ok (YnViaUBleGFtcGxlLm9yZzo=).
>     So this is not the problem. All seems the same now on both Web Services
>     Explorer and HTTPAPI, but the latter doesn't work (always Bad Request).
> Mirco Andreon
>
> Il 04/12/2012 11:02, Mirco Andreon ha scritto:
>
>     Hello, I'm trying to invoke this web service:
>
>       WSDL: [2]http://www.nexusonline.it:8088/4DWSDL
>       endpoint: [3]http://www.nexusonline.it:8088/4DSOAP/
>       instructions: [4]http://www.nexusonline.it:8088/esempio4d
>       method: Get_BankFromCAB
>           parameters:
>               ABI, 5 chars code
>               CAB, 5 chars code
>       Authentication: basic with an email as username and an empty string
>       as password
>
>     This is how Eclipse Web Services Explorer allows me to invoke it
>     (following is Wireshark capture of the HTTP request):
>
>       POST /4DSOAP/ HTTP/1.1
>       Host: [5]www.nexusonline.it:8088
>       Content-Type: text/xml; charset=utf-8
>       Content-Length: 590
>       Accept: application/soap+xml, application/dime, multipart/related,
>       text/*
>       User-Agent: IBM Web Services Explorer
>       Cache-Control: no-cache
>       Pragma: no-cache
>       SOAPAction: "Nexus_WebService#Get_BankFromCAB"
>       Authorization: Basic YnViaUBleGFtcGxlLm9yZzo=
>       Connection: close
>
>     [SOAP envelope omitted, because it's like mine]
>     and it works.
>     This is how I invoke it by HTTPAPI:
>
>       http_setAuth( HTTP_AUTH_BASIC : %trim(email) : '');
>       rc = http_url_post(
>                           '[6]http://www.nexusonline.it:8088/4DSOAP/'
>                         : %addr(SoapReq)+2
>                         : %len(SoapReq)
>                         : soapfile
>                         : HTTP_TIMEOUT
>                         : HTTP_USERAGENT
>                         : 'text/xml; charset=utf-8'
>                         : '"Nexus_WebService#Get_BankFromCAB"' );
>
>     and it doesn't work.
>     This is an extract from '/tmp/httpapi_debug.txt':
>
>       POST /4DSOAP/ HTTP/1.1
>       Host: [7]www.nexusonline.it:8088
>       User-Agent: http-api/1.24
>       Content-Type: text/xml; charset=utf-8
>       SOAPAction: "Nexus_WebService#Get_BankFromCAB"
>       Content-Length: 594
>       Authorization: Basic
>       
> YnViaUBleGFtcGxlLm9yZyAgICAgICAgICAgICAgICAgAAAAAAAAAAAAAAAAAAAAAAA6
>
>     [if I read further I can see SOAP response saying
>     <SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Bad
>     Request.</SOAP-ENV:Fault>]
>     The only difference I see is Authorization parameter. I always use
>     username [8]"bubi@xxxxxxxxxxx" and empty password, but seems HTTPAPI is
>     encoding in a slightly different way. Also putting double-quotes in
>     SOAP action seems strange to me but I don't think it's the problem.
>     Any help is appretiated, thanks!
> --
> Mirco Andreon
>
> References
>
>     1. mailto:bubi@xxxxxxxxxxx
>     2. http://www.nexusonline.it:8088/4DWSDL
>     3. http://www.nexusonline.it:8088/4DSOAP/
>     4. http://www.nexusonline.it:8088/esempio4d
>     5. http://www.nexusonline.it:8088/
>     6. http://www.nexusonline.it:8088/4DSOAP/
>     7. http://www.nexusonline.it:8088/
>     8. mailto:bubi@xxxxxxxxxxx
>
>
>
> ----------------------------------------------------------------------
> - This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> ----------------------------------------------------------------------
> -

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------