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

  1. <legend id='ipEDr'><style id='ipEDr'><dir id='ipEDr'><q id='ipEDr'></q></dir></style></legend>
    <tfoot id='ipEDr'></tfoot>
    • <bdo id='ipEDr'></bdo><ul id='ipEDr'></ul>

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

      <i id='ipEDr'><tr id='ipEDr'><dt id='ipEDr'><q id='ipEDr'><span id='ipEDr'><b id='ipEDr'><form id='ipEDr'><ins id='ipEDr'></ins><ul id='ipEDr'></ul><sub id='ipEDr'></sub></form><legend id='ipEDr'></legend><bdo id='ipEDr'><pre id='ipEDr'><center id='ipEDr'></center></pre></bdo></b><th id='ipEDr'></th></span></q></dt></tr></i><div class="jj9tr9v" id='ipEDr'><tfoot id='ipEDr'></tfoot><dl id='ipEDr'><fieldset id='ipEDr'></fieldset></dl></div>
    1. 無(wú)法在 Yii2 中將肥皂響應(yīng)字符串轉(zhuǎn)換為 xml

      Unable to convert soap response string to xml in Yii2(無(wú)法在 Yii2 中將肥皂響應(yīng)字符串轉(zhuǎn)換為 xml)

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

          <legend id='lCYa4'><style id='lCYa4'><dir id='lCYa4'><q id='lCYa4'></q></dir></style></legend>
              <tbody id='lCYa4'></tbody>

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

              • 本文介紹了無(wú)法在 Yii2 中將肥皂響應(yīng)字符串轉(zhuǎn)換為 xml的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                限時(shí)送ChatGPT賬號(hào)..

                我有一個(gè)肥皂請(qǐng)求.我能夠發(fā)送請(qǐng)求并獲得字符串響應(yīng).現(xiàn)在我想將其轉(zhuǎn)換為 XML 并從中獲取所需的數(shù)據(jù).

                I have a soap request. I am able to send the request and get a response in a string. Now I want to convert it into XML and get the required data from it.

                回復(fù)

                string(1383) "
                <?xml version="1.0" encoding="UTF-8"?>
                <ResponseMessage xmlns:ns="http://iec.ch/TC57/2011/schema/message" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://iec.ch/TC57/2011/schema/message Message.xsd">
                <Header>
                    <Verb>reply</Verb>
                    <Noun>EndDeviceControls</Noun>
                    <Revision>2.0</Revision>
                    <Timestamp>2019-05-04T10:39:11+04:30</Timestamp>
                    <Source>HES-BSTC</Source>
                    <AsyncReplyFlag>true</AsyncReplyFlag>
                    <ReplyAddress>http://ip:port/AmiWeb/services/Metering</ReplyAddress>
                    <User>
                        <UserID>user</UserID>
                    </User>
                    <MessageID>6C3F761B-A1EC-4EBE-BB49-67B720C5AE62</MessageID>
                    <CorrelationID>1001</CorrelationID>
                    <Property>
                        <Name>password</Name>
                        <Value>password</Value>
                    </Property>
                    <Property>
                        <Name>timeout(m)</Name>
                        <Value>30</Value>
                    </Property>
                </Header>
                <Reply>
                    <Result>OK</Result>
                    <Error>
                        <code>0.3</code>
                    </Error>
                </Reply>
                </ResponseMessage>"
                

                代碼

                $xml_post_string = /** @lang text */
                                           '<soapenv:Envelope 
                xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                xmlns:soap="http://soap.inf.hexing.cn">
                <soapenv:Header/>
                <soapenv:Body>
                  <soap:doCommand>
                     <!--Optional:-->
                     <arg0><![CDATA[<?xml version="1.0" encoding="utf-8"?>
                <RequestMessage
                xmlns="http://iec.ch/TC57/2011/schema/message"
                xmlns:m="http://iec.ch/TC57/2011/EndDeviceControls#"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://iec.ch/TC57/2011/schema/message Message.xsd">
                <Header>
                <Verb>create</Verb>
                <Noun>EndDeviceControls</Noun>
                <Revision>2.0</Revision>
                <Timestamp>2016-01-01T00:00:00+04:30</Timestamp>
                <Source>MDM</Source>
                <AsyncReplyFlag>true</AsyncReplyFlag>
                <ReplyAddress>http://ip:port/AmiWeb/services/Metering</ReplyAddress>
                <AckRequired>true</AckRequired>
                <User>
                <UserID>'.$userName.'</UserID>
                </User>
                <MessageID>83c643e6-85c5-43c0-9e0a-fa1deb469b72</MessageID>
                <CorrelationID>1001</CorrelationID>
                <Property>
                <Name>password</Name>
                <Value>'.$password.'</Value>
                </Property>
                <Property>
                <Name>timeout(m)</Name>
                <Value>30</Value>
                </Property>
                </Header>
                <Payload>
                <m:EndDeviceControls>
                <m:EndDeviceControl>
                <m:reason>Disconnect/Reconnect</m:reason>
                <m:EndDeviceControlType ref="3.0.211.23"/>
                <m:EndDevices>
                <m:mRID>'.$msn.'</m:mRID>
                <m:Names>
                <m:name>Disconnect</m:name>
                <m:NameType>
                <m:name>ControlType</m:name>
                </m:NameType>
                </m:Names>
                </m:EndDevices>
                </m:EndDeviceControl>
                </m:EndDeviceControls>
                </Payload>
                </RequestMessage>
                     ]]></arg0>
                  </soap:doCommand>
                 </soapenv:Body>
                </soapenv:Envelope>';
                 $headers = array(
                                           "Content-type: text/xml;charset="utf-8"",
                                           "Accept: text/xml",
                                           "Cache-Control: no-cache",
                                           "Pragma: no-cache",
                                           //"SOAPAction: http://connecting.website.com/WSDL_Service/GetPrice",
                                           "Content-length: ".strlen($xml_post_string),
                                       ); //SOAPAction: your op URL
                
                                       $url = $soapUrl;
                
                                       // PHP cURL  for https connection
                
                                       $ch = curl_init();
                                       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
                                       curl_setopt($ch, CURLOPT_URL, $url);
                                       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                                       curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
                                       curl_setopt($ch, CURLOPT_TIMEOUT, 10);
                                       curl_setopt($ch, CURLOPT_POST, true);
                                       curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
                                       curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                
                                       // converting
                                       $response = curl_exec($ch);
                                       curl_close($ch);
                                       $xml = simplexml_load_string($response);
                                       var_dump($xml);
                                       die();
                

                輸出

                object(SimpleXMLElement)#121 (0) { }
                

                輸出為空.現(xiàn)在我想要兩件事

                The output is empty. Now I want two things

                1. 將字符串轉(zhuǎn)換為 XML
                2. 從返回的 XML 我想從響應(yīng)中獲取 true 的值

                更新 1

                根據(jù)建議,我添加了以下代碼

                As per suggestion, I have added below code

                $xml = simplexml_load_string($response);
                                        echo $xml->asXML();
                

                輸出

                <?xml version="1.0" encoding="UTF-8"?>
                <ResponseMessage xmlns:ns="http://iec.ch/TC57/2011/schema/message" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://iec.ch/TC57/2011/schema/message Message.xsd">
                <Header>
                    <Verb>reply</Verb>
                    <Noun>EndDeviceControls</Noun>
                    <Revision>2.0</Revision>
                    <Timestamp>2019-05-04T14:01:48+04:30</Timestamp>
                    <Source>HES-BSTC</Source>
                    <AsyncReplyFlag>true</AsyncReplyFlag>
                    <ReplyAddress>http://ip:port/AmiWeb/services/Metering</ReplyAddress>
                    <User>
                        <UserID>user</UserID>
                    </User>
                    <MessageID>F4E15012-D009-4CBC-A610-E937F2620193</MessageID>
                    <CorrelationID>1001</CorrelationID>
                    <Property>
                        <Name>password</Name>
                        <Value>password</Value>
                    </Property>
                    <Property>
                        <Name>timeout(m)</Name>
                        <Value>30</Value>
                    </Property>
                </Header>
                <Reply>
                    <Result>OK</Result>
                    <Error>
                        <code>0.3</code>
                    </Error>
                </Reply>
                </ResponseMessage>
                

                我嘗試了什么?

                $xml = new SimpleXMLElement($response);
                print_r($xml);
                die();
                

                它給了我一個(gè)空的結(jié)果

                 $doc = new DOMDocument('1.0', 'utf-8');
                                       $doc->loadXML($response);
                                       $XMLresults = $doc->getElementsByTagName("AsyncReplyFlag")->item(0)->textContent;
                                       echo $XMLresults;
                                       die();
                

                它給了我一個(gè)錯(cuò)誤

                試圖獲取非對(duì)象的屬性$XMLresults = $doc->getElementsByTagName("AsyncReplyFlag")->item(0)->textContent;

                Trying to get property of non-object $XMLresults = $doc->getElementsByTagName("AsyncReplyFlag")->item(0)->textContent;

                仍然無(wú)法獲取true

                Still, I am unable to get the value of <AsyncReplyFlag>true</AsyncReplyFlag>

                我怎樣才能實(shí)現(xiàn)它?任何幫助將不勝感激.

                How can I achieve it? Any help would be highly appreciated.

                推薦答案

                DOMDocument 提取它應(yīng)該沒(méi)有問(wèn)題,作為一個(gè)快速的單行:

                DOMDocument should have no problem extracting it, as a quick one-liner:

                echo (@DOMDocument::loadXML($response))->getElementsByTagName("AsyncReplyFlag")->item(0)->textContent;
                

                ...或者如果您想在每一步都仔細(xì)檢查錯(cuò)誤,

                ... or if you want to meticulously check for errors every step of the way,

                $xml_errors=[];
                set_error_handler(function(int $errno, string $errstr, string $errfile, int $errline, array $errcontext) use(&$xml_errors){
                    ob_start();
                    call_user_func_array('var_dump',func_get_args());
                    $xml_errors[]=ob_get_clean();
                });
                $domd=new DOMDocument();
                $loaded=$domd->loadXML($response);
                restore_error_handler();
                if(!$loaded){
                    if(defined('STDERR')){
                        fprintf(STDERR,"%s",$response);
                    }
                    throw new RuntimeException("errors parsing XML! xml printed in stderr, parsing errors: ".print_r($xml_errors,true));    
                }
                $ele=$domd->getElementsByTagName("AsyncReplyFlag");
                if($ele->length<1){
                    if(defined('STDERR')){
                        fprintf(STDERR,"%s",$response);
                    }
                    throw new RuntimeException("did not get AsyncReplyFlag in response! (xml printed in stderr)");
                }
                echo $ele->item(0)->textContent;
                

                這篇關(guān)于無(wú)法在 Yii2 中將肥皂響應(yīng)字符串轉(zhuǎn)換為 xml的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                enable SOAP on PHP(在 PHP 上啟用 SOAP)
                Get received XML from PHP SOAP Server(從 PHP SOAP 服務(wù)器獲取接收到的 XML)
                not a valid AllXsd value(不是有效的 AllXsd 值)
                PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 異常無(wú)法連接到主機(jī))
                Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的實(shí)現(xiàn))
                Sending a byte array from PHP to WCF(將字節(jié)數(shù)組從 PHP 發(fā)送到 WCF)
                <tfoot id='tRnU0'></tfoot>
                  <legend id='tRnU0'><style id='tRnU0'><dir id='tRnU0'><q id='tRnU0'></q></dir></style></legend>

                        <tbody id='tRnU0'></tbody>

                        • <bdo id='tRnU0'></bdo><ul id='tRnU0'></ul>
                          <i id='tRnU0'><tr id='tRnU0'><dt id='tRnU0'><q id='tRnU0'><span id='tRnU0'><b id='tRnU0'><form id='tRnU0'><ins id='tRnU0'></ins><ul id='tRnU0'></ul><sub id='tRnU0'></sub></form><legend id='tRnU0'></legend><bdo id='tRnU0'><pre id='tRnU0'><center id='tRnU0'></center></pre></bdo></b><th id='tRnU0'></th></span></q></dt></tr></i><div class="fbhpbnp" id='tRnU0'><tfoot id='tRnU0'></tfoot><dl id='tRnU0'><fieldset id='tRnU0'></fieldset></dl></div>
                        • <small id='tRnU0'></small><noframes id='tRnU0'>

                          主站蜘蛛池模板: 混合生育酚_醋酸生育酚粉_琥珀酸生育酚-山东新元素生物科技 | 安驭邦官网-双向万能直角铣头,加工中心侧铣头,角度头[厂家直销] 闸阀_截止阀_止回阀「生产厂家」-上海卡比阀门有限公司 | 沈阳建筑设计公司_加固改造设计_厂房设计_设计资质加盟【金辉设计】 | 威海防火彩钢板,威海岩棉复合板,威海彩钢瓦-文登区九龙岩棉复合板厂 | 冲锋衣滑雪服厂家-冲锋衣定制工厂-滑雪服加工厂-广东睿牛户外(S-GERT) | 彩信群发_群发彩信软件_视频短信营销平台-达信通 | 南京办公用品网-办公文具用品批发-打印机耗材采购 | 防爆暖风机_防爆电暖器_防爆电暖风机_防爆电热油汀_南阳市中通智能科技集团有限公司 | 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 冷油器,取样冷却器,热力除氧器-连云港振辉机械设备有限公司 | 合肥网络推广_合肥SEO网站优化-安徽沃龙First | 折弯机-刨槽机-数控折弯机-数控刨槽机-数控折弯机厂家-深圳豐科机械有限公司 | 复盛空压机配件-空气压缩机-复盛空压机(华北)总代理 | 桁架楼承板-钢筋桁架楼承板-江苏众力达钢筋楼承板厂 | 郑州墨香品牌设计公司|品牌全案VI设计公司 | 耐力板-PC阳光板-PC板-PC耐力板 - 嘉兴赢创实业有限公司 | 自恢复保险丝_贴片保险丝_力特保险丝_Littelfuse_可恢复保险丝供应商-秦晋电子 | 东莞精密模具加工,精密连接器模具零件,自動機零件,冶工具加工-益久精密 | 智能电表|预付费ic卡水电表|nb智能无线远传载波电表-福建百悦信息科技有限公司 | 基业箱_环网柜_配电柜厂家_开关柜厂家_开关断路器-东莞基业电气设备有限公司 | 知企服务-企业综合服务(ZiKeys.com)-品优低价、种类齐全、过程管理透明、速度快捷高效、放心服务,知企专家! | 回收二手冲床_金丰旧冲床回收_协易冲床回收 - 大鑫机械设备 | 科普仪器菏泽市教育教学仪器总厂 | 全温度恒温培养摇床-大容量-立式-远红外二氧化碳培养箱|南荣百科 | 泡沫消防车_水罐消防车_湖北江南专用特种汽车有限公司 | CXB船用变压器-JCZ系列制动器-HH101船用铜质开关-上海永上船舶电器厂 | 代办建筑资质升级-建筑资质延期就找上海国信启航 | 清水-铝合金-建筑模板厂家-木模板价格-铝模板生产「五棵松」品牌 | 阀门智能定位器_电液动执行器_气动执行机构-赫尔法流体技术(北京)有限公司 | 【ph计】|在线ph计|工业ph计|ph计厂家|ph计价格|酸度计生产厂家_武汉吉尔德科技有限公司 | 智能风向风速仪,风速告警仪,数字温湿仪,综合气象仪(气象五要素)-上海风云气象仪器有限公司 | IHDW_TOSOKU_NEMICON_EHDW系列电子手轮,HC1系列电子手轮-上海莆林电子设备有限公司 | 诚暄电子公司首页-线路板打样,pcb线路板打样加工制作厂家 | 鹤壁创新仪器公司-全自动量热仪,定硫仪,煤炭测硫仪,灰熔点测定仪,快速自动测氢仪,工业分析仪,煤质化验仪器 | ET3000双钳形接地电阻测试仪_ZSR10A直流_SXJS-IV智能_SX-9000全自动油介质损耗测试仪-上海康登 | 珠海网站建设_响应网站建设_珠海建站公司_珠海网站设计与制作_珠海网讯互联 | 定制异形重型钢格栅板/钢格板_定做踏步板/排水沟盖板_钢格栅板批发厂家-河北圣墨金属制品有限公司 | 二手注塑机回收_旧注塑机回收_二手注塑机买卖 - 大鑫二手注塑机 二手光谱仪维修-德国OBLF光谱仪|进口斯派克光谱仪-热电ARL光谱仪-意大利GNR光谱仪-永晖检测 | 引领中高档酒店加盟_含舍·美素酒店品牌官网 | 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 | 精密光学实验平台-红外粉末压片机模具-天津博君 |