問題描述
我正在使用 PHP 開發 SOAP 客戶端,并且調用可以很好地傳遞給服務,但存在彼此相同的元素的調用除外.似乎發生這種情況時,而不是創建兩個獨立但相同的元素,如下所示:
I am working on a SOAP client in PHP, and the calls are going through to the service fine, with the exception of calls where there are elements that are identical to each other. It seems that when this happens, rather than creating two separate but identical elements, like this:
<ns1:someelement>
<ns1:name>name1</ns1:name>
<ns1:value>value1</ns1:value>
</ns1:someelement>
<ns1:someelement>
<ns1:name>name1</ns1:name>
<ns1:value>value1</ns1:value>
</ns1:someelement>
它堅持只制作元素的一個副本并為其分配一個 ID,并對該元素的任何后續實例使用 href(如下所示),而我正在使用的網絡服務不支持(我不支持)知道這是為什么,但這并不重要,因為我無法改變它)
it is insisting on making only one copy of the element and assigning it an ID, and using href for any subsequent instances of that element (shown below), which is not supported by the webservice I am using (I don't know why this is, but it doesn't really matter because I cannot change it)
<ns1:someelement id="#ref1">
<ns1:name>name1</ns1:name>
<ns1:value>value1</ns1:value>
</ns1:someelement>
<ns1:someelement href="#ref1" />
所以我的問題是如何強制 XML 包含完整的重復元素,而不是使用 hrefs/ids.我檢查了 PHP SoapClient 的文檔以獲取選項或類似內容,但找不到任何內容.任何幫助或建議將不勝感激.謝謝.
So my question is how might I force the XML to come out with the duplicate elements included in full, rather than them using hrefs/ids. I checked the docs for PHP SoapClient for an option or something of the sort, but couldn't find anything. Any help or advice would be greatly appreciated. Thanks.
推薦答案
SoapClient 僅在您在多個 XML 節點上使用同一對象時才進行引用.如果您不想要引用,請為每個位置創建一個新對象.
SoapClient makes a reference only when you use the same object on multiple XML nodes. Make for each place a new object if you do not want the references.
這篇關于PHP SoapClient 為相同元素創建 XML 引用,使其無法用于服務的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!