Конференция "Сети" » Передача комплексных типов в SOAP
 
  • halilpro (24.07.12 00:17) [0]
    Здравствуйте!
    Использую ХЕ2.
    Реализовал веб-сервис, который должен обрабатывать массив значений:
    .....
    Tindicator = class (TRemotable)
     private
       FindicatorName: String;
       FindicatorCode: String;
     published
       property indicatorName: String read FindicatorName write FindicatorName;
       property indicatorCode: String read FindicatorCode write FindicatorCode;
     end;

     arr_indic = array of Tindicator;

     TOrderInfo = class (TRemotable)
     private
       FdiagnosticCode: String;
       FdiagnosticName: String;
       ForderPriority: Integer;
       Findicators: arr_indic;
     published
       property diagnosticCode: String read FdiagnosticCode write FdiagnosticCode;
       property diagnosticName: String read FdiagnosticName write FdiagnosticName;
       property orderPriority: Integer read ForderPriority write ForderPriority;
       property indicators: arr_indic read Findicators write Findicators;
      // property indicators: Tindicator read Findicators write Findicators;
     end;
    ....


    Но встал вопрос, что клиент JAX-WS не может работать с массивом, а только с последовательным набором тэгов:
    ...
    <NS1:OrderInfo id="6" xsi:type="NS1:OrderInfo">
     <diagnosticCode xsi:type="xsd:string">555</diagnosticCode>
     <diagnosticName xsi:type="xsd:string" />
     <orderPriority xsi:type="xsd:int">0</orderPriority>
    <NS2:Tindicator id="7" xsi:type="NS2:Tindicator">
     <indicatorName xsi:type="xsd:string">ALT</indicatorName>
     <indicatorCode xsi:type="xsd:string">123</indicatorCode>
    </NS2:Tindicator>
    <NS2:Tindicator id="8" xsi:type="NS2:Tindicator">
     <indicatorName xsi:type="xsd:string">GLU</indicatorName>
     <indicatorCode xsi:type="xsd:string">333</indicatorCode>
     </NS2:Tindicator>
     </NS1:OrderInfo>
    ...


    т.е. индикаторы прямо внутри OrderInfo.

    Просмотрел всю документацию по передачи сложных типов(ее очень мало), не помогло. Единственное нашел кусочек кода, но Дельфи не понимает эти классы:
    TBaseComplexRemotable = class(TAbstractComplexRemotable)
     public
       class procedure Save(
               AObject   : TBaseRemotable;
               AStore    : IFormatterBase;
         const AName     : string;
         const ATypeInfo : PTypeInfo
       );override;
       class procedure Load(
         var   AObject   : TObject;
               AStore    : IFormatterBase;
         var   AName     : string;
         const ATypeInfo : PTypeInfo
       );override;
       class procedure RegisterAttributeProperty(const AProperty : shortstring);virtual;
       class procedure RegisterAttributeProperties(const APropertList : array of shortstring);virtual;
       class function IsAttributeProperty(const AProperty : shortstring):Boolean;
       procedure Assign(Source: TPersistent); override;
     end;
    TBaseComplexSimpleContentRemotable provides implementation for the “XML Schema” complex types which extend simple types with attributes. The following example illustrates this :

     <xs:complexType name="DecimalWithUnits">
       <xs:simpleContent>
         <xs:extension base="xs:decimal">
           <xs:attribute name="Units" type="xs:string"
                         use="required"/>
         </xs:extension>
       </xs:simpleContent>
     </xs:complexType>
    This type will be translate by ws_helper to Pascal as

     DecimalWithUnits = class(TComplexFloatExtendedContentRemotable)
     private
       FUnits : string;
     published
       property Units : string read FUnits write FUnits;
     end;


    Помогите найти выход.
  • Slym © (26.07.12 15:30) [1]
    в коме обычно коллекции пользуют для таких вещей
  • Slym © (26.07.12 15:39) [2]
    http://www.softwareschule.ch/download/bestof_d3000.txt
    4. Define the arrays of objects
    -----------------------------------------------------------
    We have to decompose a complex structrue in its elements so the class
    TSoapDataPacket has a member of TRowArray which is an array of TSoapRow with the Fields inside:

     TRowArray =   array of TSoapRow;

     TSoapRow = class(TRemotable)
     private
       FRowID: Integer;
       FFieldValueArray: TFieldValueArray;
       FUpdateType: TUpdateType;
     published
       property RowID: Integer read FRowID write FRowID;
       property FieldValueArray: TFieldValueArray read FFieldValueArray
                                 write FFieldValueArray;
       property UpdateType: TUpdateType read FUpdateType
                                 write FUpdateType;
     end;

    As you see, we must map these complex types to a class like TSoapRow that includes runtime type information (RTTI, in published), which the invoker can use to convert between data in the SOAP stream and type values.

    (It can also handle dynamic arrays, as long as they are registered with the remotable type registry).

    If you are using dynamic arrays, enum types, or booleans for parameters, you don't need to create a remotable class to represent them, but you do have to register them with the remotable type registry. Thus, for example, if your interface uses the type mentioned before such as:

    type
      TRowArray = array of TSoapRow;

    then you must add the following registration to the initialization section of the unit where you declare this dynamic array:

    RemClassRegistry.RegisterXSInfo(TypeInfo(TRowArray),'
    urn:ServerDBObjects','TRowA rray','');
    RemClassRegistry.RegisterXSInfo(TypeInfo(TUpdateType),'
    urn:ServerDBObjects','TUp dateType','');
    RemClassRegistry.RegisterXSInfo(TypeInfo(TColDescArray),'
    urn:ServerDBObjects','T ColDescArray','');

 
Конференция "Сети" » Передача комплексных типов в SOAP
Есть новые Нет новых   [134436   +21][b:0][p:0.003]