Michael,I modified your stub and program source to properly retrieve and display the response values of your "Inventory" web service.
For sure modifying the generated source is not a trivial task and requires some knowledge about web services and the way WSDL2RPG works. But I hope that my sample will enable you to successfully generate a RPG client for your next web service. It is not trivial but also not too hard. If I was you I would use a source compare utility like "WinMerge" and start with comparing the old and new source members to understand the changes. Using a PC utility is more effective than CMPPFM.
The output of KOESTER1T (test pgm) is: DSPLY 1 DSPLY 124 DSPLY WL_COUNTRY=WL_COUNTRY_US 1 = Number of elements of "getProfilesReturn" 124 = Number of map entriesPlease notice that the changed stub module is somewhat quick & dirty because it will not work in case the map contains multi-ref items such as "getProfilesReturn". If you want to make sure that the stub module also works for multi-ref map items, please try to modify the wsdl file and generate the stub from that because it is too hard to tweak the source by hand. Maybe the owner of the web service is willing to help you with that.
Thomas. Am 22.08.2011 17:16, schrieb Koester, Michael:
Thanks so much for your time and efforts, Thomas. Tried to follow the recommendation to adjust the impl_item_of_anyType_t... to a data structure, but the compiler caught me on the need to change four occurrences where other subprocedures had local definitions referring to that same "impl_item_of_anyType_t" structure. Those were "curItem_of_anyType_A1" in subproc, "Inventory_getProfiles", "currentItem" and "emptyItem" in subproc, "impl_item_of_anyTypeStart_of_impl_getProfilesRpc", and "currentItem" in subproc, "impl_item_of_anyTypeEnd_of_impl_getProfilesRpc". I changed those fields to "likeds" data structures as well, but still could not get past the compiler. In subproc, "impl_item_of_anyTypeEnd_of_impl_getProfilesRpc" I get "RNF0229: *DATA is not valid with %ADDR..." on the call to UnMarshaller_toStringV6. Sadly, I may be in over my head here. I have not yet tried to download and modify the WSDL, but that may be my next effort. Again, thanks for all you're doing here. My project will require accessing a number of similar web services, and I'm really hoping I can leverage your tools to a meet those needs. -- Michael Koester Below is my stub, as modified. (Today's changes are tagged with "22") /IF NOT DEFINED(PROTOTYPE_TSTINVEN01) *====================================================================== * Generated by WSDL2RPG 1.14beta11 / 23.07.2011 * Built on Aug 18, 2011 (13:20:52) * Built for V6R1M0 * Based on WS_STUB v1.14 *====================================================================== * * Please search for 'INFO:' to get basic information how to call * the web service. * * Default attachment handling (for demonstration) was added to * WS_STUB but is disabled by default. * * In order to enable or disable default attachment handling you have * to define or undefine the following compiler condition name: * DEFAULT_ATTACHMENT_HANDLING /UNDEFINE DEFAULT_ATTACHMENT_HANDLING * * By default attachments are stored in folder: * '/tmp/attachments' * * You can change the default attachment folder by calling the * following procedure before calling the web service: * Inventory_setAttachmentFolder() * * Default attachment handling was added to demonstrate how * to manage attachments. Please search the generate stub * module for 'TODO:' to see what code belongs to attachment * support. * * Log4rpg: /UNDEFINE LOGGING_SERVICE * *====================================================================== * Pre-Compiler tags used by STRPREPRC to retrieve creation * commands from the source member. * --------------------------------------------------------------------- *>>PRE-COMPILER<< *>>CRTCMD<< CRTRPGMOD MODULE(&LI/&OB) + * SRCFILE(&SL/&SF) + * SRCMBR(&SM); *>>COMPILE<< *>>PARM<< TRUNCNBR(*NO); *>>PARM<< DBGVIEW(*LIST); *>>END-COMPILE<< *>>EXECUTE<< *>>CMD<< CRTSRVPGM + * SRVPGM(&LI/&OB) + * MODULE(&LI/&OB) + * EXPORT(*ALL) + * BNDSRVPGM(*LIBL/WSDL2RPGRT + * *LIBL/MIME + * *LIBL/HTTPMIME + * *LIBL/BASICS1) + * TEXT('+ * Web Service: getProfiles()+ * ') + * DETAIL(*BASIC); *>>END-PRE-COMPILER<< *====================================================================== H NOMAIN H DEBUG H BNDDIR('HTTPAPI' : 'QC2LE' : 'TFSUTILS') H OPTION(*SRCSTMT : *NODEBUGIO) H EXTBININT(*YES) /ENDIF * * INFO: * This is the procedure you call to consume the Web Service: * ---------------------------------------------------------- * Operation: impl:getProfiles * Returns : impl_getProfilesRpc * * INFO: * Include fields in your test/production programs referring to the *_t * type templates used in this prototype, using a LIKE(*_t) or LIKEDS(*_t). * These fields will be your request and response messages. * D Inventory_getProfiles... D PR likeds(impl_getProfilesRpc_t) D extproc('Inventory_getProfiles') D i_in0 likeds(apachesoap_Map_t) D o_msg like(wsdl_errText_t ) * * Array dimensions: D DIM_A1 C 256 D DIM_A2 C 256 * * Types: * D apachesoap_mapItem_t... D DS template D qualified D key 4096A varying D value 4096A varying * * D apachesoap_Map_t... D DS template D qualified D item likeds(apachesoap_RpgArrayOfItem_t) * * D apachesoap_RpgArrayOfItem_t... D DS template D qualified D x 10I 0 D mapItem likeds(apachesoap_mapItem_t) D dim(DIM_A2) * * D impl_getProfilesRpc_t... D DS template D qualified D getProfilesReturn... D likeds(impl_RpgArrayOfArrayOf_xsd_... D anyType_t) * D impl_item_of_anyType_t... 22 D DS template 22 D x 10i 0 22 D key 64a 22 D value 256a 22 D* S 4096A varying 22 D* template * D impl_RpgArrayOfArrayOf_xsd_anyType_t... D DS template D qualified D x 10I 0 22 D item likeds(impl_item_of_anyType_t) D dim(DIM_A1) /IF DEFINED(LOGGING_SERVICE) * * Starts the Log4rpg logging service. D Inventory_startLoggingService... D PR D extproc('+ D Inventory+ D _startLoggingService+ D ') D i_path const like(LOG4RPG_path_t ) D options(*nopass) D i_waitMinutes 10I 0 const options(*nopass) D i_unit 10A const options(*nopass) /ENDIF * * Web service: Enables/disables the debug log of HTTP API D Inventory_setHttpDebug... D PR D extproc('+ D Inventory+ D _setHttpDebug+ D ') D i_status N const D i_fileName 500A const varying options(*nopass) * * Web service: Sets the proxy server to use for the connection D Inventory_setProxy... D PR D extproc('+ D Inventory+ D _setProxy+ D ') D i_server 256A const D i_port 10I 0 const * * Web service: Returns the endpoint of the Web service D Inventory_getEndpoint... D PR 32767A varying D extproc('+ D Inventory+ D _getEndpoint+ D ') * * Web service: Sets the endpoint of the Web service D Inventory_setEndpoint... D PR D extproc('+ D Inventory+ D _setEndpoint+ D ') D i_url 32767A const varying options(*varsize) * * Web service: Returns the host name of the Web Service endpoint D Inventory_getHost... D PR 32767A varying D extproc('+ D Inventory+ D _getHost+ D ') * * Web service: Sets the host name of the Web service endpoint D Inventory_setHost... D PR D extproc('+ D Inventory+ D _setHost+ D ') D i_url 32767A const varying options(*varsize) * * Web service: Returns the port of the Web Service endpoint D Inventory_getPort... D PR 10I 0 D extproc('+ D Inventory+ D _getPort+ D ') * * Web service: Sets the port of the Web service endpoint D Inventory_setPort... D PR D extproc('+ D Inventory+ D _setPort+ D ') D i_port 10I 0 const * * Registers an user callback procedure, that is called whenever * a web service requires user authentification. D Inventory_registerLoginCallback... D PR D extproc('+ D Inventory+ D _registerLoginCallback+ D ') D i_pLoginProc * value procptr * * Http: Returns cTrue in case of an error, else cFalse. D Inventory_isError... D PR N D extproc('+ D Inventory+ D _isError+ D ') * * Http: Returns the last HTTP error (code) that occurred. D Inventory_HttpError_getCode... D PR like(wsdl_http_ErrorNo_t ) D extproc('+ D Inventory+ D _HttpError_getCode+ D ') * * Http: Returns the last HTTP error (text) that occurred. D Inventory_HttpError_getText... D PR like(wsdl_http_ErrorText_t) D extproc('+ D Inventory+ D _HttpError_getText+ D ') * * Soap: Returns the last SOAP error (code) that occurred. D Inventory_SoapError_getCode... D PR like(wsdl_soap_faultcode_t ) D extproc('+ D Inventory+ D _SoapError_getCode+ D ') * * Soap: Returns the last SOAP error (text) that occurred. D Inventory_SoapError_getText... D PR like(wsdl_soap_faultstring_t) D extproc('+ D Inventory+ D _SoapError_getText+ D ') * * Soap: Returns the last XML error (code) that occurred. D Inventory_XmlError_getCode... D PR like(wsdl_xml_errorNo_t ) D extproc('+ D Inventory+ D _XmlError_getCode+ D ') * * Soap: Returns the last XML error (text) that occurred. D Inventory_XmlError_getText... D PR like(wsdl_xml_ErrorText_t ) D extproc('+ D Inventory+ D _XmlError_getText+ D ') * * Returns the file name of the attachment that is associated to * a given content ID. D Inventory_Attachments_get... D PR like(wsdl_path_t ) D extproc('+ D Inventory+ D _Attachments_get+ D ') D i_attachmentID... D const like(wsdl_attachmentID_t ) * * Returns the file name of the attachment that is associated to * a given index. D Inventory_Attachments_getAtPos... D PR likeds(wsdl_attachment_t ) D extproc('+ D Inventory+ D _Attachments_getAtPos+ D ') D i_index 10I 0 const * * Returns the number of attachments that were downloaded with the * last call to the web service. D Inventory_Attachments_getNumE... D PR 10I 0 D extproc('+ D Inventory+ D _Attachments_getNumE+ D ') * * Removes all attachments from the list of attachments of this web service. D Inventory_Attachments_removeAll... D PR D extproc('+ D Inventory+ D _Attachments_removeAll+ D ') * * Enables/disables a workaround for Web services that are driven * by Axis and that are affected by the AXIS-2095 bug. D Inventory_enableAxis2095... D PR D extproc('+ D Inventory+ D _enableAxis2095+ D ') D i_isEnabled N const * * 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 Inventory_supplyLoginData... D PR 10I 0 D extproc('+ D Inventory+ 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 * * Specifies the name of the folder where to put attachments in. D Inventory_setAttachmentFolder... D PR D extproc('+ D Inventory+ D _setAttachmentFolder+ D ') D i_folder 1024A const varying options(*varsize) * CPY /COPY QWSDL2RPG,TYPES_H * /IF DEFINED(PROTOTYPE_TSTINVEN01) /EOF /ENDIF * --------------------------------------------------------------------- * CPY /COPY QBASICS1,PBASICS1 Tools/400 Runtime Library CPY /COPY QMIME,PMIME Tools/400 MIME Parser CPY /COPY QMIME,HTTPMIME_H Tools/400 MIME Parser to HTTP API adapter CPY /COPY QRPGLESRC,HTTPAPI_H HTTP-API Service Program CPY /COPY QWSDL2RPG,PWSDL2R70 WSDL2RPG: HTTP API Header Extensions CPY /COPY QWSDL2RPG,PWSDL2R71 WSDL2RPG: HTTP Debug Log CPY /COPY QWSDL2RPG,PWSDL2R86 WSDL2RPG: Stream CPY /COPY QWSDL2RPG,PWSDL2R87 WSDL2RPG: ManagedMemoryDataSource CPY /COPY QWSDL2RPG,PWSDL2R89 WSDL2RPG: List of attachments CPY /COPY QWSDL2RPG,PWSDL2R90 WSDL2RPG: AppMsg CPY /COPY QWSDL2RPG,PWSDL2R94 WSDL2RPG: MultiRef CPY /COPY QWSDL2RPG,PWSDL2R97 WSDL2RPG: eXpat Adapter CPY /COPY QWSDL2RPG,PWSDL2R98 WSDL2RPG: UnMarshaller/Marshaller CPY /COPY QWSDL2RPG,PWSDL2R42 WSDL2RPG: User name and password * /IF DEFINED(LOGGING_SERVICE) CPY /COPY QWSDL2RPG,PLOG4RPG Log4rpg: The Log4rpg service program CPY /COPY QWSDL2RPG,PLOG4RPG00 Log4rpg: The Log4rpg stub module /ENDIF * * ------------------------------------ * Internal prototypes * ------------------------------------ * * Reopens a given input stream in order to send it over * the wire again. D reOpenInputStream... D PR like(wsdl_hStream_t ) D extproc('+ D reOpenInputStream+ D ') D i_hDataSource const like(wsdl_hDataSource_t) D i_hInpStream value like(wsdl_hStream_t ) * * Login in to proxy server or http server. D login... D PR 10I 0 D extproc('+ D login+ D ') D i_http_err 10I 0 value D i_numAttempts 10I 0 value * * Sets the content type and the SOAP action of the POST message. D HTTP_setContentTypeAndSOAPAction... D PR D extproc('+ D HTTP_setContentTypeAndSOAPAction+ D ') D o_addlHdrs 1024A varying D i_pUserData * value * D impl_getProfilesRpcStart... D PR D extproc('impl_getProfilesRpcStart') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) D impl_getProfilesRpcEnd... D PR D extproc('impl_getProfilesRpcEnd') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying D attrs * dim(32767) D const options(*varsize) D impl_item_of_anyTypeStart_of_impl_getProfilesRpc... D PR D extproc('impl_item_of_anyTypeStart_o+ D f_impl_getProfilesRpc') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) D impl_item_of_anyTypeEnd_of_impl_getProfilesRpc... D PR D extproc('impl_item_of_anyTypeEnd_of_+ D impl_getProfilesRpc') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying D attrs * dim(32767) D const options(*varsize) * * Receice response of HTTP post operation. D HTTP_receiveResponse... D PR 10I 0 extproc('+ D HTTP_receiveResponse+ D ') D i_hStream 10I 0 value D i_data * value D i_length 10I 0 value * * SOAP message: Envelope D SOAPMessage_Envelope... D PR extproc('+ D SOAPMessage_Envelope+ D ') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * * SOAP message: fault information D SOAPMessage_FaultStart... D PR extproc('+ D SOAPMessage_FaultStart+ D ') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * * SOAP message: fault information D SOAPMessage_FaultEnd... D PR extproc('+ D SOAPMessage_FaultEnd+ D ') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying const D attrs * dim(32767) D const options(*varsize) * * SOAP message: fault details D SOAPMessage_FaultDetailStart... D PR extproc('+ D SOAPMessage_FaultDetailStart+ D ') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * * SOAP message: fault details D SOAPMessage_FaultDetailEnd... D PR extproc('+ D SOAPMessage_FaultDetailEnd+ D ') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying const D attrs * dim(32767) D const options(*varsize) * * SOAP message: NULL callback procedure D SOAPMessage_unexpectedElementStart... D PR D extproc('+ D SOAPMessage_unexpectedElementStart+ D ') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * * SOAP message: NULL callback procedure D SOAPMessage_unexpectedElementEnd... D PR D extproc('+ D SOAPMessage_unexpectedElementEnd+ D ') D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying const D attrs * dim(32767) D const options(*varsize) * D ignoreUnexpectedSoapHeader... D PR N D extproc('+ D ignoreUnexpectedSoapHeader+ D ') * DataEast customizations mk * Set the URL based on data in the EPequipmnt 'DSLAM' record mk D BuildURLfromEPequipmnt... mk D PR 32767a varying mk D extproc('DSLAM_URL') mk D WebServiceName 256a varying mk D const mk D LoginNeeded n const * ------------------------------------ * Global fields& constants * ------------------------------------ * * Web service port name D cWEB_SERVICE_PORT... D C 'Inventory' * * UUID of the web service as generated by WSDL2RPG D cSERVICE_UUID C '30A56001C640194DA35A0004AC101091' * * SOAP response header * * Reference to the 'respSoapHeader' field. D g_pRespSoapHeader... D S * inz * * XMLSAXParser handle D g_hSAXParser S like(xmlSaxParser_handle_t) inz * * MIME parser D g_hMIMEParser S like(mime_hMime_t ) inz * * MIME message indicator D g_isMimeMessage... D S N inz(cFalse) * * Content ID of the SOAP message part D g_SOAPMessageID... D S 512A varying inz * * Indicator "parse SOAP message" D g_doParseSOAPMessage... D S N inz(cFalse) * * Indicator "SOAP message parsed" D g_SOAPMessage_done... D S N inz(cFalse) * * Body part counter D g_BodyPart_counter... D S 10I 0 inz * * Default and current attachment folder D cATTACHMENT_FOLDER... D C '/tmp/attachments/' * D g_attachmentFolder... D S 1024A varying inz(cATTACHMENT_FOLDER) * * HTTP response "initialized" indicator D g_HTTP_isInit... D S N inz(cFalse) * * POST data CCSID (1208 = UTF-8) D g_post_ccsid... D S 10I 0 inz(1208) * * HTTP debug log settings D g_httpDebug DS qualified D status N inz D fileName 500A inz varying * * Proxy server to use D g_proxy DS qualified D server 256A inz D port 10I 0 inz * * Switch for AXIS bug AXIS-2095 D g_isAXIS_2095 S N inz(cFalse) * * Error information D g_errors DS likeds(wsdl_errors_t ) inz * * User callback to supply login information * Returns WSDL_SUCCESS if successful, WSDL_ERROR upon error. D g_getLoginDataImpl... D S * procptr inz * D getLoginDataImpl... D PR 10I 0 D extproc(g_getLoginDataImpl) 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 * * Web service endpoint as specified in the WSDL file. D cURL C 'http://192.168.41.252:9090/axis/ser+ D vices/Inventory' * * Web service endpoint D g_url S 32767A varying inz(cURL) * * ------------------------------------------- * TODO: Added to implement default * attachment handling. * ------------------------------------------- /IF DEFINED(DEFAULT_ATTACHMENT_HANDLING) CPY /COPY QWSDL2RPG,CLIB C Runtime Library * * User data scoped to the current part D partUserData_t... D DS qualified based(pDummy) D FD 10i 0 * /ENDIF * ===================================================================== * Operation: impl:getProfiles * Returns : impl_getProfilesRpc * ===================================================================== P Inventory_getProfiles... P B export D Inventory_getProfiles... D PI likeds(impl_getProfilesRpc_t) D i_in0 likeds(apachesoap_Map_t) D o_msg 128A varying * * Return value D rtnValue DS likeds(impl_getProfilesRpc_t) D inz * * Local fields D isUnexpectedError... D S N inz(cFalse) D isRedirect S N inz(cFalse) D request S 65535A varying inz D url S like(g_url) inz D rc S 10I 0 inz D rcvm0200 DS likeds(rcvm0200_t ) inz D msg DS likeds(msg_t ) inz D headers DS likeds(headers_t ) inz * D hDataSource S like(wsdl_hDataSource_t ) inz D hOutStream S like(wsdl_hStream_t ) inz D hSAXParser S like(xmlSaxParser_handle_t) inz D hMIMEParser S like(mime_hMime_t ) inz D hInpStream S like(wsdl_hStream_t ) inz D contentType S like(wsdl_contentType_t ) inz * * Login helper fields D err S 10I 0 inz D lastErr S 10I 0 inz(-1) D numAttempts S 10I 0 inz * * Array iterator fields D X_A1 S 10I 0 inz D X_A2 S 10I 0 inz * D curItem_of_anyType_A1... 22 D DS likeds(impl_item_of_anyType_t) D inz * D curMapItem_A2 DS likeds(apachesoap_mapItem_t) D inz * D userData DS likeds(impl_getProfilesRpc_t) D inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free // Set url to include login credentials mk g_url = BuildURLfromEPequipmnt('Inventory' : cTrue); mk if g_url = 'ERROR'; mk // unable to build the URL from the EPequipmnt record. mk // Use the default value in the cURL constant; mk g_url = cURL; mk endif; // ---- End DataEast custom code... o_msg = ''; monitor; // Initialize map to manage<multiRef> elements MultiRef_new(); // Remove all attachments of this service from the list of attachments Attachments_removeAll(Attachments_theInstance(): cSERVICE_UUID); // Enable/disable HTTP debug log B01 if (g_httpDebug.status = *ON); B02 if (g_httpDebug.fileName<> ''); http_debug(*ON: g_httpDebug.fileName); X02 else; http_debug(*ON); E02 endif; X01 else; http_debug(*OFF); E01 endif; // Set proxy server to use B01 if (g_proxy.server<> ''); http_setproxy(g_proxy.server: g_proxy.port); X01 else; http_setproxy('': 0); E01 endif; // Set CCSID for POST data according // to the encoding of the SOAP envelope HTTP_SetCCSIDs(g_post_ccsid: HTTP_EBCDIC); // Create and open data source to store the request message hDataSource = ManagedMemoryDataSource_new(); contentType = 'text/xml'; hOutStream = ManagedMemoryDataSource_OutputStream_open( hDataSource: contentType: g_post_ccsid); // Produce SOAP request message request = '<?xml version="1.0" encoding="UTF-8"?>' + '<soapenv:Envelope' + ' xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"' + ' xmlns:apachesoap="http://xml.apache.org/xml-soap"' + ' xmlns:impl="urn:Inventory"' + ' xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"' + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' + '>' + '<soapenv:Body>' + ''; if (%len(request)> 0); // Add previous bytes of request message to output stream ManagedMemoryDataSource_OutputStream_write(hOutStream: %addr(requ... est: *DATA): %len(request)); clear request; endif; request = request + '<impl:getProfiles' + ' soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/e+ ncoding/"' + '>' + '<in0' + ' xsi:type="apachesoap:Map"' + '>' + ''; if (%len(request)> 0); // Add previous bytes of request message to output stream ManagedMemoryDataSource_OutputStream_write(hOutStream: %addr(requ... est: *DATA): %len(request)); clear request; endif; for X_A2 = 1 to i_in0.item.x; curMapItem_A2 = i_in0.item.mapItem(X_A2); request = request + '<item' + ' xsi:type="apachesoap:mapItem"' + '>' + '<key>' + ''; if (%len(request)> 0); // Add previous bytes of request message to output stream ManagedMemoryDataSource_OutputStream_write(hOutStream: %addr( request: *DATA): %len(request)); clear request; endif; Marshaller_toAnyTypeV6( %addr(curMapItem_A2.key) : %addr(curMapItem_A2.key: *DATA) : %len(curMapItem_A2.key) : hOutStream); request = request + '</key>' + '<value>' + ''; if (%len(request)> 0); // Add previous bytes of request message to output stream ManagedMemoryDataSource_OutputStream_write(hOutStream: %addr( request: *DATA): %len(request)); clear request; endif; Marshaller_toAnyTypeV6( %addr(curMapItem_A2.value) : %addr(curMapItem_A2.value: *DATA) : %len(curMapItem_A2.value) : hOutStream); request = request + '</value>' + '</item>' + ''; if (%len(request)> 0); // Add previous bytes of request message to output stream ManagedMemoryDataSource_OutputStream_write(hOutStream: %addr( request: *DATA): %len(request)); clear request; endif; endfor; request = request + '</in0>' + '</impl:getProfiles>' + '</soapenv:Body>' + '</soapenv:Envelope>'; // Add remaining bytes of request message to output stream B01 if (%len(request)> 0); ManagedMemoryDataSource_OutputStream_write( hOutStream: %addr(request) + 2: %len(request)); E01 endif; // Close output stream and finish the request message ManagedMemoryDataSource_OutputStream_close(hOutStream); // Open input stream hInpStream = ManagedMemoryDataSource_InputStream_open(hDataSource); // Clear error code clear g_errors; g_errors.errType = WSDL_HTTP_SUCCESS; // HTTPAPI: Enables additional headers http_xproc(HTTP_POINT_ADDL_HEADER : %paddr('HTTP_setContentTypeAndSOAPAction') : %addr(headers)); headers.contentType = ManagedMemoryDataSource_getContentType(hDataSource); headers.soapAction = ''; // --------------------------------------- // Post request and parse response // --------------------------------------- // Create parser (callbacks style: HTTP API) XMLSAXParser_new(hSAXParser: cTrue); XMLSAXParser_setDoNamespaces(hSAXParser: cTrue); XMLSAXParser_registerCallback(hSAXParser : cXML_CB_SAX_STARTELEMENT : %paddr('SOAPMessage_Envelope')); XMLSAXParser_prepareParse(hSAXParser: %addr(userData)); // Create MIME parser in case we need it hMIMEParser = MIMEParser_new(); MIMEParser_setDecodeData(hMIMEParser: cTrue); http_mime_DataSink_initialize(hMIMEParser : *NULL : %paddr('HTTPDataSink_startPart') : %paddr('HTTPDataSink_bodyData') : %paddr('HTTPDataSink_endPart')); // Make parser available for HTTP_receiveResponse() g_hSAXParser = hSAXParser; g_hMIMEParser = hMIMEParser; g_isMimeMessage = cFalse; g_HTTP_isInit = cFalse; g_SOAPMessageID = ''; g_doParseSOAPMessage = cFalse; g_SOAPMessage_done = cFalse; g_BodyPart_counter = 0; // Make SOAP response header available to SOAPMessage_Envelope g_pRespSoapHeader = *NULL; // eXpat: Post request and parse response url = Inventory_getEndpoint(); B01 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 B02 dou (not isRedirect); rc = http_url_post_raw2( url : hInpStream : %paddr( 'WSDL2R87_ManagedMemoryDataSource_InputStream_read') : ManagedMemoryDataSource_getSize(hDataSource) : 0 : %paddr('HTTP_receiveResponse') : HTTP_TIMEOUT : HTTP_USERAGENT : ''); B03 if (rc = 301 or rc = 302 or rc = 303 or rc = 307); url = http_redir_loc(); // Reopen data stream hInpStream = reOpenInputStream(hDataSource: hInpStream); isRedirect = cTrue; X03 else; isRedirect = cFalse; E03 endif; E02 enddo; // The first time we request a document that requires user/password // it will return a HTTP_NDAUTH error. B02 if (rc<> 1); http_error(err); B03 if (err = HTTP_NDAUTH or err = HTTP_PXNDAUTH); B04 if (g_getLoginDataImpl = *NULL); leave; E04 endif; B04 if (err<> lastErr); lastErr = err; numAttempts = 0; E04 endif; numAttempts = numAttempts + 1; B04 if (login(err: numAttempts)<> 1); leave; E04 endif; // Reopen data stream hInpStream = reOpenInputStream(hDataSource: hInpStream); E03 endif; X02 else; MultiRef_finalize(); err = 0; E02 endif; E01 enddo; // Preserve parser error code and message text B01 if (err = HTTP_RDWERR); g_errors.xmlError.code = XMLToolkit_getError( hSAXParser : g_errors.xmlError.text : g_errors.xmlError.line : g_errors.xmlError.column); E01 endif; XMLSAXParser_endParse(hSAXParser); B01 if (g_isMimeMessage); MIMEParser_endParse(hMIMEParser); g_isMimeMessage = cFalse; E01 endif; g_HTTP_isInit = cFalse; on-error; isUnexpectedError = cTrue; rcvm0200 = f_rcvPgmMsg(cMsg_Any: *: cMsg_Act_Same: 0 : cMsg_Same: cMsg_ToMyself); http_DebugLog_appendRcvMsg(rcvm0200); msg = f_cvtRcvMsgToMsg(rcvm0200); g_errors.errType = WSDL_HTTP_ERROR_UNEXPECTED; g_errors.httpError.no = WSDL_HTTP_ERROR_UNEXPECTED; g_errors.httpError.text = f_rtvMsgText(msg); rc = g_errors.httpError.no; o_msg = g_errors.httpError.text; endmon; g_hSAXParser = *NULL; g_hMIMEParser = *NULL; B01 if (not isUnexpectedError); B02 if (err<> 0); g_errors.errType = WSDL_HTTP_ERROR; // Set http error code and message text g_errors.httpError.no = err; g_errors.httpError.text = http_error(); // Return error message text to caller B03 if (g_errors.httpError.text<> ''); o_msg = g_errors.httpError.text; X03 else; o_msg = Inventory_SoapError_getText(); E03 endif; clear rtnValue; else; o_msg = ''; rtnValue = userData; endif; E02 endif; B02 if (not XMLSAXParser_isNull(hSAXParser)); XMLSAXParser_delete(hSAXParser); E02 endif; B02 if (not MIMEParser_isNull(hMIMEParser)); MIMEParser_delete(hMIMEParser); E02 endif; B02 if (not ManagedMemoryDataSource_isNull(hDataSource)); B03 if (ManagedMemoryDataSource_Stream_isOpen(hInpStream)); ManagedMemoryDataSource_InputStream_close(hInpStream); E03 endif; B03 if (ManagedMemoryDataSource_Stream_isOpen(hOutStream)); ManagedMemoryDataSource_OutputStream_close(hOutStream); E03 endif; ManagedMemoryDataSource_delete(hDataSource); E02 endif; B02 if (not MultiRef_isNull()); MultiRef_delete(); E02 endif; B02 if (http_DebugLog_isOpen()); http_DebugLog_close(); E02 endif; return rtnValue; /end-free * P Inventory_getProfiles... P E * * * ================================================================== * Return value: impl:getProfilesRpc * ================================================================== P impl_getProfilesRpcStart... P B D impl_getProfilesRpcStart... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * D currentItem DS likeds(impl_getProfilesRpc_t) D based(pCurrentItem) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free // Get access to current item pCurrentItem = userdata; select; when (depth = 1 and name = 'getProfilesRpc'); if (MultiRef_isReference(attrs)); MultiRef_put( attrs : XMLSAXParser_getUserData() : depth : namespace : name : path : XMLSAXParser_getStartCallback() : XMLSAXParser_getEndCallback() : *omit : %addr(currentItem) : %size(currentItem) ); endif; return; when (depth = 2 and name = 'getProfilesReturn' and namespace = ''); XMLSAXParser_delegateElementProcessing( %addr(currentItem.getProfilesReturn) : %paddr('impl_item_of_anyTypeStart_of_impl_getProfilesRpc') : %paddr('impl_item_of_anyTypeEnd_of_impl_getProfilesRpc') ); return; endsl; return; /end-free * P impl_getProfilesRpcStart... P E * * ================================================================== * Return value: impl:getProfilesRpc * ================================================================== P impl_getProfilesRpcEnd... P B D impl_getProfilesRpcEnd... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying D attrs * dim(32767) D const options(*varsize) * D currentItem DS likeds(impl_getProfilesRpc_t) D based(pCurrentItem) * D itemValue DS likeds(wsdl_fullElementData_t) D inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free // Get access to current item pCurrentItem = userdata; // Get full element data itemValue = XMLSAXParser_getFullElementData(); select; endsl; return; /end-free * P impl_getProfilesRpcEnd... P E * * ================================================================== * Return value: impl:getProfilesReturn * ================================================================== P impl_item_of_anyTypeStart_of_impl_getProfilesRpc... P B D impl_item_of_anyTypeStart_of_impl_getProfilesRpc... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * D x S 10I 0 inz * D impl_getProfilesReturn... D DS likeds(impl_RpgArrayOfArrayOf_xsd_... D anyType_t) D based(userdata) * 22 D currentItem DS likeds(impl_item_of_anyType_t) D based(pCurrentItem) * 22 D emptyItem DS likeds(impl_item_of_anyType_t) D inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free // Return to caller if array is SOAP encoded. // Depth=1 indicates that we are at the top // of the array but not on item level. if (depth = 1); if (MultiRef_isReference(attrs)); MultiRef_put( attrs : XMLSAXParser_getUserData() : depth : namespace : name : path : XMLSAXParser_getStartCallback() : XMLSAXParser_getEndCallback() : *omit : %addr(impl_getProfilesReturn) : %size(impl_getProfilesReturn) ); endif; return; endif; // Get access to current array item if (MultiRef_doCaptureData() and MultiRef_hasItemIndex()); x = MultiRef_getItemIndex(); else; if (depth = 2); impl_getProfilesReturn.x = impl_getProfilesReturn.x + 1; endif; x = impl_getProfilesReturn.x; endif; pCurrentItem = %addr(impl_getProfilesReturn.item(x)); select; when (depth = 2); if (MultiRef_isReference(attrs)); MultiRef_put( attrs : XMLSAXParser_getUserData() : depth : namespace : name : path : XMLSAXParser_getStartCallback() : XMLSAXParser_getEndCallback() : x : %addr(currentItem) : %size(currentItem) ); endif; return; endsl; return; /end-free * P impl_item_of_anyTypeStart_of_impl_getProfilesRpc... P E * * ================================================================== * Return value: impl:getProfilesReturn * ================================================================== P impl_item_of_anyTypeEnd_of_impl_getProfilesRpc... P B D impl_item_of_anyTypeEnd_of_impl_getProfilesRpc... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying D attrs * dim(32767) D const options(*varsize) * D x S 10I 0 inz * D impl_getProfilesReturn... D DS likeds(impl_RpgArrayOfArrayOf_xsd_... D anyType_t) D based(userdata) * 22 D currentItem DS likeds(impl_item_of_anyType_t) D based(pCurrentItem) * D itemValue DS likeds(wsdl_fullElementData_t) D inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free // Return to caller if array is SOAP encoded. // Depth=1 indicates that we are at the top // of the array but not on item level. if (depth = 1); return; endif; // Get access to current array item if (MultiRef_doCaptureData() and MultiRef_hasItemIndex()); x = MultiRef_getItemIndex(); else; x = impl_getProfilesReturn.x; endif; pCurrentItem = %addr(impl_getProfilesReturn.item(x)); // Get full element data itemValue = XMLSAXParser_getFullElementData(); select; when (depth = 2); if (not Value_isNil(attrs)); UnMarshaller_toStringV6( %addr(currentItem) : %addr(currentItem: *DATA) : %size(currentItem) : itemValue.pData : itemValue.size); endif; endsl; return; /end-free * P impl_item_of_anyTypeEnd_of_impl_getProfilesRpc... P E * * ===================================================================== * Reopens a given input stream in order to send it over * the wire again. * ===================================================================== P reOpenInputStream... ERR P B * D reOpenInputStream... D PI like(wsdl_hStream_t ) D i_hDataSource const like(wsdl_hDataSource_t) D i_hInpStream value like(wsdl_hStream_t ) * * Return value D hInpStream S like(wsdl_hStream_t ) inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free ManagedMemoryDataSource_InputStream_close(i_hInpStream); hInpStream = ManagedMemoryDataSource_InputStream_open(i_hDataSource); return hInpStream; /end-free * P reOpenInputStream... P E * * ===================================================================== * Login in to proxy server or http server. * ===================================================================== P login... P B * D login... D PI 10I 0 D i_http_err 10I 0 value D i_numAttempts 10I 0 value * * Return value D rc S 10I 0 inz * * Helper fields D basic S N inz D digest S N inz D realm S 124A inz D authType S 14A inz varying D userid S 50A inz varying D password S 50A inz varying * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (i_http_err = HTTP_NDAUTH); http_getauth(basic: digest: realm); authType = WSDL_AUTH_TYPE_HTTP; else; http_proxy_getauth(basic: realm); authType = WSDL_AUTH_TYPE_PROXY; endif; rc = getLoginDataImpl(authType: realm : i_numAttempts: userid: password); if (rc<> 1); userid = ''; password = ''; return rc; endif; if (i_http_err = HTTP_NDAUTH); if (digest); http_setAuth(HTTP_AUTH_MD5_DIGEST : userid: password); else; http_setAuth(HTTP_AUTH_BASIC : userid: password); endif; else; if (digest); http_proxy_setAuth(HTTP_AUTH_MD5_DIGEST : userid: password); else; http_proxy_setAuth(HTTP_AUTH_BASIC : userid: password); endif; endif; userid = ''; password = ''; return rc; /end-free * P login... P E * * ===================================================================== * Sets the content type and the SOAP action of the POST message. * ===================================================================== P HTTP_setContentTypeAndSOAPAction... P B * D HTTP_setContentTypeAndSOAPAction... D PI D o_addlHdrs 1024A varying D i_pUserData * value * * User Data D headers DS likeds(headers_t) based(i_pUserData) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free o_addlHdrs = cHTTP_HEADER_CONTENT_TYPE + ': ' + headers.contentType + cEBCDIC_CRLF + cHTTP_HEADER_SOAP_ACTION + ': ' + headers.soapAction + cEBCDIC_CRLF; /end-free * P HTTP_setContentTypeAndSOAPAction... P E * * ===================================================================== * Receice response of HTTP post operation. * ===================================================================== P HTTP_receiveResponse... P B * D HTTP_receiveResponse... D PI 10I 0 D i_hStream 10I 0 value D i_data * value D i_length 10I 0 value * D contentType S 1024A inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (not g_HTTP_isInit); select; when (http_getContentType() = 'text'); if (http_getContentSubType() = 'html'); if (f_exist('WSDL2RPG': '*LIBL': '*MSGF')); clear USR0030; USR00301 = cWEB_SERVICE_PORT; AppMsg_sendCancelMsg(AppMsg_newError('USR0030': USR0030)); else; AppMsg_sendCancelMsg( f_newMsg('CPF9898' : 'Unexpected HTML data received from web service' : '*ESCAPE' : 'QCPFMSG')); endif; endif; when (http_getContentType() = 'multipart'); contentType = %trim(http_header('content-type')); MIMEParser_beginParse(g_hMIMEParser); MIMEParser_setContentType(g_hMIMEParser: contentType); g_SOAPMessageID = http_getContentTypeAttr('start': cTrue); g_isMimeMessage = cTrue; endsl; g_HTTP_isInit = cTrue; endif; if (g_isMimeMessage); if (MIMEParser_parse(g_hMIMEParser: i_data: i_length) = cTrue); return i_length; else; return -1; endif; else; if (XMLSAXParser_parse(g_hSAXParser: i_data: i_length) = cTrue); return i_length; else; return -1; // return i_length; endif; endif; /end-free * P HTTP_receiveResponse... P E * * ===================================================================== * Starts a MIME body part. * This procedure is called whenever a new part is started. * ===================================================================== * Parameters: * i_pPart Handle of the current part. * i_pUserData Pointer to user data as specified at * http_mime_DataSink_initialize(). * ===================================================================== P HTTPDataSink_startPart... P B * D HTTPDataSink_startPart... D PI D i_pPart * const D i_pUserData * const * D contentID S 512A varying inz D contentSubType S 16A varying inz * * ------------------------------------------- * TODO: Add fields to open * the file and to store the * file descriptor. * ------------------------------------------- /IF DEFINED(DEFAULT_ATTACHMENT_HANDLING) D contentType S 10I 0 inz D fileName S 1024A varying inz D fileExt S 10A varying inz * D partUserData DS likeds(partUserData_t ) D based(pPartUserData) /ENDIF * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (http_mime_Part_getType(i_pPart)<> cMIME_BASICPART); return; endif; g_BodyPart_counter = g_BodyPart_counter + 1; contentID = http_mime_Part_getContentID(i_pPart); contentSubType = http_mime_Part_getContentSubType(i_pPart); if (not g_SOAPMessage_done); if (g_SOAPMessageID<> ''); if (contentSubType = 'xml' and contentID = g_SOAPMessageID); g_doParseSOAPMessage = cTrue; return; endif; else; if (g_BodyPart_counter = 1); g_doParseSOAPMessage = cTrue; return; endif; endif; endif; // ----------------------------------------- // TODO: // Add your code to handle attachments here| // E.g.: Open output file. // ----------------------------------------- /IF DEFINED(DEFAULT_ATTACHMENT_HANDLING) // Ignore all attachments that are not a BasicPart if (http_mime_Part_getType(i_pPart)<> cMIME_BASICPART); return; endif; fileName = http_mime_Part_getFileName(i_pPart); contentID = http_mime_Part_getContentID(i_pPart); contentType = http_mime_Part_getContentType(i_pPart); contentSubType = http_mime_Part_getContentSubType(i_pPart); if (contentType = cMIME_TYPE_TEXT); fileExt = 'txt'; else; fileExt = contentSubType; endif; fileName = g_attachmentFolder + %char(%timestamp()) + '_' + contentID + '_' + fileName + '.' + fileExt; fileName = %xlate(':<>': '___': fileName); // Assign filename to content-ID and put it into the list of attachments Attachments_put(Attachments_theInstance() : cSERVICE_UUID : contentID : fileName); // Produce the user data of that Part to // store the file descriptor of the open file. pPartUserData = %alloc(%size(partUserData_t)); clear partUserData; partUserData.FD = open(fileName : O_CREAT + O_EXCL + O_SHARE_RDONLY + O_WRONLY + O_CCSID : S_IRWXU + S_IRWXG + S_IRWXO : 819); // CCSID does not matter because // we write binary data // Set user data of the current Part. http_mime_Part_setUserData(i_pPart: pPartUserData); /ENDIF return; /end-free * P HTTPDataSink_startPart... P E * * ===================================================================== * Receices MIME part body data. * This procedure is called whenever new body data is available. * ===================================================================== * Parameters: * i_pPart Handle of the current part. * i_pUserData Pointer to user data as specified at * http_mime_DataSink_initialize(). * i_data Pointer to decoded body data. * i_size Size of decoded body data. * ===================================================================== P HTTPDataSink_bodyData... P B * D HTTPDataSink_bodyData... D PI D i_pPart * const D i_pUserData * const D i_data * const D i_size 10I 0 const * * ------------------------------------------- * TODO: Add fields to write * the attachment to the file * opened in HTTPDataSink_startPart(). * ------------------------------------------- /IF DEFINED(DEFAULT_ATTACHMENT_HANDLING) D rc S 10I 0 inz * D partUserData DS likeds(partUserData_t ) D based(pPartUserData) /ENDIF * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (g_doParseSOAPMessage); XMLSAXParser_parse(g_hSAXParser: i_data: i_size); return; endif; // ----------------------------------------- // TODO: // Add your code to handle attachments here| // E.g.: Write received data to output file. // ----------------------------------------- /IF DEFINED(DEFAULT_ATTACHMENT_HANDLING) // Gain access to the user data of the current Part. pPartUserData = http_mime_Part_getUserData(i_pPart); if (pPartUserData = *NULL); return; endif; // Return to caller if no file is open. if (partUserData.FD<= 0); return; endif; // Append attachment data to the file. rc = write(partUserData.FD: i_data: i_size); /ENDIF return; /end-free * P HTTPDataSink_bodyData... P E * * ===================================================================== * Ends a MIME body part. * This procedure is called whenever a new part ends. * ===================================================================== * Parameters: * i_pPart Handle of the current part. * i_pUserData Pointer to user data as specified at * http_mime_DataSink_initialize(). * ===================================================================== P HTTPDataSink_endPart... P B * D HTTPDataSink_endPart... D PI D i_pPart * const D i_pUserData * const * * ------------------------------------------- * TODO: Add fields to close the file * opened in HTTPDataSink_startPart(). * ------------------------------------------- /IF DEFINED(DEFAULT_ATTACHMENT_HANDLING) D rc S 10I 0 inz * D partUserData DS likeds(partUserData_t ) D based(pPartUserData) /ENDIF * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (http_mime_Part_getType(i_pPart)<> cMIME_BASICPART); return; endif; if (g_doParseSOAPMessage); g_doParseSOAPMessage = cFalse; g_SOAPMessage_done = cTrue; return; endif; // ----------------------------------------- // TODO: // Add your code to handle attachments here| // E.g.: Close output file. // ----------------------------------------- /IF DEFINED(DEFAULT_ATTACHMENT_HANDLING) // Gain access to the user data of the current Part. pPartUserData = http_mime_Part_getUserData(i_pPart); if (pPartUserData = *NULL); return; endif; // Return to caller if no file is open. if (partUserData.FD<= 0); return; endif; // Close the file. callp close(partUserData.FD); partUserData.FD = 0; // Free memory allocated in HTTPDataSink_startPart() dealloc(N) pPartUserData; /ENDIF return; /end-free * P HTTPDataSink_endPart... P E * * ===================================================================== * SOAP message: Envelope * ===================================================================== P SOAPMessage_Envelope... P B * D SOAPMessage_Envelope... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (depth = 1 and f_lcase(name) = 'html'); if (f_exist('WSDL2RPG': '*LIBL': '*MSGF')); clear USR0030; USR00301 = cWEB_SERVICE_PORT; AppMsg_sendCancelMsg(AppMsg_newError('USR0030': USR0030)); else; AppMsg_sendCancelMsg( f_newMsg('CPF9898' : 'Unexpected HTML data received from web service' : '*ESCAPE' : 'QCPFMSG')); endif; endif; select; when (path = '/Envelope/Header'); XMLSAXParser_delegateElementProcessing( g_pRespSoapHeader : %paddr('SOAPMessage_unexpectedElementStart') : %paddr('SOAPMessage_unexpectedElementEnd')); return; when (path = '/Envelope/Body'); select; when (name = 'Fault'); XMLSAXParser_delegateElementProcessing( %addr(g_errors.soapFault) : %paddr('SOAPMessage_FaultStart') : %paddr('SOAPMessage_FaultEnd')); return; when (MultiRef_isData(attrs)); XMLSAXParser_delegateElementProcessing( *NULL : MultiRef_getStartCallback() : MultiRef_getEndCallback()); return; other; XMLSAXParser_delegateElementProcessing( userdata : %paddr('impl_getProfilesRpcStart') : %paddr('impl_getProfilesRpcEnd')); return; endsl; endsl; return; /end-free * P SOAPMessage_Envelope... P E * * ===================================================================== * SOAP message: fault information * ===================================================================== P SOAPMessage_FaultStart... P B * D SOAPMessage_FaultStart... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * D fault... D DS based(userdata) D likeds(wsdl_soapFault_t ) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (depth = 1); return; endif; select; when (name = 'detail'); XMLSAXParser_delegateElementProcessing( %addr(fault.detail) : %paddr('SOAPMessage_FaultDetailStart') : %paddr('SOAPMessage_FaultDetailEnd')); endsl; /end-free * P SOAPMessage_FaultStart... P E * * ===================================================================== * SOAP message: fault information * ===================================================================== P SOAPMessage_FaultEnd... P B * D SOAPMessage_FaultEnd... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying const D attrs * dim(32767) D const options(*varsize) * D fault... D DS based(userdata) D likeds(wsdl_soapFault_t ) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (depth = 1); return; endif; select; when (name = 'faultcode'); fault.code = value; when (name = 'faultstring'); fault.string = value; endsl; /end-free * P SOAPMessage_FaultEnd... P E * * ===================================================================== * SOAP message: fault details * ===================================================================== P SOAPMessage_FaultDetailStart... P B * D SOAPMessage_FaultDetailStart... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * D detail... D DS based(userdata) D likeds(wsdl_soap_faultDetail_t) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (depth = 1); return; endif; select; endsl; /end-free * P SOAPMessage_FaultDetailStart... P E * * ===================================================================== * SOAP message: fault details * ===================================================================== P SOAPMessage_FaultDetailEnd... P B * D SOAPMessage_FaultDetailEnd... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying const D attrs * dim(32767) D const options(*varsize) * D detail... D DS based(userdata) D likeds(wsdl_soap_faultDetail_t) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (depth = 1); return; endif; select; when (name = 'hostname'); detail.hostname = value; endsl; /end-free * P SOAPMessage_FaultDetailEnd... P E * * ===================================================================== * SOAP message: NULL callback procedure * ===================================================================== P SOAPMessage_unexpectedElementStart... P B * D SOAPMessage_unexpectedElementStart... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D attrs * dim(32767) D const options(*varsize) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (ignoreUnexpectedSoapHeader()); http_DebugLog_appendText( 'Warning: Received unexpected Soap header:<' + name +'>'); return; endif; if (f_exist('WSDL2RPG': '*LIBL': '*MSGF')); clear USR0042; USR00421 = 'SOAPMessage_unexpectedElementStart'; USR00422 = 'SOAPMessage_unexpectedElementEnd'; AppMsg_sendCancelMsg(AppMsg_newError('USR0042': USR0042)); else; AppMsg_sendCancelMsg( f_newMsg('CPF9898' : 'Unexpected Soap element received from web service.' : '*ESCAPE' : 'QCPFMSG')); endif; return; /end-free * P SOAPMessage_unexpectedElementStart... P E * * ===================================================================== * SOAP message: NULL callback procedure * ===================================================================== P SOAPMessage_unexpectedElementEnd... P B * D SOAPMessage_unexpectedElementEnd... D PI D userdata * value D depth 10I 0 value D namespace 1024A varying const D name 1024A varying const D path 24576A varying const D value 65535A varying const D attrs * dim(32767) D const options(*varsize) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (ignoreUnexpectedSoapHeader()); http_DebugLog_appendText( 'Warning: Received unexpected Soap header: ' + value); http_DebugLog_appendText( 'Warning: Received unexpected Soap header:</' + name + '>'); return; endif; if (f_exist('WSDL2RPG': '*LIBL': '*MSGF')); clear USR0042; USR00421 = 'SOAPMessage_unexpectedElementStart'; USR00422 = 'SOAPMessage_unexpectedElementEnd'; AppMsg_sendCancelMsg(AppMsg_newError('USR0042': USR0042)); else; AppMsg_sendCancelMsg( f_newMsg('CPF9898' : 'Unexpected Soap element received from web service.' : '*ESCAPE' : 'QCPFMSG')); endif; return; /end-free * P SOAPMessage_unexpectedElementEnd... P E * * ===================================================================== * Specifies, whether unexpected Soap headers are ignored or not. * ===================================================================== P ignoreUnexpectedSoapHeader... P B * D ignoreUnexpectedSoapHeader... D PI N * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free return cFalse; /end-free * P ignoreUnexpectedSoapHeader... P E * * ===================================================================== * Registers an user callback procedure, that is called whenever * a web service requires user authentification. * ===================================================================== P Inventory_registerLoginCallback... P B export * D Inventory_registerLoginCallback... D PI D D i_pLoginProc * value procptr * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free g_getLoginDataImpl = i_pLoginProc; return; /end-free * P Inventory_registerLoginCallback... P E * * ===================================================================== * Http: Returns the last HTTP error (code) that occurred. * ===================================================================== P Inventory_isError... P B export * D Inventory_isError... D PI N * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free if (g_errors.errType = WSDL_HTTP_SUCCESS); return cFalse; else; return cTrue; endif; /end-free * P Inventory_isError... P E * * ===================================================================== * Http: Returns the last HTTP error (code) that occurred. * ===================================================================== P Inventory_HttpError_getCode... P B export * D Inventory_HttpError_getCode... D PI like(wsdl_http_ErrorNo_t ) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free return g_errors.httpError.no; /end-free * P Inventory_HttpError_getCode... P E * * ===================================================================== * Http: Returns the last HTTP error (text) that occurred. * ===================================================================== P Inventory_HttpError_getText... P B export * D Inventory_HttpError_getText... D PI like(wsdl_http_ErrorText_t) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free return g_errors.httpError.text; /end-free * P Inventory_HttpError_getText... P E * * ===================================================================== * Soap: Returns the last SOAP error (code) that occurred. * ===================================================================== P Inventory_SoapError_getCode... P B export * D Inventory_SoapError_getCode... D PI like(wsdl_soap_faultcode_t ) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free return g_errors.soapFault.code; /end-free * P Inventory_SoapError_getCode... P E * * ===================================================================== * Soap: Returns the last SOAP error (text) that occurred. * ===================================================================== P Inventory_SoapError_getText... P B export * D Inventory_SoapError_getText... D PI like(wsdl_soap_faultstring_t) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free return g_errors.soapFault.string; /end-free * P Inventory_SoapError_getText... P E * * ===================================================================== * XML: Returns the last XML error (code) that occurred. * ===================================================================== P Inventory_XmlError_getCode... P B export * D Inventory_XmlError_getCode... D PI like(wsdl_xml_ErrorNo_t ) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free return g_errors.xmlError.code; /end-free * P Inventory_XmlError_getCode... P E * * ===================================================================== * XML: Returns the last XML error (text) that occurred. * ===================================================================== P Inventory_XmlError_getText... P B export * D Inventory_XmlError_getText... D PI like(wsdl_xml_ErrorText_t ) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free return g_errors.xmlError.text; /end-free * P Inventory_XmlError_getText... P E * * ===================================================================== * Returns the file name of the attachment that is associated to * a given content ID. * ===================================================================== P Inventory_Attachments_get... P B export * D Inventory_Attachments_get... D PI like(wsdl_path_t ) D i_attachmentID... D const like(wsdl_attachmentID_t ) * D fileName S like(wsdl_path_t ) inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free fileName = Attachments_get(Attachments_theInstance() : cSERVICE_UUID : i_attachmentID); return fileName; /end-free * P Inventory_Attachments_get... P E * * ===================================================================== * Returns the file name of the attachment that is associated to * a given index. * ===================================================================== P Inventory_Attachments_getAtPos... P B export * D Inventory_Attachments_getAtPos... D PI likeds(wsdl_attachment_t ) D i_index 10I 0 const * D attachment DS likeds(wsdl_attachment_t ) inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free attachment = Attachments_getAtPos(Attachments_theInstance() : cSERVICE_UUID : i_index); return attachment; /end-free * P Inventory_Attachments_getAtPos... P E * * ===================================================================== * Returns the number of attachments that were downloaded with * the last call of the web service. * ===================================================================== P Inventory_Attachments_getNumE... P B export * D Inventory_Attachments_getNumE... D PI 10I 0 * D numE S 10I 0 inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free numE = Attachments_getNumAttachments(Attachments_theInstance() : cSERVICE_UUID); return numE; /end-free * P Inventory_Attachments_getNumE... P E * * ===================================================================== * Removes all attachments from the list of attachments of * this web service. * ===================================================================== P Inventory_Attachments_removeAll... P B export * D Inventory_Attachments_removeAll... D PI * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free Attachments_removeAll(Attachments_theInstance() : cSERVICE_UUID); return; /end-free * P Inventory_Attachments_removeAll... P E * * ===================================================================== R * *** private/experimental *** * Enables/disables a workaround for Web services that are driven * by Axis and that are affected by the AXIS-2095 bug. * Export this procedure if you really need it. * ===================================================================== P Inventory_enableAxis2095... P B * D Inventory_enableAxis2095... D PI D i_isEnabled N const * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free deprecated(); g_isAXIS_2095 = i_isEnabled; return; /end-free * P Inventory_enableAxis2095... P E * * ===================================================================== * Specifies the name of the folder where to put attachments in. * ===================================================================== P Inventory_setAttachmentFolder... P B export * D Inventory_setAttachmentFolder... D PI D i_folder 1024A const varying options(*varsize) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free g_attachmentFolder = i_folder; g_attachmentFolder = %trimR(%xlate('Ö': '/': g_attachmentFolder)); if (not f_endsWith('/': g_attachmentFolder)); g_attachmentFolder = g_attachmentFolder + '/'; endif; return; /end-free * P Inventory_setAttachmentFolder... P E /IF DEFINED(LOGGING_SERVICE) * * ===================================================================== * Starts the Log4rpg logging service. * ===================================================================== P Inventory_startLoggingService... P B export * D Inventory_startLoggingService... D PI D i_path const like(LOG4RPG_path_t ) D options(*nopass) D i_waitMinutes 10I 0 const options(*nopass) D i_unit 10A const options(*nopass) * * Parameter positions D p_path C 1 D p_waitMinutes C 2 D p_unit C 3 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free LoggerStub_loadSrvPgm(); select; when (%parms()>= p_unit); Configurator_loadAndWatchPropertiesConfiguration( i_path: i_waitMinutes: i_unit); when (%parms()>= p_waitMinutes); Configurator_loadAndWatchPropertiesConfiguration( i_path: i_waitMinutes); when (%parms()>= p_path); Configurator_loadPropertiesConfiguration(i_path); other; Configurator_loadDefaultConfiguration(); endsl; return; /end-free * P Inventory_startLoggingService... P E /ENDIF * * ===================================================================== * Web service: Enables/disables the debug log of HTTP API * ===================================================================== P Inventory_setHttpDebug... P B export * D Inventory_setHttpDebug... D PI D i_status N const D i_fileName 500A const varying options(*nopass) * * Parameter positions D p_fileName C 2 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free g_httpDebug.status = i_status; if (%parms()>= p_fileName); g_httpDebug.fileName = i_fileName; else; g_httpDebug.fileName = HTTP_API_DEFAULT_LOG_FILE; endif; if (i_status); http_DebugLog_open(g_httpDebug.fileName); else; http_DebugLog_close(); endif; return; /end-free * P Inventory_setHttpDebug... P E * * ===================================================================== * Web service: Sets the proxy server to use for the connection * ===================================================================== P Inventory_setProxy... P B export * D Inventory_setProxy... D PI D i_server 256A const D i_port 10I 0 const * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free g_proxy.server = i_server; g_proxy.port = i_port; return; /end-free * P Inventory_setProxy... P E * * ===================================================================== * Web service: Returns the endpoint of the Web service * ===================================================================== P Inventory_getEndpoint... P B export * D Inventory_getEndpoint... D PI 32767A varying * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free return g_url; /end-free * P Inventory_getEndpoint... P E * * ===================================================================== * Web service: Sets the endpoint of the Web service * ===================================================================== P Inventory_setEndpoint... P B export * D Inventory_setEndpoint... D PI D i_url 32767A const varying options(*varsize) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free g_url = %subst(i_url: 1: %len(i_url)); return; /end-free * P Inventory_setEndpoint... P E * * ===================================================================== * Web service: Returns the host name of the Web Service endpoint * ===================================================================== P Inventory_getHost... P B export * D Inventory_getHost... D PI 32767A varying * D tmpUrl S like(url_t ) inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free tmpUrl = URL_new(g_url); return URL_getHost(tmpUrl); /end-free * P Inventory_getHost... P E * * ===================================================================== * Web service: Sets the host name of the Web service endpoint * ===================================================================== P Inventory_setHost... P B export * D Inventory_setHost... D PI D i_host 32767A const varying options(*varsize) * D tmpUrl S like(url_t ) inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free tmpUrl = URL_new(g_url); URL_setHost(tmpUrl: %subst(i_host: 1: %len(i_host))); g_url = URL_toString(tmpUrl); return; /end-free * P Inventory_setHost... P E * * ===================================================================== * Web service: Returns the port of the Web Service endpoint * ===================================================================== P Inventory_getPort... P B export * D Inventory_getPort... D PI 10I 0 * D tmpUrl S like(url_t ) inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free tmpUrl = URL_new(g_url); return URL_getPort(tmpUrl); /end-free * P Inventory_getPort... P E * * ===================================================================== * Web service: Sets the port of the Web service endpoint * ===================================================================== P Inventory_setPort... P B export * D Inventory_setPort... D PI D i_port 10I 0 const * D tmpUrl S like(url_t ) inz * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /free tmpUrl = URL_new(g_url); URL_setPort(tmpUrl: i_port); g_url = URL_toString(tmpUrl); return; /end-free * P Inventory_setPort... P E * ____________________________________ ----Original Message----- Date: Fri, 19 Aug 2011 11:22:40 +0200 From: thomas.raddatz@xxxxxx Subject: RE: Ftpapi Digest, Vol 62, Issue 20 To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx Message-ID: <OF4117F9A3.B2AB96DE-ONC12578F1.002F1B0F-C12578F1.00339880@xxxxxxxxxx> Content-Type: text/plain; charset="iso-8859-1" Michael, It seems as if "getProfilesReturn" is defined as an array of "anyType". That means that the web service can return any type of data in that array. Therefore WSDL2RPG cannot forecast what type of information the web service will return and hence cannot generate code for it. What you got back from the web service is a map of key/value pairs. Unfortunately in that case it is up to you to parse the map and to retrieve the values from it. If I was you I would enrich the generated stub module with the missing code. Perhaps you want to follow these steps to understand what the stub does and how to get the values of the map out of the response message: 1) Change "impl_item_of_anyType_t" to a data structure likes this (and compile the stub): * D impl_item_of_anyType_t... D DS template D x 10I 0 D key 64A D value 256A * D impl_RpgArrayOfArrayOf_xsd_anyType_t... D DS template D qualified D x 10I 0 D item likeds(impl_item_of_anyType_t) D dim(DIM_A1) 2) Start the debugger for the stub (service program?) 3) Add a breakpoint to procedure impl_item_of_anyTypeStart_of_impl_getProfilesRpc() When the debugger stops here with depth=1, "name" should contain " getProfilesReturn". For depth=2 it should contain "item" and for depth=3 it should contain "key" or "value". The same thing should be true for step 3 below. 4) Add a breakpoint to procedure impl_item_of_anyTypeEnd_of_impl_getProfilesRpc() As you can see, this procedure already contains the code to increment the array index of "impl_getProfilesReturn" (but we only expect to get a single element): impl_getProfilesReturn.x = impl_getProfilesReturn.x + 1; But it lacks the statements needed to retrieve the data because it does not now the type of data because of "anyType". The missing statements should look similar to (not sure about the namespace value): when (depth = 2 and name = 'item' and namespace = 'urn:Inventory'); // Increment index of map currentItem.x = currentItem.x + 1; when (depth = 3 and name = 'key' and namespace = 'urn:Inventory'); B02 if (not Value_isNil(attrs)); x = currentItem.x; UnMarshaller_toStringV6( %addr(currentItem.key) : %addr(currentItem.key(x): *DATA) : %size(currentItem.key(x)) : itemValue.pData : itemValue.size); E02 endif; when (depth = 3 and name = 'value' and namespace = 'urn:Inventory'); B02 if (not Value_isNil(attrs)); x = currentItem.x; UnMarshaller_toStringV6( %addr(currentItem.ort) : %addr(currentItem.value(x): *DATA) : %size(currentItem.value(x)) : itemValue.pData : itemValue.size); E02 endif; Before changing the code you may just add the breakpoints and run the program to see what happens. Especially look at the contents of "name", "depth", "itemValue.pData" and "itemValue.size". You can see the value addressed by "itemValue.pData" like this: eval itemValue.pData :x 64 or eval itemValue.pData :c 64 Please have in mind that all I could do was to look at the stub and the debug log as provided by you. I had no chance to verify or even test my suggestions. Hence it is very likely that some details (or assumptions) may be wrong. Last but not least another option is to download the WSDL file and to modify it to reflect the actual structure of the data returned by the web service. Then WSDL2RPG could generate a new stub from the modified WSDL file. Thomas. ----------------------------------------------------------------------- This is the FTPAPI mailing list. To unsubscribe, please go to: http://www.scottklement.com/mailman/listinfo/ftpapi -----------------------------------------------------------------------
Attachment:
2011-08-22_Koester.ZIP
Description: Zip archive
----------------------------------------------------------------------- This is the FTPAPI mailing list. To unsubscribe, please go to: http://www.scottklement.com/mailman/listinfo/ftpapi -----------------------------------------------------------------------