Troubleshooting
Problem
By default, the C/C++ stubs generated by the IWS Client tool WSDL2Ws do not support URL redirects. The Web service client must handle them explicitly.
Resolving The Problem
By default, the C/C++ stubs generated by the IWS Client tool WSDL2Ws do not support URL redirects. The Web service client must handle them explicitly.
To enable a Web service client to handle URL redirects automatically, you will need to invoke an API. The C version of the API is:
axiscStubSetTransportAutoRedirect().
The prototype for that function is listed here:
void axiscStubSetTransportAutoRedirect(AXISCHANDLE stub, AxiscBool handleRedirect, int maxCount);
o The first parameter is the pointer to the Web service.
o The second parameter is an integer indicating whether redirection is to be enabled (by passing a non-zero value) or disabled (by passing 0). The default is 0.
o The third parameter is an integer indicating how many redirects to follow before stopping.
In C++, redirects can be enabled by setting the following properties in the transport. They are located in:
<install directory>/include/axis/GDefine.hpp.
/**
* Whether redirect should be handled implicitly. Values can be "true" or "false".
* The default is false. Redirects will only be implicitly be handled if going from
* http:// to http:// or https:// to https://.
*/
ENABLE_AUTOMATIC_REDIRECT,
/**
* Maximum number of automatic redirects to follow. Property should be a numeric string.
* Default is 1. If "0" is specified, it will be as if ENABLE_AUTOMATIC_REDIRECT is set to
* false.
*/
MAX_AUTOMATIC_REDIRECT
Here are some examples of using the API:
Examples
(Note: the links provided in the samples are for illustration purpose only)
C:
//Create the web service stub
AXISCHANDLE ws = get_ConvertTempPortType_stub("http://lp12ut8:40100/web/services/ConvertTempRedirect");
//Enable Redirects
axiscStubSetTransportAutoRedirect(ws, 1, 2);
RPG:
//Prototype to create stub handle (Necessary for AXIS client)
DgetStub PR * ExtProc('get_CENTSTODOLLARS+
D ServicesDelegate+
D _stub')
D pchEndPointUri...
D * Value Options(*String)
//Prototype to Enable Redirects
DSetRedirect PR ExtProc('axiscStubSetTransport+
D AutoRedirect')
D pStub * Value
D enableRedirect 10I 0 Value
D numRedirects 10I 0 Value
//The Web Service stub
DConvertsWS S *
/Free
//Create the web service stub
ConvertsWS = getStub('http:/'+
'/RCHASK60:10201/Converts/CENTSTODOLLARSServicesService');
//Enable Redirects
SetRedirect(ConvertsWS : 1 : 2);
.......
//Other Code here
.......
/End-Free
Note: Automatic redirects will only happen, if enabled, when going from http:// to http:// or https:// to https://. Anything else will result in an exception.
To enable a Web service client to handle URL redirects automatically, you will need to invoke an API. The C version of the API is:
axiscStubSetTransportAutoRedirect().
The prototype for that function is listed here:
void axiscStubSetTransportAutoRedirect(AXISCHANDLE stub, AxiscBool handleRedirect, int maxCount);
o The first parameter is the pointer to the Web service.
o The second parameter is an integer indicating whether redirection is to be enabled (by passing a non-zero value) or disabled (by passing 0). The default is 0.
o The third parameter is an integer indicating how many redirects to follow before stopping.
In C++, redirects can be enabled by setting the following properties in the transport. They are located in:
<install directory>/include/axis/GDefine.hpp.
/**
* Whether redirect should be handled implicitly. Values can be "true" or "false".
* The default is false. Redirects will only be implicitly be handled if going from
* http:// to http:// or https:// to https://.
*/
ENABLE_AUTOMATIC_REDIRECT,
/**
* Maximum number of automatic redirects to follow. Property should be a numeric string.
* Default is 1. If "0" is specified, it will be as if ENABLE_AUTOMATIC_REDIRECT is set to
* false.
*/
MAX_AUTOMATIC_REDIRECT
Here are some examples of using the API:
| Caution: These are examples only. IBM accepts no responsibility for their correctness. |
Examples
(Note: the links provided in the samples are for illustration purpose only)
C:
//Create the web service stub
AXISCHANDLE ws = get_ConvertTempPortType_stub("http://lp12ut8:40100/web/services/ConvertTempRedirect");
//Enable Redirects
axiscStubSetTransportAutoRedirect(ws, 1, 2);
RPG:
//Prototype to create stub handle (Necessary for AXIS client)
DgetStub PR * ExtProc('get_CENTSTODOLLARS+
D ServicesDelegate+
D _stub')
D pchEndPointUri...
D * Value Options(*String)
//Prototype to Enable Redirects
DSetRedirect PR ExtProc('axiscStubSetTransport+
D AutoRedirect')
D pStub * Value
D enableRedirect 10I 0 Value
D numRedirects 10I 0 Value
//The Web Service stub
DConvertsWS S *
/Free
//Create the web service stub
ConvertsWS = getStub('http:/'+
'/RCHASK60:10201/Converts/CENTSTODOLLARSServicesService');
//Enable Redirects
SetRedirect(ConvertsWS : 1 : 2);
.......
//Other Code here
.......
/End-Free
Note: Automatic redirects will only happen, if enabled, when going from http:// to http:// or https:// to https://. Anything else will result in an exception.
[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CJLAA2","label":"Integrated Application Server"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]
Historical Number
557062371
Was this topic helpful?
Document Information
Modified date:
01 May 2025
UID
nas8N1012356