Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1411 connectés 

  FORUM HardWare.fr
  Programmation
  Perl

  [Perl] Récupérer une information dans un retour SOAP

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[Perl] Récupérer une information dans un retour SOAP

n°2271105
Shadow aok
Moitié de demi en 3/4 d'entier
Posté le 08-12-2015 à 17:02:27  profilanswer
 

Bonjour,
 
Je m'y perds un peu dans la structure ci-dessous, retournée par une requête SOAP.
 
Il faudrait que je récupère l'id 1534 et la ref FA1512-1277 dans le hash undef.
 
Une idée pour y accéder ?
 
Merci,
 

Code :
  1. $VAR1 = bless( {
  2.                  '_content' => [
  3.                                  'SOAP-ENV:Envelope',
  4.                                  {
  5.                                    'xmlns:tns' => 'http://www.dolibarr.org/ns/',
  6.                                    'SOAP-ENV:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/',
  7.                                    'xmlns:SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
  8.                                    'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
  9.                                    'xmlns:SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/',
  10.                                    'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
  11.                                  },
  12.                                  [
  13.                                    [
  14.                                      'SOAP-ENV:Body',
  15.                                      {},
  16.                                      [
  17.                                        [
  18.                                          'ns1:createInvoiceResponse',
  19.                                          {
  20.                                            'xmlns:ns1' => 'http://schemas.xmlsoap.org/soap/envelope/'
  21.                                          },
  22.                                          [
  23.                                            [
  24.                                              'result',
  25.                                              {
  26.                                                'xsi:type' => 'tns:result'
  27.                                              },
  28.                                              [
  29.                                                [
  30.                                                  'result_code',
  31.                                                  {
  32.                                                    'xsi:type' => 'xsd:string'
  33.                                                  },
  34.                                                  'OK',
  35.                                                  undef,
  36.                                                  'OK',
  37.                                                  'result_code',
  38.                                                  {
  39.                                                    '{http://www.w3.org/2001/XMLSchema-instance}type' => '{http://www.w3.org/2001/XMLSchema}string',
  40.                                                    'xsi:type' => 'xsd:string'
  41.                                                  }
  42.                                                ],
  43.                                                [
  44.                                                  'result_label',
  45.                                                  {
  46.                                                    'xsi:type' => 'xsd:string'
  47.                                                  },
  48.                                                  '',
  49.                                                  undef,
  50.                                                  '',
  51.                                                  'result_label',
  52.                                                  {
  53.                                                    '{http://www.w3.org/2001/XMLSchema-instance}type' => '{http://www.w3.org/2001/XMLSchema}string',
  54.                                                    'xsi:type' => 'xsd:string'
  55.                                                  }
  56.                                                ]
  57.                                              ],
  58.                                              undef,
  59.                                              bless( {
  60.                                                       'result_label' => '',
  61.                                                       'result_code' => 'OK'
  62.                                                     }, 'result' ),
  63.                                              'result',
  64.                                              {
  65.                                                'xsi:type' => 'tns:result',
  66.                                                '{http://www.w3.org/2001/XMLSchema-instance}type' => '{http://www.dolibarr.org/ns/}result'
  67.                                              }
  68.                                            ],
  69.                                            [
  70.                                              'id',
  71.                                              {
  72.                                                'xsi:type' => 'xsd:string'
  73.                                              },
  74.                                              '1534',
  75.                                              undef,
  76.                                              '1534',
  77.                                              'id',
  78.                                              {
  79.                                                'xsi:type' => 'xsd:string'
  80.                                              }
  81.                                            ],
  82.                                            [
  83.                                              'ref',
  84.                                              {
  85.                                                'xsi:type' => 'xsd:string'
  86.                                              },
  87.                                              'FA1512-1277',
  88.                                              undef,
  89.                                              'FA1512-1277',
  90.                                              'ref',
  91.                                              {
  92.                                                'xsi:type' => 'xsd:string'
  93.                                              }
  94.                                            ]
  95.                                          ],
  96.                                          undef,
  97.                                          {
  98.                                            'id' => '1534',
  99.                                            'result' => $VAR1->{'_content'}[2][0][2][0][2][0][4],
  100.                                            'ref' => 'FA1512-1277'
  101.                                          },
  102.                                          '{http://schemas.xmlsoap.org/soap/envelope/}createInvoiceResponse',
  103.                                          {}
  104.                                        ]
  105.                                      ],
  106.                                      undef,
  107.                                      {
  108.                                        'createInvoiceResponse' => $VAR1->{'_content'}[2][0][2][0][4]
  109.                                      },
  110.                                      '{http://schemas.xmlsoap.org/soap/envelope/}Body',
  111.                                      {}
  112.                                    ]
  113.                                  ],
  114.                                  undef,
  115.                                  {
  116.                                    'Body' => $VAR1->{'_content'}[2][0][4]
  117.                                  },
  118.                                  '{http://schemas.xmlsoap.org/soap/envelope/}Envelope',
  119.                                  {
  120.                                    'SOAP-ENV:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/',
  121.                                    '{http://schemas.xmlsoap.org/soap/envelope/}encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/'
  122.                                  }
  123.                                ],

mood
Publicité
Posté le 08-12-2015 à 17:02:27  profilanswer
 

n°2271112
Shadow aok
Moitié de demi en 3/4 d'entier
Posté le 08-12-2015 à 18:13:13  profilanswer
 

Bon, j'ai finalement réussi comme ceci :
$VAR1->{'_content'}[2][0][2][0][4]->{'id'} (ou ref).

n°2271113
gilou
Modérateur
Modzilla
Posté le 08-12-2015 à 18:15:52  profilanswer
 

$VAR1->{'_content'}->[2]->[0]->[2]->[0]->[4]->{'id'}
et
$VAR1->{'_content'}->[2]->[0]->[2]->[0]->[4]->{'ref'}
 
En virant les trucs inutiles de l'exemple, on arrive à

$VAR1 = bless( {
  '_content' => [
          '',
          {},
          [
    [
     '',
     {},
     [
      [
       '',
       {},
       [],
       undef,
       {
        'id' => '1534',
        'result' => $VAR1->{'_content'}[2][0][2][0][2][0][4],
        'ref' => 'FA1512-1277'
       },


 
qui se réduit, en simplifiant, pour tester, a:

Code :
  1. my $VAR1 = { '_content' => ['aaa', 'bbb',
  2.         [['aaa', 'bbb',
  3.           [['aaa', 'bbb', 'ccc', 'ddd',
  4.         {
  5.          'id' => '1534',
  6.          'result' => $VAR1->{'_content'}[2][0][2][0][2][0][4],
  7.          'ref' => 'FA1512-1277'
  8.         }]]]]]};


 
et il y a plus qu'à compter les positions dans les tableaux.
EDIT: je vois que tu y était arrivé. C'est plus juste avec les flèches partout, mais perl sait se débrouiller sans dans les cas simples.
 
A+,


Message édité par gilou le 08-12-2015 à 18:18:10

---------------
There's more than what can be linked! --    Iyashikei Anime Forever!    --  AngularJS c'est un framework d'engulé!  --
n°2271114
Shadow aok
Moitié de demi en 3/4 d'entier
Posté le 08-12-2015 à 18:16:48  profilanswer
 

C'est quand même super moche comme retour !

n°2271115
gilou
Modérateur
Modzilla
Posté le 08-12-2015 à 18:19:57  profilanswer
 

Bof, tu manipules le même genre de chose quand tu fais de la programmation en C avec des structures complexes.
Et c'est bien plus coton, puisqu'il faut gérer la mémoire à la mimine :/
 
A+,


---------------
There's more than what can be linked! --    Iyashikei Anime Forever!    --  AngularJS c'est un framework d'engulé!  --

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Perl

  [Perl] Récupérer une information dans un retour SOAP

 

Sujets relatifs
Concatenation lignes[Perl] simplifier ma regex
[ASP] Terniner une page avec un code retour précis[PERL] CGI retourner un code erreur
Code de retour Runtime avec exitValueRécupérer telnet via PHP
e voudrais lancer plusieurs script Perl à partir d'un autre script PerRécupérer valeurs
Récupérer des valeurs fusionnéesRecuperer l'URL d'un spreadsheet et l'envoyer par mail
Plus de sujets relatifs à : [Perl] Récupérer une information dans un retour SOAP


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR