久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  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="qwawimqqmiuu" id='ipEDr'><tfoot id='ipEDr'></tfoot><dl id='ipEDr'><fieldset id='ipEDr'></fieldset></dl></div>
    1. 無法在 Yii2 中將肥皂響應字符串轉換為 xml

      Unable to convert soap response string to xml in Yii2(無法在 Yii2 中將肥皂響應字符串轉換為 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="qwawimqqmiuu" id='lCYa4'><tfoot id='lCYa4'></tfoot><dl id='lCYa4'><fieldset id='lCYa4'></fieldset></dl></div>
            • <bdo id='lCYa4'></bdo><ul id='lCYa4'></ul>

              • 本文介紹了無法在 Yii2 中將肥皂響應字符串轉換為 xml的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我有一個肥皂請求.我能夠發送請求并獲得字符串響應.現在我想將其轉換為 XML 并從中獲取所需的數據.

                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.

                回復

                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) { }
                

                輸出為空.現在我想要兩件事

                The output is empty. Now I want two things

                1. 將字符串轉換為 XML
                2. 從返回的 XML 我想從響應中獲取 true 的值

                更新 1

                根據建議,我添加了以下代碼

                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();
                

                它給了我一個空的結果

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

                它給了我一個錯誤

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

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

                仍然無法獲取true

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

                我怎樣才能實現它?任何幫助將不勝感激.

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

                推薦答案

                DOMDocument 提取它應該沒有問題,作為一個快速的單行:

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

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

                ...或者如果您想在每一步都仔細檢查錯誤,

                ... 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;
                

                這篇關于無法在 Yii2 中將肥皂響應字符串轉換為 xml的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                <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="qwawimqqmiuu" id='tRnU0'><tfoot id='tRnU0'></tfoot><dl id='tRnU0'><fieldset id='tRnU0'></fieldset></dl></div>
                        • <small id='tRnU0'></small><noframes id='tRnU0'>

                          主站蜘蛛池模板: 91免费观看 | 欧美一级艳情片免费观看 | 久久久久亚洲精品 | 欧美日韩中文在线 | 日韩欧美在线观看 | 香蕉一区 | 亚洲精品一区二区 | 日韩三级电影在线看 | 亚洲午夜精品视频 | 免费日韩网站 | 男女污网站 | 亚洲三区在线 | 综合精品 | 黄a在线观看 | 午夜视频免费在线观看 | 九九激情视频 | 亚洲精品乱码久久久久久黑人 | 精品欧美激情精品一区 | 国产综合在线视频 | 欧美久久久久 | 国产精品久久午夜夜伦鲁鲁 | 日韩欧美三级在线 | 日产精品久久久一区二区福利 | 国产精品嫩草影院精东 | 日本久久精品视频 | av在线免费播放 | av男人天堂影院 | 亚洲一级二级三级 | 婷婷综合 | 精品国产91乱码一区二区三区 | 99re视频在线 | 欧美性生交大片免费 | 国产精品成人一区二区三区吃奶 | 成人黄色三级毛片 | 亚洲成人福利 | 欧美一级在线 | 日韩av免费在线观看 | 国产成人综合一区二区三区 | 青春草在线 | 我要看免费一级毛片 | 久久久免费观看视频 |