[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: WSDL2RPG web service login questions
Michael,
The built-in authentication features completely relies on the HTTPAPI
authentication mechanism. So in case your web service uses BASIC or DIGEST
authentication, you can use the authentication support of WSDL2RPG. For any
other kind of authentication you need to do it on your own.
There is a FAQ that describes how to use the
YourWebServicePort_supplyLoginData() callback procedure:
http://tools400.de/Downloads/Freeware/Tools/FAQ/wsdl2rpg/FAQ_Proxy_and_HTTP_Server_requires_Authentication_v1.1.pdf
In short words, you have to implement the callback procedure and register
it for your web service stub. When WSDL2RPG encounters that the web service
requires authentication, it call the registered callback procedure to get
the user name and password. The prototype of the callback procedure is
predefined in the stub module. It looks like this (taken from sample WS0001):
*
* User callback to supply login information
* Returns WSDL_SUCCESS if successful, WSDL_ERROR upon error.
*
* Parameter description:
* i_authType Authentication type:
* WSDL_AUTH_TYPE_HTTP - HTTP server.
* WSDL_AUTH_TYPE_PROXY - Proxy server.
* i_realm Authentication realm.
* i_numAttempts Number of login attempts.
* o_user UserName to use.
* o_password Password to use.
*
D ZipCodeSoap_supplyLoginData...
D PR 10I 0
D extproc('+
D ZipCodeSoap+
D _supplyLoginData+
D ')
D i_authType 14A const varying
D i_realm 126A const varying
D i_numAttempts 10I 0 const
D o_user 50A varying
D o_password 50A varying
And here is how to register the callback procedure:
ZipCodeSoap_Port_registerLoginCallback(
%paddr('ZipCodeSoap_supplyLoginData'))
Maybe it is a good idea to add that procedure to your generated stub module
(not the operation module!). This way you can use it for all operations of
the web service.
Although it is not very elegant you may register the procedure in
YourWebServicePort_getEndpoint(). That procedure is called right before
sending the request:
// eXpat: Post request and parse response
url = ZipCodeSoap_Port_getEndpoint();
dou (err <> HTTP_NDAUTH and err <> HTTP_PXNDAUTH);
// Get document from server and handle http redirects
// 301 Moved Permanently
// 302 Found
// 303 See Other
// 307 Temporary Redirect
dou (not isRedirect);
http_DebugLog_appendText(
'** Sending request to server at: ' + %char(%timestamp()));
rc = http_url_post_raw2(
So the first line of getEndpoint() could be:
ZipCodeSoap_Port_registerLoginCallback(
%paddr('ZipCodeSoap_supplyLoginData'))
For the next beta I am going to add a ZipCodeSoap_Port_initialize()
procedure to better support initialization of the web service port.
The is no general answer for the best default values. Actually I thought
that 128 works well most of the times. You can always tweak these values
for each array or element after having generated the stub.
For arrays:
Search the array and identify the DIM_Ax constant that is used for the
array and which defines the number of elements of the array. Change it to a
more reasonable size and recompile everything.
For elements:
Identify the name of the element and search for 'nameOfElement_t'. The '_t'
fields are reference fields. Then change 'nameOfElement_t' to, e.g. 12500
and recompile everything.
The following FAQ covers that problem:
http://tools400.de/Downloads/Freeware/Tools/FAQ/wsdl2rpg/FAQ_What_to_do_in_case_of_a_RNF0501_compiler_error_message_v1.0.pdf
Hope that helps.
Regards,
Thomas.
Am 18.01.2012 16:13, schrieb Koester, Michael:
> My initial proof-of-concept work was done on 1.14beta11 / 23.07.2011. I'm now moving forward using 1.15beta4 / 08.01.2012, and having a bit of trouble making the transition. The web service I'm consuming is for communicating with a piece of communications hardware. It is accessed within our VPN tunnel, but still requires a user/password login. In the previous version, I accomplished that by inserting the userid and password into the URL, just ahead of the IP address. That worked fine. In the new version, I noticed some procedures to handle login, and I should probably use those instead? I just don't know how.
>
> I generated stubs for the "getInventoryObjectNames()" operation in the "Inventory" web service (stub names WS_INVEN05 and WS_INVEN)
> In the base member, WS_INVEN, there's a Inventory_Port_login subprocedure, where I suspect I need to insert logic to supply the values to the local "userid" and "password" fields. Are there other values I need to supply (i.e. basic, digest, realm, authType) as well? Is there something else I need to do to enable this feature?
>
> On another but unrelated question, do you have any guidance on what to specify for the "Default array dimension" and "Default string length"? One of the operations in the web service returns a 2-column table of 177 rows, where a one of the columns contains a string exceeding 12500 characters in a couple rows.
>
> Our IBM i is now on 7.1.
>
> This tool set is an incredible help to my project.
> Many thanks for your development and support.
>
> Michael Koester
> -----------------------------------------------------------------------
> 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
-----------------------------------------------------------------------