在 utf-8 php 頁面上,我無法讀取肥皂響應的輸出。這是我的代碼:<?php header('Content-Type:text/html; charset=UTF-8');ini_set('display_errors','1');error_reporting(E_ALL);class loginInfo{ public $loginOperation= array( "loginId" => 'username', "password" => 'password', "thirdPartyId" => 'appname', "apiVersion" => '2' );}$client = new SoapClient("http:/example.com:9280/wsdl/test.wsdl", array('exceptions' => 0, 'trace' => 1,'encoding'=>'UTF-8'));echo("<pre>");$loginInfo = new loginInfo();$response = $client->Login($loginInfo);$data = $response->loginResult->loginSuccessData;$primaryToken = $data->token->primary;$secondaryToken = $data->token->secondary;$expiration = $data->expiration;var_dump($data); // token strings unreadable in this dumpecho $primaryToken."\n"; //this line is garbledecho htmlentities($primaryToken)."\n"; //This line returns blankecho "RESPONSE:\n" . htmlentities($client->__getLastResponse()). "\n";?>這是來自頁面的響應文本。object(stdClass)#5 (2) { ["token"]=> object(stdClass)#6 (2) { ["primary"]=> string(32) "??h?????8??9????P??k0$*???" ["secondary"]=> string(32) "p-???z??5Y????Z?6?:?" } ["expiration"]=> string(24) "2020-01-04T08:37:06.835Z"}??h?????8??9????P??k0$*???RESPONSE:<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/><soapenv:Body><tfm:loginResponse xmlns:tfm="http://www.example.com/test.xsd"><tfm:loginResult><tfm:loginSuccessData><tfm:token><tcor:primary xmlns:tcor="http://www.example.com/exampleTypes.xsd">yKz/aKuGvZPFOK8e7A8508LT51DTh6JrMAEkAiqbkr4=</tcor:primary><tcor:secondary xmlns:tcor="http://www.example.com/exampleTypes.xsd">cMKtkAzwBZl6FsLkkzUHFwZZhx3U5xb7WhDjnTaZOqc=</tcor:secondary></tfm:token><tfm:expiration>2020-01-04T08:37:06.835Z</tfm:expiration></tfm:loginSuccessData></tfm:loginResult></tfm:loginResponse></soapenv:Body></soapenv:Envelope>在 html 實體中包裝 token 變量會在回顯時將其從頁面中完全刪除。不完全確定這是否與編碼有關,因為據我所知,一切都應該在 utf-8 中。
1 回答

滄海一幻覺
TA貢獻1824條經驗 獲得超5個贊
標記看起來像 base64 編碼的二進制數據。SOAP 客戶端識別(WSDL)并自動對其進行解碼。如果您想以 HTML/Text 輸出它(用于調試),請嘗試以相同的方式對其進行編碼:
echo base64_encode($primaryToken)."\n";
- 1 回答
- 0 關注
- 118 瀏覽
添加回答
舉報
0/150
提交
取消