|
458 | 458 | </term>
|
459 | 459 | <listitem>
|
460 | 460 | <para>
|
461 |
| - TODO |
| 461 | + When decoding a response to an array, the default behaviour is to detect whether |
| 462 | + an element name appears once or multiple times in a particular parent element. |
| 463 | + For elements which appear only once, an object property allows direct access to |
| 464 | + the content; for elements which appear more than once, the property contains an |
| 465 | + array with the content of each matching element. |
| 466 | + </para> |
| 467 | + <para> |
| 468 | + If the <constant>SOAP_SINGLE_ELEMENT_ARRAYS</constant> feature is enabled, |
| 469 | + elements which appear only once are placed in a single-element array, so that |
| 470 | + access is consistent for all elements. This only has an effect when using a WSDL |
| 471 | + containing a schema for the response. See Examples sections for an illustration. |
462 | 472 | </para>
|
463 | 473 | </listitem>
|
464 | 474 | </varlistentry>
|
|
468 | 478 | </term>
|
469 | 479 | <listitem>
|
470 | 480 | <para>
|
471 |
| - TODO |
| 481 | + When the <parameter>use</parameter> option is set to <literal>encoded</literal>, |
| 482 | + force arrays to use a type of <literal>SOAP-ENC:Array</literal>, rather than a |
| 483 | + schema-specific type. |
472 | 484 | </para>
|
473 | 485 | </listitem>
|
474 | 486 | </varlistentry>
|
@@ -574,8 +586,7 @@ $client = new SoapClient("some.wsdl", ['context' => $context]);
|
574 | 586 | <para>
|
575 | 587 | <example>
|
576 | 588 | <title>
|
577 |
| - <function>SoapClient::__construct</function> |
578 |
| - example |
| 589 | + <function>SoapClient::__construct</function> example |
579 | 590 | </title>
|
580 | 591 | <programlisting role="php">
|
581 | 592 | <![CDATA[
|
@@ -623,6 +634,73 @@ $client = new SoapClient("books.wsdl", array('classmap' => array('book' => "MyBo
|
623 | 634 | </programlisting>
|
624 | 635 | </example>
|
625 | 636 | </para>
|
| 637 | + |
| 638 | + <para> |
| 639 | + <example> |
| 640 | + <title>Using the <constant>SOAP_SINGLE_ELEMENT_ARRAYS</constant> feature</title> |
| 641 | + <programlisting role="php"> |
| 642 | + <![CDATA[ |
| 643 | + /* Assuming a response like this, and an appropriate WSDL: |
| 644 | + <?xml version="1.0" encoding="UTF-8"?> |
| 645 | + <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:example"> |
| 646 | + <SOAP-ENV:Body> |
| 647 | + <response> |
| 648 | + <collection> |
| 649 | + <item>Single</item> |
| 650 | + </collection> |
| 651 | + <collection> |
| 652 | + <item>First</item> |
| 653 | + <item>Second</item> |
| 654 | + </collection> |
| 655 | + </response> |
| 656 | + </SOAP-ENV:Body> |
| 657 | + </SOAP-ENV:Envelope> |
| 658 | + */ |
| 659 | +
|
| 660 | + echo "Default:\n"; |
| 661 | +
|
| 662 | + $client = new TestSoapClient(__DIR__ . '/temp.wsdl'); |
| 663 | + $response = $client->exampleRequest(); |
| 664 | + var_dump( $response->collection[0]->item ); |
| 665 | + var_dump( $response->collection[1]->item ); |
| 666 | +
|
| 667 | + echo "\nWith SOAP_SINGLE_ELEMENT_ARRAYS:\n"; |
| 668 | +
|
| 669 | + $client = new TestSoapClient(__DIR__ . '/temp.wsdl', ['features' => SOAP_SINGLE_ELEMENT_ARRAYS]); |
| 670 | + $response = $client->exampleRequest(); |
| 671 | + var_dump( $response->collection[0]->item ); |
| 672 | + var_dump( $response->collection[1]->item ); |
| 673 | + ]]> |
| 674 | + </programlisting> |
| 675 | + |
| 676 | + &example.outputs; |
| 677 | + |
| 678 | + <screen> |
| 679 | + <![CDATA[ |
| 680 | + Default: |
| 681 | + string(6) "Single" |
| 682 | + array(2) { |
| 683 | + [0] => |
| 684 | + string(5) "First" |
| 685 | + [1] => |
| 686 | + string(6) "Second" |
| 687 | + } |
| 688 | +
|
| 689 | + With SOAP_SINGLE_ELEMENT_ARRAYS: |
| 690 | + array(1) { |
| 691 | + [0] => |
| 692 | + string(6) "Single" |
| 693 | + } |
| 694 | + array(2) { |
| 695 | + [0] => |
| 696 | + string(5) "First" |
| 697 | + [1] => |
| 698 | + string(6) "Second" |
| 699 | + } |
| 700 | + ]]> |
| 701 | + </screen> |
| 702 | + </example> |
| 703 | + </para> |
626 | 704 | </refsect1>
|
627 | 705 |
|
628 | 706 | </refentry>
|
|
0 commit comments