SoapVar/Param和SOAP中嵌套的重复元素 [英] SoapVar/Param and nested, repeated elements in SOAP

查看:182
本文介绍了SoapVar/Param和SOAP中嵌套的重复元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是能够创建一个包含以下内容的肥皂请求:

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

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

但是,我能够想到的soapvar和soapparam的每种组合都使我无法复制嵌套的名称"标签.我可以像这样获得1个子标签:

However, every combination of soapvar and soapparam I've been able to think up either makes it impossible for me to duplicate the nested 'names' tag. I can get 1 sub tag like so:

$flexFields = array(
  'names'=> new SoapVar(
      new SoapVar(array('names'=>'IAG Group'),SOAP_ENC_OBJECT),
    SOAP_ENC_OBJECT)
);

这将生成:

<flexFields xsi:type="ns2:SoapNamedValues">
  <names xsi:type="names">
    <names xsi:type="xsd:string">IAG Group</names>
  </names>
</flexFields>

但是,如果我使用SOAP_ENC_OBJECT进行任何尝试重复获取名称标签的尝试,都会生成一个可怕的BOGUS元素,或者如果使用SOAP_ENC_ARRAY,则将每个项目都包装在另一个"item"元素中,这也是不希望的.

But any attempt I make to get the names tag to repeat either generates a dreaded BOGUS element if I use SOAP_ENC_OBJECT, or wraps every item in another 'item' element if I use SOAP_ENC_ARRAY, which is also not desirable.

我知道我可以手动创建所需的东西并用XSD_ANYXML加载它,但这已经接近达到使用SOAP库的目的这一行.

I know I could just manually create what I want and load it with XSD_ANYXML, but that is getting close to the line of defeating the purpose of using the SOAP library.

谁能提供一个示例,说明如何完美地平衡soapvar/soapparam +数组嵌套以使其真正起作用?还是我在尝试使用PHP的SOAP库实现不可能?

Can anyone provide an example of just how to perfectly balance the soapvar/soapparam + array nesting to get this to actually work? Or am I attempting the impossible with PHP's SOAP library?

推荐答案

我也遇到了BOGUS标签问题.我的解决方案涉及使用ArrayObject代替数组基元.然后将所有对象转换为SoapVar对象.似乎Soap库确实想在任何地方处理对象.我在这里有更完整的文章:

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

这篇关于SoapVar/Param和SOAP中嵌套的重复元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆