如何在 SOAP 中向请求添加 XML 属性?

发布于 2024-12-14 09:07:01 字数 1639 浏览 2 评论 0原文

我需要像这样创建 SOAP 请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:stor="http://storage.xdoc.xx/">
   <soapenv:Header/>
   <soapenv:Body>
      <stor:createDocument>
         <parentEntryId>workspace://SpacesStore/15f33e3a-32ba-4a5d-976f-c9e2096e1112</parentEntryId>
         <name>test.txt</name>
         <properties module="" name="Content" type="Binary">
            <valueBinary>
               <bytes>cXdlcnR5</bytes>
            </valueBinary>
         </properties>
      </stor:createDocument>
   </soapenv:Body>
</soapenv:Envelope>

据我所知,我需要使用嵌套数组,但问题出在 XML 属性中。 SoapVar 似乎不完全是我所需要的。

现在我有这样的呼吁:

$client->__callSoap("createDocument",
                                array(new SoapParam($name, "name"),
                                        new SoapParam(
                                                new SoapParam(
                                                        new SoapParam(
                                                                $contents,
                                                                "bytes"
                                                        ),
                                                        "valueBinary"
                                                ),
                                                "properties"
                                        )
                                )
                        );  

如何给“属性”添加属性?

先感谢您。

I need to create SOAP request like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:stor="http://storage.xdoc.xx/">
   <soapenv:Header/>
   <soapenv:Body>
      <stor:createDocument>
         <parentEntryId>workspace://SpacesStore/15f33e3a-32ba-4a5d-976f-c9e2096e1112</parentEntryId>
         <name>test.txt</name>
         <properties module="" name="Content" type="Binary">
            <valueBinary>
               <bytes>cXdlcnR5</bytes>
            </valueBinary>
         </properties>
      </stor:createDocument>
   </soapenv:Body>
</soapenv:Envelope>

As far as I understand I need to use nested arrays, but the problem is in the XML properties. SoapVar seems to be not exactly what I need.

Now I have such a call:

$client->__callSoap("createDocument",
                                array(new SoapParam($name, "name"),
                                        new SoapParam(
                                                new SoapParam(
                                                        new SoapParam(
                                                                $contents,
                                                                "bytes"
                                                        ),
                                                        "valueBinary"
                                                ),
                                                "properties"
                                        )
                                )
                        );  

How to add attributes to "properties"?

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国产ˉ祖宗 2024-12-21 09:07:01

我尝试了一些变体来完成这项工作 - 使用嵌套数组、stdClass、SoapVar 编码数组和组合等。但我发现可以正常工作的唯一变体是:

 $parameters = new stdClass();
 $parameters->name = $name;
 $parameters->parentEntryId = $parentEntryId;
 $parameters->properties = new stdClass();
 $propsSimpleVar = new SoapVar("<properties module=\"\" name=\"Content\" type=\"Binary\"><valueBinary><bytes>" . $cleanContents . "</bytes></valueBinary></properties>", XSD_ANYXML);

 $parameters->properties = $propsSimpleVar;

 $client->createDocument( $parameters );

我认为它应该与属性数组一起使用也。
希望这对其他人有用。

I've tried some variants to make this work - with nested arrays, and stdClass, and SoapVar enconded arrays, and combinations, etc. But the only variant I found to be working properly is that:

 $parameters = new stdClass();
 $parameters->name = $name;
 $parameters->parentEntryId = $parentEntryId;
 $parameters->properties = new stdClass();
 $propsSimpleVar = new SoapVar("<properties module=\"\" name=\"Content\" type=\"Binary\"><valueBinary><bytes>" . $cleanContents . "</bytes></valueBinary></properties>", XSD_ANYXML);

 $parameters->properties = $propsSimpleVar;

 $client->createDocument( $parameters );

I think it should work with array for properties too.
Hope this'll be useful for someone else.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文