SoapVar/Param and nested, repeated elements in SOAP

后端 未结 2 538
后悔当初
后悔当初 2020-12-06 19:21

My goal is to be able to create a soap request that can contain items like so:


  
    IAG Group
           


        
相关标签:
2条回答
  • 2020-12-06 20:06

    I have a similar problem, try this:

    $Names=array();
    $Names[]=new SoapVar("IAG Group",XSD_STRING,null,null,'names');
    $Names[]=new SoapVar("Ticket #",XSD_STRING,null,null,'names');
    $BigNames=new SoapVar($Names,SOAP_ENC_OBJECT,null,null,'Names');
    

    This creates and array of of SoapVar objects ($Names) and places them in the BigNames object, creating an output like this:

    <Names>
        <names>IAG Group</names>
        <names>Ticket #</names>  
    </Names>
    

    You can then create another SoapVar object for FlexFields, but for some reason you can't place a SoapVar object directly into another, it has to be stored in an array...

    I want to do this:

    $FlexFields=new SoapVar($BigNames,SOAP_ENC_OBJECT,null,null,'FlexFields');
    

    This works:

    $FF=array($BigNames);
    $FlexFields=new SoapVar($FF,SOAP_ENC_OBJECT,null,null,'FlexFields');
    
    0 讨论(0)
  • 2020-12-06 20:07

    I ran into the BOGUS tag problem also. My solution involved using an ArrayObject in place of array primitives. The objects are all then converted to SoapVar objects. It seems the soap library really wants to deal with objects everywhere. I have a more complete writeup here:

    http://www.fischco.org/blog/2011/3/26/php-soapserver-objects-arrays-and-encoding.html

    0 讨论(0)
提交回复
热议问题