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

Re: Basic authentication fails probably because of Base64 enconding



Mirco,

Please check the content of your "username" field. When I decode the Base64 string I get the following result:

00000000: 62 75 62 69 40 65 78 61 6d 70 6c 65 2e 6f 72 67 bubi@xxxxxxxxxxx
00000010: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
00000020: 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ...............
00000030: 00 00 3a                                        ..:

The colon is added by HTTPAPI but the blanks and NULL values must come from your "username" field:

Snippet from http_setauth():

   eval      wwString = %trimr(peUserName) + ':' +
                        %trimr(pePasswd)
   callp     http_xlate( %len(%trimr(wwString))
                       : wwString
                       : TO_ASCII )

   eval      wwEncLen = base64_encode(%addr(wwString):
                             %len(%trimr(wwString)):
                             %addr(wwEncoded):
                             %size(wwEncoded))


Thomas.


Am 04.12.2012 14:11, schrieb Mirco Andreon:
    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
-----------------------------------------------------------------------