SoapVar/Param 和 SOAP 中嵌套的重复元素

SoapVar/Param and nested, repeated elements in SOAP(SoapVar/Param 和 SOAP 中嵌套的重复元素)
本文介绍了SoapVar/Param 和 SOAP 中嵌套的重复元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我的目标是能够创建一个包含如下项目的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,则将每个项目都包装在另一个项目"元素中,这也是不可取的.

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 中嵌套的重复元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)