[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Httpapi and basic authentication
Hello,
I am trying to consume a web service that requires authentication. I
have been trying to do basic authentication, but I have not been able
to get it to work. I have attached an httpapi debug file and a program
file. Assuming the userid and password are correct, can anyone see
anything I am doing wrong? (I attempted to change all of the
identifying information in both files including the encoded userid and
password.)
Thanks,
Karen
HTTPAPI Ver 1.23 released 2008-04-24
OS/400 Ver V5R3M0
New iconv() objects set, PostRem=1208. PostLoc=0. ProtRem=819. ProtLoc=0
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry : 2
DNS resolver options: x'00000136'
DNS default domain: abc.com
DNS server found: xx.xxx.xx.xx
DNS server found: xx.xxx.xx.x
http_persist_post(): entered
http_long_ParseURL(): entered
do_post(): entered
POST /AxAifLive/customerservice.svc HTTP/1.1
Host: webserver1.xyz.com:83
User-Agent: http-api/1.23
Content-Type: text/xml;charset=utf-8
Expect: 100-continue
Content-Length: 528
SOAPAction: http://schemas.microsoft.com/dynamics/2008/01/services/CustomerService/GetCustomerInfo
recvresp(): entered
HTTP/1.1 100 Continue
SetError() #13: HTTP/1.1 100 Continue
senddoc(): entered
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><CustomerServiceGetCustomerInfoRequest xmlns="http://schemas.microsoft.com/dynamics/2008/01/services"><AifAccountNumList xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/AifAccountNumList"><AifAccountNum><AccountNumValue>001904</AccountNumValue></AifAccountNum></AifAccountNumList></CustomerServiceGetCustomerInfoRequest></s:Body></s:Envelope>
recvresp(): entered
HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/7.0
X-AspNet-Version: 2.0.50727
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="webserver1.xyz.com"
X-Powered-By: ASP.NET
Date: Thu, 12 Feb 2009 23:44:09 GMT
Content-Length: 1293
SetError() #13: HTTP/1.1 401 Unauthorized
recvdoc parms: identity 1293
interpret_auth(): entered
SetError() #36: This page requires a user-id & password
http_close(): entered
http_setauth(): entered
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry : 2
DNS resolver options: x'00000136'
DNS default domain: abc.com
DNS server found: xx.xxx.xx.xx
DNS server found: xx.xxx.xx.x
http_persist_post(): entered
http_long_ParseURL(): entered
do_post(): entered
POST /AxAifLive/customerservice.svc HTTP/1.1
Host: webserver1.xyz.com:83
User-Agent: http-api/1.23
Content-Type: text/xml;charset=utf-8
Expect: 100-continue
Content-Length: 528
Authorization: Basic ZFI2YXRvcHJdefR1c2EvYWlmLXNfffZpY7UtTTT2OkF2ACB0YTIwMDk=
SOAPAction: http://schemas.microsoft.com/dynamics/2008/01/services/CustomerService/GetCustomerInfo
recvresp(): entered
HTTP/1.1 100 Continue
SetError() #13: HTTP/1.1 100 Continue
senddoc(): entered
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><CustomerServiceGetCustomerInfoRequest xmlns="http://schemas.microsoft.com/dynamics/2008/01/services"><AifAccountNumList xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/AifAccountNumList"><AifAccountNum><AccountNumValue>001904</AccountNumValue></AifAccountNum></AifAccountNumList></CustomerServiceGetCustomerInfoRequest></s:Body></s:Envelope>
recvresp(): entered
HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/7.0
X-AspNet-Version: 2.0.50727
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="webserver1.xyz.com"
X-Powered-By: ASP.NET
Date: Thu, 12 Feb 2009 23:44:09 GMT
Content-Length: 1293
SetError() #13: HTTP/1.1 401 Unauthorized
recvdoc parms: identity 1293
interpret_auth(): entered
SetError() #36: This page requires a user-id & password
http_close(): entered
*
* To Compile (requires V5R1):
* CRTBNDRPG PGM(GETCUSTDUE) SRCFILE(library/QRPGLESRC)
*
* To Run:
* CALL GETCUSTDUE PARM('123456' 0)
* (Get A/R balance for customer 123456.)
*
H DFTACTGRP(*NO) BNDDIR('HTTPAPI':'QC2LE')
D GETCUSTDUE PR ExtPgm('GETCUSTDUE')
D Cust# 6A const
D Amount 15P 5 const
D GETCUSTDUE PI
D Cust# 6A const
D Amount 15P 5 const
/copy httpapi_h
D Incoming PR
D ARBal 8F
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 65535A varying const
D attrs * dim(32767)
D const options(*varsize)
D Add_SOAPACTION PR
D Header 1024A varying
D UserData * value
D SOAP s 32767A varying
D rc s 10I 0
D err s 10I 0
D ARBal s 8F
D Result s 12P 2
D userid S 50A
D pass S 50A
D msg S 50A
/free
*inlr = *on;
http_debug(*ON);
http_XmlStripCRLF(*ON);
SOAP =
'<s:Envelope'
+' xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">'
+'<s:Body'
+' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
+' xmlns:xsd="http://www.w3.org/2001/XMLSchema">'
+'<CustomerServiceGetCustomerInfoRequest'
+' xmlns="http://schemas.microsoft.com/dynamics/2008/01/services">'
+'<AifAccountNumList'
+' xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents'
+'/AifAccountNumList">'
+'<AifAccountNum>'
+'<AccountNumValue>' + %trim(Cust#) + '</AccountNumValue>'
+'</AifAccountNum>'
+'</AifAccountNumList>'
+'</CustomerServiceGetCustomerInfoRequest>'
+'</s:Body>'
+'</s:Envelope>';
HTTP_setCCSIDs(1208: 0); // CCSID 1208 = UTF-8
// do post
http_xproc( HTTP_POINT_ADDL_HEADER
: %paddr(Add_SOAPACTION) );
rc = http_url_post_xml(
'http://webserver1.xyz.com:83/AxAifLive/customerservice.svc'
: %addr(SOAP) + 2
: %len(SOAP)
: *NULL
: %paddr(Incoming)
: %addr(ARBal)
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml;charset=utf-8');
if (rc <> 1);
http_error(err);
if (err <> HTTP_NDAUTH);
msg = HTTP_ERROR;
dsply msg;
return;
endif;
// set password
userid = 'domain/username';
pass = 'password';
http_setauth(HTTP_AUTH_BASIC:userid:pass);
// do post again
http_xproc( HTTP_POINT_ADDL_HEADER
: %paddr(Add_SOAPACTION) );
rc = http_url_post_xml(
'http://webserver1.xyz.com:83/AxAifLive/customerservice.svc'
: %addr(SOAP) + 2
: %len(SOAP)
: *NULL
: %paddr(Incoming)
: %addr(ARBal)
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml;charset=utf-8');
if (rc <> 1);
http_error(err);
msg = HTTP_ERROR;
dsply msg;
else;
Result = %dech(ARBal: 12: 2);
http_comp(%trim(Cust#) + ' Bal = ' + %char(Result));
endif;
else;
Result = %dech(ARBal: 12: 2);
http_comp(%trim(Cust#) + ' Bal = ' + %char(Result));
endif;
/end-free
P Incoming B
D Incoming PI
D ARBal 8F
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 65535A varying const
D attrs * dim(32767)
D const options(*varsize)
D atof PR 8F extproc('atof')
D string * value options(*string)
/free
if (name = 'ARBalance');
ARBal = atof(value);
endif;
/end-free
P E
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* HTTPAPI will call this (because we set it with http_xproc)
* just before sending the HTTP headers to the remote server.
* This procedure lets us add any header we like to the
* HTTP request.
*
* In this example, I'll use it to supply the SoapAction:
* header. This way, I can supply a SOAPAction that's up to
* 1024 characters long.
*
* NOTE: Make sure you leave off the SOAPAction header on the
* HTTP_url_post_xml, above, otherwise you'll send two
* of them!
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P Add_SOAPACTION B
D Add_SOAPACTION PI
D Header 1024A varying
D UserData * value
/free
Header = 'SOAPAction: '
+ 'http://schemas.microsoft.com/dynamics/2008/01/services/CustomerServ+
ice/GetCustomerInfo'
+ x'0d25';
/end-free
P E
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------