pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <bdo id='CBQk5'></bdo><ul id='CBQk5'></ul>

      <small id='CBQk5'></small><noframes id='CBQk5'>

      <tfoot id='CBQk5'></tfoot>
      1. <legend id='CBQk5'><style id='CBQk5'><dir id='CBQk5'><q id='CBQk5'></q></dir></style></legend>

        <i id='CBQk5'><tr id='CBQk5'><dt id='CBQk5'><q id='CBQk5'><span id='CBQk5'><b id='CBQk5'><form id='CBQk5'><ins id='CBQk5'></ins><ul id='CBQk5'></ul><sub id='CBQk5'></sub></form><legend id='CBQk5'></legend><bdo id='CBQk5'><pre id='CBQk5'><center id='CBQk5'></center></pre></bdo></b><th id='CBQk5'></th></span></q></dt></tr></i><div class="ix0elcm" id='CBQk5'><tfoot id='CBQk5'></tfoot><dl id='CBQk5'><fieldset id='CBQk5'></fieldset></dl></div>
      2. PHP SoapVar 對象屬性?

        PHP SoapVar Object Attribute?(PHP SoapVar 對象屬性?)
          • <bdo id='LMNBC'></bdo><ul id='LMNBC'></ul>
              <tbody id='LMNBC'></tbody>
              <tfoot id='LMNBC'></tfoot>
              <i id='LMNBC'><tr id='LMNBC'><dt id='LMNBC'><q id='LMNBC'><span id='LMNBC'><b id='LMNBC'><form id='LMNBC'><ins id='LMNBC'></ins><ul id='LMNBC'></ul><sub id='LMNBC'></sub></form><legend id='LMNBC'></legend><bdo id='LMNBC'><pre id='LMNBC'><center id='LMNBC'></center></pre></bdo></b><th id='LMNBC'></th></span></q></dt></tr></i><div class="xawkgec" id='LMNBC'><tfoot id='LMNBC'></tfoot><dl id='LMNBC'><fieldset id='LMNBC'></fieldset></dl></div>
            • <small id='LMNBC'></small><noframes id='LMNBC'>

                <legend id='LMNBC'><style id='LMNBC'><dir id='LMNBC'><q id='LMNBC'></q></dir></style></legend>

                  本文介紹了PHP SoapVar 對象屬性?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  有沒有人知道如何向 SoapVar 對象添加屬性?看起來這很簡單,但我無法接受/工作.

                  我查看了 PHP 文檔和以下 stackoverflow 問題:

                  關于 SoapVar 的文檔,

                  stackoverflow 問題:SoapVar/Param 和 SOAP 中的嵌套重復元素

                  我正在嘗試添加一個像這個數組示例一樣的屬性,但使用復雜的 SoapVar 對象.

                  最終結果是

                  25

                  謝謝.

                  解決方案

                  在 SOAP 元素中獲取屬性有點麻煩.他們實施的方式有點令人困惑.

                  首先要做的是將屬性添加到 SoapServer 用來正確讀取和響應 SOAP 請求的 wsdl 文件.

                  <xs:simpleContent><xs:extension base=xs:string">**

                  我們必須告訴 SoapServer 使用一個 php 幫助類,方法是將它作為 classmap 傳遞到選項中:

                  $soap_server = new SoapServer($wsdl_file, array('cache_wsdl' =>1、'跟蹤' =>真的,'類圖' =>數組('mediaCollection' => 'SoapMediaHelper')));

                  我們在這里映射的是 SOAP 元素名稱 mediaCollection 到我們的一個類 SoapMediaHelper.我們現在可以返回一個 class,而不是返回數組,在這種情況下,它被命名為 SoapMediaHelper.該類可以具有soap-element=>值對以及soap-attribute=>值對.

                  假設我們已經創建了一個處理 mediaCollection 的類,這會告訴 SoapServer 將一個名為 SoapMediaHelper 的類映射到它.這個類真的很簡單:

                  class SoapMediaHelper{公共函數 __construct(Array $properties = array()){foreach ($properties as $key => $value) {$this->{$key} = $value;}}}

                  必須填充此類的屬性.這些屬性應該是 tagname=>value 對以及我們想要添加到 mediaCollection 的屬性的屬性名稱和值對.SoapServer 將根據我們的 wsdl 文件找出哪個是哪個.

                  我們仍然需要填充這個對象,我們可以用另一個類來完成.

                  class SoapVarHelper{公共函數 get($the_playlist, $playlist_id, $owned_by_user){/* SoapMediaHelper 類映射到 mediaCollection wsdl.* 只需要在使用 php 的 SoapServer 時能夠在 XML 節點上設置屬性* */$media_helper = new SoapMediaHelper($the_playlist);/* 對于這種類型,必須設置以下 xml 屬性.(不在上面的 wsdl 示例中.)*/if($playlist_id === '播放列表'){$media_helper->readOnly = false;$media_helper->userContent = true;$media_helper->renameable = false;$media_helper->canDeleteItems = true;}如果($owned_by_user){$media_helper->readOnly = false;$media_helper->userContent = false;$media_helper->renameable = true;$media_helper->canDeleteItems = true;$media_helper->canReorderItems = true;}返回新的 SoapVar($media_helper, SOAP_ENC_OBJECT);}}

                  這個類應該用普通的標記名=>值對來調用.然后添加我們想要的屬性.在這種情況下是有條件的.我們將 SoapMediaHelper 對象提供給 SoapVar.(我們之前告訴 SoapServer 這很好.)

                  現在我們需要做的最后一件事是,在我們的 mediaCollection 類中,使用幫助器 SoapVarHelper 返回一個 SoapMediaHelper(我們之前告訴 SoapServer 的一個).

                  在我們的 mediaCollection 中,我們有一個函數 get_metadata_for_root:

                  public function get_metadata_for_root($user_id, $index, $count){$titles = 數組('幻燈片' =>'精選',);$media_metadata = array();foreach($titles as $key => $title){$播放列表=數組('id' =>$key,'標題' =>$title,'img' =>$this->_utils->get_url() .'/public/sonos/images/browse-icons/icon-default-legacy.png');**$media_metadata[] = $this->_soap_var_helper->get($playlist, $key, false);**}$res = 數組('計數' =>計數($media_metadata),'索引' =>0,'總計' =>計數($media_metadata),'mediaCollection' =>$media_metadata);}

                  對于每個 mediaCollection 結果,我們通過 soap_var_helper 傳遞它以確保不僅添加了 element=>value 對,而且還添加了我們想要的屬性

                  總結:

                  1. 確保為 SoapServer 提供 wsdl 文件,以便它知道元素和屬性.

                  2. SoapServer 選項中添加 classmap 以告訴 SoapServer 當我們給它一個 SoapMediaHelper 對象而不是常規輸入.

                  3. 在響應請求之前,在本例中為 mediaCollection,通過 SoapMediaHelper 傳遞此響應.SoapVarHelper 將所有 properties=>value 對映射為類屬性,然后 SoapMediaHelper 將向其添加屬性(也作為 name=>value 對).

                  4. SoapServer 會處理剩下的事情.

                  Does anyone have any clue as to how I can add an attribute to a SoapVar object? It seems like it would be simple, but I can't get it to take/work.

                  I've looked at the PHP docs and at the following stackoverflow question:

                  Documentation on SoapVar,

                  stackoverflow question: SoapVar/Param and nested, repeated elements in SOAP

                  I'm trying to add an attribute like this array example, but using complex SoapVar objects instead.

                  <?php
                   $amount['_'] = 25;
                   $amount['currencyId'] = 'GBP';
                   $encodded = new SoapVar($amount, SOAP_ENC_OBJECT);
                  
                  ?>
                  

                  and end result wound be

                  <amount currencyId="GBP">25</amount> 
                  

                  Thanks.

                  解決方案

                  Getting attributes into SOAP elements is a bit of a hassle. The way they implemented it is a bit confusing.

                  First thing to do is add the attributes to the wsdl file that SoapServer uses to correctly read and respond to the SOAP requests.

                  <xs:complexType name="encryptionContext">
                      <xs:simpleContent>
                          <xs:extension base="xs:string">
                              **<xs:attribute name="type" type="tns:encryptionType" />**
                          </xs:extension>
                      </xs:simpleContent>
                  </xs:complexType>
                  

                  We will have to tell SoapServer to use a php helper class by passing it in the options as classmap:

                  $soap_server = new SoapServer($wsdl_file, array(
                      'cache_wsdl' => 1,
                      'trace' => true,
                      'classmap' => array('mediaCollection' => 'SoapMediaHelper')
                  ));
                  

                  What we are mapping here is the SOAP element name mediaCollection to one of our classes, SoapMediaHelper. Instead of returning arrays, we can now return a class, in this case, it's named SoapMediaHelper. The class can have soap-element=>value pairs as well as soap-attribute=>value pairs.

                  Assuming we already have made a class that handles mediaCollections, this tells SoapServer to map a class called SoapMediaHelper to it. The class is really simple:

                  class SoapMediaHelper
                  {
                      public function __construct(Array $properties = array())
                      {
                          foreach ($properties as $key => $value) {
                              $this->{$key} = $value;
                          }
                      }
                  }
                  

                  The properties of this class have to be populated. These properties should be both the tagname=>value pairs as well as the attribute name and value pair(s) for the attributes we want to add to our mediaCollection. SoapServer will figure out which is which according to our wsdl file.

                  We will still have to populate this object, which we can do with yet another class.

                  class SoapVarHelper
                  {
                      public function get($the_playlist, $playlist_id, $owned_by_user){
                          /* The SoapMediaHelper class is mapped to the mediaCollection wsdl.
                           * This is only needed to be able to set attributes on the XML nodes while using php's SoapServer
                           * */
                          $media_helper = new SoapMediaHelper($the_playlist);
                          /* For this type, the following xml attributes have to be set. (Not in the wsdl example above.) */
                          if($playlist_id === 'playlists'){
                              $media_helper->readOnly = false;
                              $media_helper->userContent = true;
                              $media_helper->renameable = false;
                              $media_helper->canDeleteItems = true;
                              
                          }
                          if($owned_by_user){
                              $media_helper->readOnly = false;
                              $media_helper->userContent = false;
                              $media_helper->renameable = true;
                              $media_helper->canDeleteItems = true;
                              $media_helper->canReorderItems = true;
                          }
                          return new SoapVar($media_helper, SOAP_ENC_OBJECT);
                      }
                  }
                  

                  This class should be called with the normal tagname=>value pairs. It then adds the attributes we want. In this case conditionally. We feed our SoapMediaHelper object to SoapVar. (We told SoapServer earlier that this is fine.)

                  Now the last thing we need to do is, in our mediaCollection class, to use the helper SoapVarHelper to return a SoapMediaHelper (the one we told SoapServer about earlier).

                  In our mediaCollection we have a function get_metadata_for_root:

                  public function get_metadata_for_root($user_id, $index, $count){
                      $titles = array(
                          'slides' => 'Featured',
                          
                      );
                      $media_metadata = array();
                      foreach($titles as $key => $title){
                          $playlist = array(
                              'id' => $key,
                              'title' => $title,
                              'img' => $this->_utils->get_url() . '/public/sonos/images/browse-icons/icon-default-legacy.png'
                          );
                          **$media_metadata[] = $this->_soap_var_helper->get($playlist, $key, false);**
                      }
                      $res = array(
                          'count' => count($media_metadata),
                          'index' => 0,
                          'total' => count($media_metadata),
                          'mediaCollection' => $media_metadata
                      );
                  }
                  

                  For every mediaCollection result we pass it through the soap_var_helper to make sure not only the element=>value pairs are added, but also the attributes that we want on it.

                  TO SUMMARIZE:

                  1. Make sure you feed the SoapServer with a wsdl file, so it know the elements and the attributes.

                  2. In the SoapServer options add classmap in order to tell SoapServer that it is fine when we feed it a SoapMediaHelper object instead of the regular input.

                  3. Before responding to a request for, in this case, mediaCollection, pass this response through the SoapMediaHelper. The SoapVarHelper will map all the properties=>value pairs as class properties, then the SoapMediaHelper will add attributes (also as name=>value pairs) to it.

                  4. SoapServer will take care of the rest.

                  這篇關于PHP SoapVar 對象屬性?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  enable SOAP on PHP(在 PHP 上啟用 SOAP)
                  Get received XML from PHP SOAP Server(從 PHP SOAP 服務器獲取接收到的 XML)
                  not a valid AllXsd value(不是有效的 AllXsd 值)
                  PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 異常無法連接到主機)
                  Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的實現)
                  Sending a byte array from PHP to WCF(將字節數組從 PHP 發送到 WCF)
                      <tbody id='1LbbY'></tbody>

                      <bdo id='1LbbY'></bdo><ul id='1LbbY'></ul>
                      <i id='1LbbY'><tr id='1LbbY'><dt id='1LbbY'><q id='1LbbY'><span id='1LbbY'><b id='1LbbY'><form id='1LbbY'><ins id='1LbbY'></ins><ul id='1LbbY'></ul><sub id='1LbbY'></sub></form><legend id='1LbbY'></legend><bdo id='1LbbY'><pre id='1LbbY'><center id='1LbbY'></center></pre></bdo></b><th id='1LbbY'></th></span></q></dt></tr></i><div class="j8nutvq" id='1LbbY'><tfoot id='1LbbY'></tfoot><dl id='1LbbY'><fieldset id='1LbbY'></fieldset></dl></div>
                      <tfoot id='1LbbY'></tfoot>

                        <small id='1LbbY'></small><noframes id='1LbbY'>

                        <legend id='1LbbY'><style id='1LbbY'><dir id='1LbbY'><q id='1LbbY'></q></dir></style></legend>
                          1. 主站蜘蛛池模板: 安全,主动,被动,柔性,山体滑坡,sns,钢丝绳,边坡,防护网,护栏网,围栏,栏杆,栅栏,厂家 - 护栏网防护网生产厂家 | 高温热泵烘干机,高温烘干热泵,热水设备机组_正旭热泵 | 临沂招聘网_人才市场_招聘信息_求职招聘找工作请认准【马头商标】 | MVR蒸发器厂家-多效蒸发器-工业废水蒸发器厂家-康景辉集团官网 | 成都亚克力制品,PVC板,双色板雕刻加工,亚克力门牌,亚克力标牌,水晶字雕刻制作-零贰捌广告 | 电梯乘运质量测试仪_电梯安全评估测试仪-武汉懿之刻 | 顺景erp系统_erp软件_erp软件系统_企业erp管理系统-广东顺景软件科技有限公司 | 深圳标识制作公司-标识标牌厂家-深圳广告标识制作-玟璟广告-深圳市玟璟广告有限公司 | 安徽集装箱厂-合肥国彩钢结构板房工程有限公司 | 邢台人才网_邢台招聘网_邢台123招聘【智达人才网】 | 长沙一级消防工程公司_智能化弱电_机电安装_亮化工程专业施工承包_湖南公共安全工程有限公司 | 磁力抛光机_磁力研磨机_磁力去毛刺机-冠古设备厂家|维修|租赁【官网】 | 防水套管厂家_刚性防水套管_柔性防水套管_不锈钢防水套管-郑州中泰管道 | 六维力传感器_六分量力传感器_模腔压力传感器-南京数智微传感科技有限公司 | 北京租车公司_汽车/客车/班车/大巴车租赁_商务会议/展会用车/旅游大巴出租_北京桐顺创业租车公司 | 理化生实验室设备,吊装实验室设备,顶装实验室设备,实验室成套设备厂家,校园功能室设备,智慧书法教室方案 - 东莞市惠森教学设备有限公司 | 等离子表面处理机-等离子表面活化机-真空等离子清洗机-深圳市东信高科自动化设备有限公司 | 桁架楼承板-钢筋桁架楼承板-江苏众力达钢筋楼承板厂 | X光检测仪_食品金属异物检测机_X射线检测设备_微现检测 | 原子吸收设备-国产分光光度计-光谱分光光度计-上海光谱仪器有限公司 | 执业药师报名时间,报考条件,考试时间-首页入口 | 南京欧陆电气股份有限公司-风力发电机官网 | 广州展台特装搭建商|特装展位设计搭建|展会特装搭建|特装展台制作设计|展览特装公司 | 上海防爆真空干燥箱-上海防爆冷库-上海防爆冷柜?-上海浦下防爆设备厂家? | 深圳南财多媒体有限公司介绍| 时代北利离心机,实验室离心机,医用离心机,低速离心机DT5-2,美国SKC采样泵-上海京工实业有限公司 工业电炉,台车式电炉_厂家-淄博申华工业电炉有限公司 | 开云(中国)Kaiyun·官方网站 - 登录入口 | 管形母线,全绝缘铜管母线厂家-山东佰特电气科技有限公司 | 肉嫩度仪-凝胶测试仪-国产质构仪-气味分析仪-上海保圣实业发展有限公司|总部 | 淋巴细胞分离液_口腔医疗器材-精欣华医疗器械(无锡)有限公司 | 气弹簧定制-气动杆-可控气弹簧-不锈钢阻尼器-工业气弹簧-可调节气弹簧厂家-常州巨腾气弹簧供应商 | 搪瓷反应釜厂家,淄博搪瓷反应釜-淄博卓耀 | 北京软件开发_软件开发公司_北京软件公司-北京宜天信达软件开发公司 | 圆周直径尺-小孔内视镜-纤维研磨刷-东莞市高腾达精密工具 | 招商帮-一站式网络营销服务|互联网整合营销|网络推广代运营|信息流推广|招商帮企业招商好帮手|搜索营销推广|短视视频营销推广 | 广西绿桂涂料--承接隔热涂料、隔音涂料、真石漆、多彩仿石漆等涂料工程双包施工 | 中药二氧化硫测定仪,食品二氧化硫测定仪|俊腾百科 | 无线联网门锁|校园联网门锁|学校智能门锁|公租房智能门锁|保障房管理系统-KEENZY中科易安 | 暖气片十大品牌厂家_铜铝复合暖气片厂家_暖气片什么牌子好_欣鑫达散热器 | EDLC超级法拉电容器_LIC锂离子超级电容_超级电容模组_软包单体电容电池_轴向薄膜电力电容器_深圳佳名兴电容有限公司_JMX专注中高端品牌电容生产厂家 | 细石混凝土泵_厂家_价格-烟台九达机械有限公司 |