Web-services and complex objectparameters

Author: roger.wallin@abilita.fi (rogerw)

Hi,
Uniface 9.4.01.02 (R103 0707_1).

Using web-services, there seem to be very popular to return "objects" of "complex types" as a parameter of the web-service.
If Uniface is able to map this as a simple occurrence or entity (=many occurrences) it does so. Importing the wsdl makes Uniface create a model and the entity with fields, Uniface also creates the signatures of the service-functions using occurrence- or entityparameters.

Because of the complex world :-( there seem to be even more popular to build web-services returning "objects" of "complex types within complex types", ie. usually typical master-child situations. Importing wsdl describing this kind of situation doesn't create any entities and the signatures created are using string-parameters instead of occurrence- or entityparameters.
Perhaps it's meant that these complex objects should be handled by xmlstreams/strings in Uniface, using eg. xmlload, xmlsave or sax to handle these further.
Unfortunately Uniface seems to add a lot of unnecessary namespace declarations to the xmlstream returned by the web-service object-parameter??

Any advice about using these kind of web-services with Uniface appreciated, ie. web-services taking or returning parameters containing objects of "complex types within complex types" (Uniface: master entity - child entity).

Regards RogerW.


Example of typical WSDL-part:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/Models" xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:tns="http://schemas.datacontract.org/2004/07/Models">
<xs:complexType name="Master">
 <xs:sequence>
  <xs:element name="MasterID" type="xs:string" />
  <xs:element minOccurs="0" name="Details" nillable="true" type="tns:ArrayOfDetail"/>
 </xs:sequence>
</xs:complexType>
<xs:element name="Master" nillable="true" type="tns:Master"/>  ;Making an instance
<xs:complexType name="ArrayOfDetail">
 <xs:sequence>
  <xs:element minOccurs="0" maxOccurs="unbounded" name="Detail" nillable="true" type="tns:Detail"/>
 </xs:sequence>
</xs:complexType>
<xs:element name="ArrayOfDetail" nillable="true" type="tns:ArrayOfDetail"/>
<xs:complexType name="Detail">
 <xs:sequence>
  <xs:element name="DetailID" type="xs:string" />
 </xs:sequence>
</xs:complexType>
<xs:element name="Detail" nillable="true" type="tns:Detail"/>
</xs:schema>
 

9 Comments

  1. Hi rogerw,

    best case: use a simple XML writer to compose a string as required (and accepted) by the "consuming partner"

    if the XMLWRITER provided by CPWR is not "complete" enough, external tools provide the complete XML specification.
    Or write your own XML writer functionality (I have done it in 100% uniface, it's easy "dITo").

    Uli


    Author: ulrich-merkel (ulrichmerkel@web.de)
  2. Hi,

    actually I would like to use the web-service in the same way as is possible if the object (mapped as Uniface occurrence) doesn't contain a child entity, ie.

    activate "testservice".GetOccurrence("MyEntityDefinedByImport.Http_Schemas")    ;The entity is automatically filled without xml-editing   

    activate "testservice".GetMasterDetail("MasterWithDetail")   ;Master and Detail not automatically created at Import, but this is how I would like to use it, signatureparameter=occurrence or entity

    So there is no problem with a simple entity, but as soon as there is a "entity in a entity", can't Uniface handle it without starting to do xmllload and xmlsave with a intermediate xmlstream?
    Furthermore,  if you try to get the object into a xmlstream/string, 
     activate "testservice".GetMasterDetail("tempXmlString")    ;Signatureparameter defined as string
    Uniface seems to rename the root-element and starts to repeat namespaces of the xmlstream??

    Regards RogerW.

     


    Author: rogerw (roger.wallin@abilita.fi)
  3. Dear Roger,

    This info probably does not help you in the short term, but In Uniface 9.5 we plan to enhance the support for complex types of Web Services. This will be done by introducing a new Uniface data type called STRUCT, which will be able to handle complex types like for example ArrayOfDetail (as defined in the above mentioned WSDL) - as a matter of fact it should be able to handle anything that can be expressed in XML. We unfortanetly cannot give you an exact release date for version 9.5 (yet), but it probably will be end of 2011/beginning of 2012 - please contact your local TAM (Technical Account Manager) in case you would like to be kept informed about this.

    And concerning the namespace of complex parameters please keep the following note in mind from the Uniface Library topic (Integrating With Other Technologies > Web Services > Call-Out From Uniface to a Web Service >) Data Type Mapping for Web Service Call-Out:

    "Note:  Complex XML Schema data types should be treated as completely self-contained—if any element of a complex parameter requires a specific XML namespace, you need to ensure that each namespace is explicitly defined."

    Hope this helps.

    Kind regards,
    Daniel

    *** Usual disclaimer ***


    Author: diseli (daniel.iseli@uniface.com)
  4. Hi Daniel

    This new type STRUCT is avaible in the proc language itself?

    So one can write something like this:

     

    params

      STRUCT {NAME C40,BIRTDAY:date} aSTRUCT :inout

    endparams

    aSTRUCT.NAME="My Name"

    aSTRUCT.BIRTHDAY="1.1.2000"

     

    Can you tell us a little bit more about this new type?

    So we can prepare our programms for this feature :-)

     

    TIA

    Ingo


    Author: istiller (i2stiller@gmx.de)

  5. Hi,

    yes it would be very interesting to know some more about this :-).

    STRUCT {CName C40, CBirthday:date} ChildStruct

     STRUCT {NAME C40,BIRTDAY:date, list of CHILDSTRUCT} aSTRUCT
    aSTRUCT.NAME="My Name"
    aSTRUCT.BIRTHDAY="1.1.2000"
    aSTRUCT.CHILDSTRUCT[1].CName="ChildName"

    And how would this map to the Uniface model. Sounds like a huge change/feature.

    Regards RogerW.

     


    Author: rogerw (roger.wallin@abilita.fi)
  6. ... and why waiting for 9.5.? I am also very interested in these kind of enhancements. If it is this, what I think it is, I need it right now...

    but I am afraid, before iCU2011 we do not get any information about the planned 9.5. features and release plans :-(

    Regards W.


    Author: gypsilon (wva@gypsilon.de)
  7. Thanks Daniel,

    I have to see how I can manage this until Uniface 9.5.
    In this specific case we do control the web-services, and should be able to declare the parameter as "any", "text" or something ?!?!
    I still don't understand what's triggering Uniface to change the xml.
    We have to do some further testing.....

    However it's very good if you address this problem. You could test your Uniface 9.5 import with the eg. the following.

    http://www.fkl.fi/verkkolasku/yrityksen_verkkolasku/ladattavat/Tekniset%20tiedostot/schemat/Finvoice.xsd

    Regards RogerW.


    Author: rogerw (roger.wallin@abilita.fi)
  8. Dear Roger,

    I'm not certain what you mean by "[...] what's triggering Uniface to change the xml." Are you referring to fact that Uniface will add the namespace ns0 to the SOAP message? The ns0 namespace is added by the XML parser Uniface is using, but that should not be (too) important here.

    You however should keep in mind that namespaces are not inherited from the parent element. A parent element can set a default namespace by using xmlns="some_uri", but if it uses a specific prefix (i.e. xmlns:ns0="some_uri"), that explicit prefix has to be used. Uniface cannot set a 'default' prefix because it has no way of knowing whether this would clash with elements that are defined as 'unqualified'. And therefore the only way is to treat the complex parameter as completely self-contained.

    Hope this clarifies this matter.

    @All: I'm not going to start speculating about how exactly the struct data type might look like or how it could be used. This functionality is still under development and I'm afraid we just have to wait until it’s finished before we could start any discussion about it.

    Kind regards,
    Daniel

    *** Usual disclaimer ***

     


    Author: diseli (daniel.iseli@uniface.com)
  9. Hi Daniel,

    I don't know if this is important anymore as I think we can handle it, but the first example is how it's going over the wire, and the second is after Uniface has changed it.
    Uniface changes <GetMasterAnyResult> to  <ufnc:parameter xmlns:ufnc="urn:uniface:applic:complexparameter"> and adds the version tag.

    Regards RogerW

     

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Body>
        <GetMasterAnyResponse xmlns="http://www.anyorg.fi/">
          <GetMasterAnyResult>
            <Master xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
              <MasterID>1</MasterID>
              <MasterName>Borje</MasterName>
              <Details>
                <Detail>
                  <MasterID>1</MasterID>
                  <DetailID>10</DetailID>
                  <DetailName>Bob</DetailName>
                </Detail>
                <Detail>
                  <MasterID>1</MasterID>
                  <DetailID>20</DetailID>
                  <DetailName>Kalle</DetailName>
                </Detail>
              </Details>
            </Master>
          </GetMasterAnyResult>
        </GetMasterAnyResponse>
      </s:Body>
    </s:Envelope>

     

    <?xml version="1.0" encoding="UTF-8"?>
    <ufnc:parameter xmlns:ufnc="urn:uniface:applic:complexparameter">
     <Master xmlns="">
      <MasterID xmlns="">1</MasterID>
      <MasterName xmlns="">Borje</MasterName>
      <Details xmlns="">
       <Detail xmlns="">
        <MasterID xmlns="">1</MasterID>
        <DetailID xmlns="">10</DetailID>
        <DetailName xmlns="">Bob</DetailName>
       </Detail>
       <Detail xmlns="">
        <MasterID xmlns="">1</MasterID>
        <DetailID xmlns="">20</DetailID>
        <DetailName xmlns="">Kalle</DetailName>
       </Detail>
      </Details>
     </Master>
    </ufnc:parameter>
     


    Author: rogerw (roger.wallin@abilita.fi)