>  기사  >  백엔드 개발  >  thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

WBOY
WBOY원래의
2016-08-18 09:15:592194검색

thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

응답 메시지 본문
thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

PHP로 보낸 요청 메시지 본문입니다

<code><?php
public function getXml()
    {
        $xmlStr = <<<xml
<?xml version="1.0" encoding="utf-8"?>
<msg v="1.0" id="1470798667">
<ctrl><agentID>800205</agentID><cmd>2000</cmd><timestamp>1470798667</timestamp><md>17468b91d6b9bc1debb052a1f9a66fee</md></ctrl>
<body><loto lotoid="001" issue=""/></body></msg>
xml;
        $url = 'http://175.25.25.41:7070/billservice/sltAPI';
        $header[] = 'Content-type: text/xml; charset=utf-8';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlStr);
        $response = curl_exec($ch);
        if(curl_errno($ch)){
            print curl_error($ch);
        }
        curl_close($ch);
        var_dump($response);
    }</code>

하지만 구문 분석할 수 없으며 문제가 어디에 있는지 알 수 없습니다. 항상 그런 결과가 반환됩니다.

파싱 결과는 그림과 같습니다. (errorcode = 100)은 오류 코드를 나타냅니다

thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

올바른 반환 결과는 이렇습니다. 여기에서는 양식 제출을 통해서만 구문 분석을 완료하는데 이는 정상적인 현상입니다.

thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

로컬로 XML 메시지를 보냈는데 구문 분석할 수 없습니다. 도와주세요!

답글 내용:

thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

응답 메시지 본문
thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

PHP로 보낸 요청 메시지 본문입니다

<code><?php
public function getXml()
    {
        $xmlStr = <<<xml
<?xml version="1.0" encoding="utf-8"?>
<msg v="1.0" id="1470798667">
<ctrl><agentID>800205</agentID><cmd>2000</cmd><timestamp>1470798667</timestamp><md>17468b91d6b9bc1debb052a1f9a66fee</md></ctrl>
<body><loto lotoid="001" issue=""/></body></msg>
xml;
        $url = 'http://175.25.25.41:7070/billservice/sltAPI';
        $header[] = 'Content-type: text/xml; charset=utf-8';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlStr);
        $response = curl_exec($ch);
        if(curl_errno($ch)){
            print curl_error($ch);
        }
        curl_close($ch);
        var_dump($response);
    }</code>

하지만 구문 분석할 수 없으며 문제가 어디에 있는지 알 수 없습니다. 항상 그런 결과가 반환됩니다.

파싱 결과는 그림과 같습니다. (errorcode = 100)은 오류 코드를 나타냅니다

thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

올바른 반환 결과는 이렇습니다. 여기에서는 양식 제출을 통해서만 구문 분석을 완료하는데 이는 정상적인 현상입니다.

thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

thinkphp5 - 긴급 PHP 전송 XML을 구문 분석할 수 없습니다.

로컬로 XML 메시지를 보냈는데 구문 분석할 수 없습니다. 도와주세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.