[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: WSDL2RPG : Empty tag for decimal variables
I agree with you if you are talking about plain XML. But since we
focus on web services here, we can be faced with NULL values, because
of XML Schema. And the problem is not the XML but RPG, which lacks
true NULL support. For the original poster the question was how to
specify NULL values for some elements of his request XML message. If
RPG had true NULL support, he could just set the related RPG field to
NULL, for example: %nullind(myIntField). In that case WSDL2RPG could
detect the NULL value and generate a NULL element or drop the element
depending on what the WSDL requires.
If the WSDL specified <element name="myIntField" nillable="true">,
WSDL2RPG would have to generate a NULL element such as <myIntField
xsi:nil="true">.
<myStructure>
<myIntField xsi:nil="true"/>
</myStructure>
If the WSDL specified <element name="myIntField" minoccurs="0">,
WSDL2RPG would have to drop the element from the request message.
<myStructure>
</myStructure>
But since RPG does not support NULL values (except for fields of
external data structures) we have to circumvent the problem with our
own NULL indicators.
So I was not quite right when I suggested to generate an empty element
although at least my Axis2 based web services treat empty elements as
NULL, except for elements of type string. I did not test all element
types but at least numeric elements are treated as NULL in case they
are empty.
Thomas.
ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 25.08.2011 18:27:49:
> Von: hr@xxxxxxxxxxxx
> An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
> Datum: 25.08.2011 18:37
> Betreff: Re: WSDL2RPG : Empty tag for decimal variables
> Gesendet von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>
> Thomas,
>
> to my best knowlegde XML dosn't support null, true and false, so
what is the
> problem?
>
> a node without being a parent should be passed as
>
> <myNode />
> or
> <myNode></mynode>
>
>
> On Thu, Aug 25, 2011 at 5:49 PM, Thomas Raddatz
> <thomas.raddatz@xxxxxxxxxxx>wrote:
>
> > You did it right. But you may also consider to do it this way:
> >
> > Let us assume that you had the following reference data structure
that is
> > used to define your request message:
> >
> > D curZualBapiacap09_A2_t...
> > D DS qualified based(pDummy)
> > D aNillableA 128A
> > D aNillableI 10I 0
> >
> >
> > D curZualBapiacap09_A2...
> > D DS likeds(curZualBapiacap09_A2_t)
> > D inz
> >
> >
> > The code producing the request message my look similar to this:
> >
> > '<aNillableA>' +
> > Marshaller_toString(
> > curZualBapiacap09_A2.aNillableA
> > ) +
> > '</aNillableA>' +
> > '<aNillableI>' +
> > Marshaller_toInteger(
> > curZualBapiacap09_A2.aNillableI
> > ) +
> > '</aNillableI>' +
> >
> > Now you may change your code as shown below to add the null
indicators:
> >
> > D curZualBapiacap09_A2_t...
> > D DS qualified
> > D aNillableA 128A inz
> > D aNillableA_isNull
> > D N inz(*ON)
> > D aNillableI 10I 0 inz
> > D aNillableI_isNull
> > D N inz(*ON)
> >
> > And eventually change the code to produce the request message as
shown
> > here:
> >
> > '<aNillableA>';
> > if (not curZualBapiacap09_A2.aNillableA_isNull);
> > request = request +
> > Marshaller_toString(
> > curZualBapiacap09_A2.aNillableA
> > );
> > endif;
> > request = request +
> > '</aNillableA>' +
> > '<aNillableI>';
> > if (not curZualBapiacap09_A2.aNillableI_isNull);
> > Marshaller_toInteger(
> > curZualBapiacap09_A2.aNillableI
> > );
> > endif;
> > request = request +
> > '</aNillableI>' +
> >
> > If a value is marked as NULL the resulting XML would look like
this:
> >
> > <aNillableA></aNillableA>
> >
> > or
> >
> > <aNillableI></aNillableI>
> >
> > However before setting the values of the request message you had
to reset
> > the data structure in order to set the NULL indicators to *ON:
> >
> > reset curZualBapiacap09_A2;
> >
> > curZualBapiacap09_A2aNillableA = 'Hello';
> > curZualBapiacap09_A2_isNull = *OFF;
> >
> > Worth a try?
> >
> > Please have in mind that I put together the sample at home. I did
not yet
> > try it in reality.
> >
> > Thomas.
> >
> > Am 25.08.2011 08:59, schrieb Dhanushka Manjula:
> > >
> > > Hi Thomas,
> > > Thank you in advance for your input.
> > > I have only 3 fields to be omitted& those 3 variables can
be
> > > permanently removed from client end and host service cannot
be
> > changed
> > > as well.
> > > So I changed STUB with search& replace function
> > > correct me if I'm wrong..
> > > I search '<DsctDays1>0.00</DsctDays1>' string in request
variable&
> > > replace it with '<DsctDays1/>'
> > > '<Pmtmthsupl>' +
> > > Marshaller_toString(
> > > curZualBapiacap09_A2.Pmtmthsupl
> > > ) +
> > > '</Pmtmthsupl>' +
> > > '</item>' +
> > > '';
> > >
> > > Search_word = '<DsctDays1>0.00</DsctDays1>';
> > > replace_word = '<DsctDays1/>' ;
> > > request = SearchR(request:search_word:replace_word);
> > > Looks like everything is OK for me..... (temporarily of
cause)
> > > btw, I think this method is much smarter than 1st one, cause
once we
> > > need to omit a variable, Just only have to turn *On the
indicator.
> > > [[1]cid:330@goomoji.gmail]
> > > request.myNillableField.isNull = *ON;
> > > Thanks again.
> > >
> > > On Thu, Aug 25, 2011 at 1:17 AM, Thomas Raddatz
> > > <[1]thomas.raddatz@xxxxxxxxxxx> wrote:
> > >
> > > The problem you have is a common problem with RPG because
RPG does
> > > not
> > > really support NULL values.
> > > Leaving an XML element empty is one option to specify a
NULL value
> > > in an
> > > XML document. But since RPG does not support NULL values,
WSDL2RPG
> > > does not
> > > have a chance to properly recognize NULL values. For
strings you
> > > may say
> > > that a string value with length=0 is equal to NULL.
Although that
> > > is not
> > > really true it should work in most cases. Fine.
> > > But for all other field types it is not that easy to
define a
> > > substitution
> > > value for NULL. For example you may say that for numeric
fields the
> > > substitute for NULL is 0. But is that really a good idea?
I do not
> > > think
> > > so. But what other value should we consider to be equal to
NULL?
> > > *LOVAL or
> > > *HIVAL? Bad.
> > > I wished RPG had true NULL support. All you can do now is
to say:
> > > "For me,
> > > 0 is equal to NULL" and then modify the generated stub
accordingly.
> > > I have been thinking about how to support NULL values
since the day
> > > WSDL2RPG was born. If it wasn't that ugly I would add a
NULL
> > > indicator
> > > field for each nillable field. If the NULL indicator is
TRUE the
> > > field
> > > would be treated as NULL regardless of its actual value.
Honestly I
> > > do not
> > > like that solution because you always have to set two
fields for
> > > one value,
> > > for example:
> > > request.myNillableField.value = 123;
> > > request.myNillableField.isNull = *OFF;
> > > Or in case of a NULL value:
> > > request.myNillableField.isNull = *ON;
> > > Any other ideas how to solve that problem?
> > > Thomas.
> > > Am [2]24.08.2011 18:41, schrieb Dhanushka Manjula:
> > > >
> > > > Hi All,
> > > > In my RPG code, I have leave out 5 line due to I
dont have
> > > values to
> > >
> > > > send, I need closed/empty tag for those
> > > >
> > > > //newZualBapiacap09_A2.BlineDate =;
> > > > //newZualBapiacap09_A2.DsctDays1 = 0;
> > > > //newZualBapiacap09_A2.DsctDays2 = 0;
> > > > //newZualBapiacap09_A2.Netterms = 0;
> > > > newZualBapiacap09_A2.PymtMeth = PYMDDL ;
> > > > //newZualBapiacap09_A2.Pmtmthsupl = ;
> > > >
> > > > Following is the part of SOAP message
> > > >
> > > > <BlineDate/>
> > > > <DsctDays1>0.00</DsctDays1>
> > > > <DsctDays2>0.00</DsctDays2>
> > > > <Netterms>0.00</Netterms>
> > > > <PymtMeth> NP</PymtMeth>
> > > > <Pmtmthsupl/>
> > > >
> > > > For String variables, it generates closed tag
accordingly but
> > > for the
> > > > decimal variables it assigns 0.00 Which were not
expected
> > > > How to have a closed/empty tag for decimal variables?
> > > > Thanks
> > > >
> > > >
> > > >
> > > >
> > >
> > > >
> > >
-------------------------------------------------------------------
> > > ----
> > > > This is the FTPAPI mailing list. To unsubscribe,
please go to:
> > > >
[3][2]http://www.scottklement.com/mailman/listinfo/ftpapi
> > > >
> > >
-------------------------------------------------------------------
> > > ----
> > >
-------------------------------------------------------------------
> > > ----
> > > This is the FTPAPI mailing list. To unsubscribe, please
go to:
> > > [4][3]http://www.scottklement.com/mailman/listinfo/ftpapi
> > >
-------------------------------------------------------------------
> > > ----
> > >
> > > References
> > >
> > > 1. [4]mailto:thomas.raddatz@xxxxxxxxxxx
> > > 2. tel:24.08.2011%2018
> > > 3. [5]http://www.scottklement.com/mailman/listinfo/ftpapi
> > > 4. [6]http://www.scottklement.com/mailman/listinfo/ftpapi
> > >
> > >
> > >
> > >
> > >
----------------------------------------------------------------------
-
> > > This is the FTPAPI mailing list. To unsubscribe, please go to:
> > > [7]http://www.scottklement.com/mailman/listinfo/ftpapi
> > >
----------------------------------------------------------------------
-
> >
----------------------------------------------------------------------
-
> > This is the FTPAPI mailing list. To unsubscribe, please go to:
> > [8]http://www.scottklement.com/mailman/listinfo/ftpapi
> >
----------------------------------------------------------------------
-
> >
>
>
>
> --
> Regards,
> Henrik Rützou
>
> [9]http://powerEXT.com <[10]http://powerext.com/>
>
----------------------------------------------------------------------
-
> This is the FTPAPI mailing list. To unsubscribe, please go to:
> [11]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.
References
1. cid:330@goomoji.gmail
2. http://www.scottklement.com/mailman/listinfo/ftpapi
3. http://www.scottklement.com/mailman/listinfo/ftpapi
4. mailto:thomas.raddatz@xxxxxxxxxxx
5. http://www.scottklement.com/mailman/listinfo/ftpapi
6. http://www.scottklement.com/mailman/listinfo/ftpapi
7. http://www.scottklement.com/mailman/listinfo/ftpapi
8. http://www.scottklement.com/mailman/listinfo/ftpapi
9. http://powerext.com/
10. http://powerext.com/
11. 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
-----------------------------------------------------------------------