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

RE: WSDL2RPG Trouble parsing multiple data maps from webservice



Hi Thomas.

A clarification:
> I am not sure that I thorougly understood the problem. What I understood is that the value of a key/value pair sometimes is > a simple type, e.g. a string, and sometimes a map. Is that right?
What I call a simple type is actually a data structure of a set of key/value pairs.  Most of those key/value pairs have a string for a value.  Where it gets tricky is that some of the values are not strings -- instead, those values are a nested array of an inner set of key value pairs.  My test program has successfully identified and displayed the strings showing those inner keys and values. But to get there, my code does not accommodate displaying any of the "simple" types where the outer value is just a string.
  
Example:
I get a count of 348 outer key/value pairs.  
Pair #1 has a key, "RG_GEN_PROFILE", and a value (which I can't get to with my current test program), "CSA3_746MOD Bridge/PPPoE 30m/3".  You can see that if you search the debug log for RG_GEN_PROFILE, but because the programs identify that outer value as a map of inner key value pairs instead of the string, I don't know how to find and display it.

Outer pair #29 has a key, "3", and its value is an array of 4 inner key/value pairs: 
  inner pair #1 has a key, "Topology", and a value, "AL-FXS-DEL".
  Inner pair #2 has a key, "Name", and a value, "tel3". 
  ...
 
These inner keys and values I'm able to identify and display. My test program shows the following:
   DSPLY  item x is   348.    
   DSPLY  1: RG_GEN_PROFILE =>  
    ...
   DSPLY  26: INET_SERVICE_TYPE =>    
   DSPLY  27: VOIP_ECHOCAN_1 =>         
   DSPLY  28: VOIP_ECHOCAN_2 =>       
   DSPLY  inner pairs: 4.             
   DSPLY  29/1: Topology => AL-FXS-DEL
   DSPLY  29/2: Name => tel3          
   DSPLY  29/3: ID => 3               
   DSPLY  29/4: Physical Port => tel3 
   DSPLY  inner pairs: 4.
   DSPLY  30/1: Topology => AL-FXS-DEL
   DSPLY  30/2: Name => tel2           
   DSPLY  30/3: ID => 2               
   DSPLY  30/4: Physical Port => tel2 
   DSPLY  31: inetProfileMOName =>    
   DSPLY  inner pairs: 4.             
   DSPLY  32/1: Topology => AL-FXS-DEL
   DSPLY  32/2: Name => tel1          
   DSPLY  32/3: ID => 1               
   DSPLY  32/4: Physical Port => tel1              
   ...
Note that pairs 1, 26, 27, 28, and 31 are the simple types, and pairs 29, 30, and 32 have the nested sets, each having 4 inner key/value pairs. 

Does that help?

I'll try to see what I can do with what you sent me.  If the above details cause you to determine that we're on the wrong path, let me know.

Thanks so much.
-- Michael

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of thomas.raddatz@xxxxxx
Sent: Wednesday, February 27, 2013 9:15 AM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: WSDL2RPG Trouble parsing multiple data maps from webservice


Michael,

I am not sure that I thorougly understood the problem. What I understood is that the value of a key/value pair sometimes is a simple type, e.g. a string, and sometimes a map. Is that right?

Given that my assumption is correct, you may try to change the WSDL file to use a <choice> to distinguish between these two data types. Please have a look at the attached sample. Hopefully it helps you to make it.

Snippet from the changed wsdl file:

   <complexType name="mapItem">
    <sequence>
     <element name="key" nillable="true" type="xsd:anyType"/>
     <choice>
      <element name="value"  nillable="true" type="apachesoap:AnyMap"/>
      <element name="value2" nillable="true" type="xsd:anyType"/>
     </choice>
    </sequence>
   </complexType>

Anfter having changed the wsdl like that I needed to tweak the generated stub. I replaced "value" with "value" at several places (but not all) and I retrieved the "type" attribute (getSchemaAttr()) to distinguish between the types of element "value":

   dataType = getSchemaAttr('type': attrs);  // FIX: added

   select;
   when (depth = 2
          and
          name = 'value'
          and                         // FIX: added
          dataType = 'Map');          // FIX: added

These nice XML "any" types is what we really do not need with RPG. :-(

Regards,

Thomas.



ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 26.02.2013 13:55:07:

> Von: mkoester@xxxxxxxxxxxxx
> An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx, > Datum: 26.02.2013 14:11
> Betreff: RE: WSDL2RPG Trouble parsing multiple data maps from 
> webservice Gesendet von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > Thank you Thomas.
> Attached is the debug log with just a couple value elements > modified.  I know you're getting toward the end of your day, as I'm > just beginning mine.
> > -- Michael
> > -----Original Message-----
> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi- 
> bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of thomas.raddatz@xxxxxx
> Sent: Tuesday, February 26, 2013 2:07 AM
> To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: WSDL2RPG Trouble parsing multiple data maps from 
> webservice
> > > Micheal,
> > Please provide a sample response message of the web service. You may
> either post the complete debug log (without sensitive data) or you > may take the response XML string out of the debug log and post it here.
> > The problem you describe is a tricky one because we reach the > capabilities of RPG. In Java it is not a problem to have a map and > to assign a string or another map to a key. Actually you can assign > every object to a key. But in RPG you are almost stuck. But first, > let me see what we can do.
> > Thomas.
> > ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 26.02.2013 00:00:54:
> > > Von: mkoester@xxxxxxxxxxxxx
> > An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx, > Datum: 26.02.2013 00:11
> > Betreff: WSDL2RPG Trouble parsing multiple data maps from webservice 
> > > > Gesendet von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > > I've been using the Thomas Raddatz WSDL2RPG tool, but I'm seeing
> > some occurrences of failures.  Getting the error "-1: Length of > > 
> > varying length variable is out of range."  If I recall correctly, > 
> > > this error may have originated in one of the WSDL2R94 procedures. 
> > > > After a lot of digging around, I find that on these occurrences, 
> > > > there appears to be a couple of different data maps being 
> > returned >
> by the webservice.  The production program is handling the simple > > type, where I receive back items defined as:
> > > >      D impl_getRGDeviceDetailsReturnMvd_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_A1)  // DIM_A1 = 512
> > >      D apachesoap_mapItem_t...
> >      D                 DS                  template
> >      D                                     qualified
> >      D  key                         256A   varying
> >      D  value                       256A   varying
> > > This works well until I encounter a nested array, where the > "Value" > is actually a map of a number of key/value pairs.
> > > So I messed with it until I got a test program to accommodate those.
> > (I used patterns from another program Thomas helped me set up last
> > August.)  I also had to do a lot of trial/error to get the array >
> dimensions right so it would compile and run without error.  It now > 
> > runs without error (at least for my very limited test inputs), and I
> > can get the key/value pairs of the inner nested values, using the > > following definitions in my test stubs: > >      D > apachesoap_RpgArrayOfItem_t...
> >      D                 DS                  template
> >      D                                     qualified
> >      D  x                            10I 0
> >      D  mapItem likeds(apachesoap_mapItem_t)
> >      D                                     dim(DIM_A1)  // DIM_A1 > = > 400 for this test stub
> > >      D apachesoap_mapItem_t...
> >      D                 DS                  template
> >      D                                     qualified
> >      D  key                          64A   varying
> >      D  value                              likeds(apachesoap_AnyMap_t)
> > >      D apachesoap_AnyMap_t...
> >      D                 DS                  template
> >      D                                     qualified
> >      D  item                               likeds
> > (apachesoap_RpgArrayOfItem1_t)
> > >      D apachesoap_RpgArrayOfItem1_t...
> >      D                 DS                  template
> >      D                                     qualified
> >      D  x                            10I 0
> >      D  anyMapItem likeds(apachesoap_anyMapItem_t)
> >      D                                     dim(DIM_A2)  // DIM_A2 > = > 64 for this test stub
> > >      D apachesoap_anyMapItem_t...
> >      D                 DS                  template
> >      D                                     qualified
> >      D  key                          64A   varying
> >      D  value                        64A   varying
> > > All is cool except that the returned data is a mix of the nested
> > types and the simple types.  I have not found a way to resolve the 
> > simple value, which my test stubs don't appear to resolve.  I get > > the "simple" key, but the value is expected to also be a nested > set > of key/value pairs, which for some pairs it is, but others it > is not. > > I know what the result set should be from a "northbound > Interface" > that should be using the same web service, and I see > the different > types of data maps there.  I just can't seem to > replicate those > results with my programs.
> > > Attached is the original wsdl from the web service > (Provision.wsdl) > and a modified version that provides for the > nested key/value pairs > (Provision4.wsdl).  The method I'm working > with here is > getRGDeviceDetails.  I've attached my test caller as > well (ws5test05.txt).
> > > If you think you can help me through this, let me know what > other > pieces you might need.
> > > Many thanks,
> >   Michael
> > > > > [Anhang "Provision.xml" gelöscht von Thomas Raddatz/OBI/DE] > 
> > > > > > > > > [Anhang > "Provision4.wsdl" gelöscht von Thomas 
> > > > > Raddatz/OBI/DE] > > > > > [Anhang > "ws5test05.txt" gelöscht 
> > > > > von Thomas Raddatz/OBI/DE] > > > > > > 
> > > > > --------------------------------------------------------------
> > > > > --
> > > > > -------
> > This is the FTPAPI mailing list.  To unsubscribe, please go to:
> > http://www.scottklement.com/mailman/listinfo/ftpapi
> > --------------------------------------------------------------------
> > --
> > -
> > > --
> IMPORTANT NOTICE:
> This email is confidential, may be legally privileged, and is for > the intended recipient only. Access, disclosure, copying, > distribution, or reliance on any of it by anyone else is prohibited > and may be a criminal offence. Please delete if obtained in error > and email confirmation to the sender.
> [Anhang "httpapi_debug.txt" gelöscht von Thomas Raddatz/OBI/DE] > 
> ----------------------------------------------------------------------
> - This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> ----------------------------------------------------------------------
> -


--
IMPORTANT NOTICE:
This email is confidential, may be legally privileged, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone else is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender.
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------