0

我的服务器上有一个用 php 编写的 Web 服务,用于更新 Acomba 表中的客户。该服务正确更新客户,但是当我收到响应时,网页崩溃,因为 xml 未正确关闭。我用 ajax 调用 Web 服务。

我没有写电话或网络服务,但我必须修复它......

记录的错误:SoapFault 异常:[Client] 看起来我们在 C:\inetpub\wwwroot\eureka\ajax\syncContratAvenant.php:85 中没有 XML 文档

堆栈跟踪:C:\inetpub\wwwroot\eureka\ajax\syncContratAvenant.php(85): SoapClient->__soapCall('saveClientAvena...', Array)

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:SOAP_AvenantAcomba" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:saveClientAvenant><param0 xsi:type="ns2:Map"><item><key xsi:type="xsd:string">noContrat</key><value xsi:type="xsd:string">FP00000000</value></item>
<item><key xsi:type="xsd:string">acombaUidClient</key><value xsi:type="xsd:string">945</value></item><item><key xsi:type="xsd:string">name</key><value xsi:type="xsd:string">Test</value></item><item><key xsi:type="xsd:string">institution</key><value xsi:type="xsd:string">000</value></item><item><key xsi:type="xsd:string">folio</key><value xsi:type="xsd:string">000000</value></item><item><key xsi:type="xsd:string">transit</key><value xsi:type="xsd:string">00000</value></item><item><key xsi:type="xsd:string">zip</key><value xsi:type="xsd:string">XXX XXX</value></item><item><key xsi:type="xsd:string">adress</key><value xsi:type="xsd:string">2 testtown</value></item><item><key xsi:type="xsd:string">phone</key><value xsi:type="xsd:string"></value></item><item><key xsi:type="xsd:string">city</key><value xsi:type="xsd:string">Test</value></item></param0></ns1:saveClientAvenant>
</SOAP-ENV:Body></SOAP-ENV:Envelope>

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:SOAP_AvenantAcomba" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:saveClientAvenantResponse><return xsi:type="ns2:Map"><item><key xsi:type="xsd:string">reponse</key><value xsi:type="xsd:boolean">true</value></item><item><key xsi:type="xsd:string">errorMessage</key><value xsi:type="xsd:string"></value></item></return></ns1:saveClientAvenantResponse>
</SOAP-ENV:Body></SOAP-ENV:Envelop

注意那里的信封没有正确关闭……不知道为什么……

来电:

$client = new SoapClient(null, array('location' => ACOMBA_WEB_SERVICE_Avenant,
                                                 'uri'             => "urn:SOAP_AvenantAcomba",
                                                 'trace'        => 1,
                                                 'encoding'    => 'ISO-8859-1'));

            $info = array($arraySOAP => array(
                    'noContrat' => getNoContratTxt($contract->getCols('noContract')),
                    'acombaUidClient' => $contract->getCols('acombaUidClient'),
                    'name' => $contract->getCols('name') ,
                    'institution' => $contract->getCols('noInstitution'),
                    'folio' => $contract->getCols('noFolio'),
                    'transit' => $contract->getCols('noTransit'),
                    'zip' => makeSQasDQ($contract->getCols('zipAddAssurer')),
                    'adress' => makeSQasDQ(utf8_decode($contract->getCols('noAddAssurer') . ' ' . $contract->getCols('streetAddAssurer'))),
                    'phone' => '',
                    'city' => makeSQasDQ(utf8_decode($contract->getCols('townAddAssurer'))))
            );


        $resultClient = $client->__soapCall('saveClientAvenant', $info); // crash here

服务 :

<?php
require_once('variables.php');

set_time_limit(900);


function saveClientAvenant($arraySOAP){

    $conn = odbc_connect(ACOMBA_DRIVER, ACOMBA_USER, base64_decode(ACOMBA_PASS));

    if (odbc_commit($conn)) {
        try {
            $nxtContrat = $arraySOAP['noContrat'];
            $nom = $arraySOAP['name'];
            $noInstitution = $arraySOAP['institution'];
            $noFolio = $arraySOAP['folio'];
            $noTransit = $arraySOAP['transit'];
            $zipCode = $arraySOAP['zip'];
            $adress = $arraySOAP['adress'];
            $phone = $arraySOAP['phone'];
            $city = $arraySOAP['city'];
            $acombaUidClient = $arraySOAP['acombaUidClient'];

            $sqlQuery = "UPDATE " . TABLE_ACOMBA_CLIENT . "
            SET
            CuSortKey = '$nom',
            CuName = '$nom',
            CuAddress = '$adress',  
            CuCity = '$city',  
            CuPostalCode = '$zipCode',
            CuPhoneNumber1 = '$phone',
            CuInstitutionNumber = '$noInstitution',
            CuBranchNumber = '$noTransit',
            CuAccountNumber = '$noFolio'
            WHERE
            CuUnique = $acombaUidClient
            ";

            if (!odbc_exec($conn, $sqlQuery)) {
                throw new Exception($sqlQuery . odbc_errormsg());
            }
        } catch (Exception $e) {
            return array('reponse' => false,
                'errorMessage' => $e->getMessage() );
        }
        odbc_close($conn);

        return array('reponse' => true,
                'errorMessage' => '' );
    }
}       



$server = new SOAPServer(null, array('uri'         => 'urn:SOAP_AvenantAcomba',
                                         'encoding'    => 'ISO-8859-1'));

$server->addFunction('saveClientAvenant');  
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
$server->handle();

?>
4

2 回答 2

0

您是否尝试过更改:

'encoding'    => 'ISO-8859-1'

至:

'encoding'=>'UTF-8'

? 我希望这些内容长度略有不同,这就是我认为您的问题。

于 2013-10-22T22:13:30.457 回答
0

我遇到了无效 SOAP XML 的相同问题,特别是当我们的服务器一直使用 Brotli 压缩来压缩 XML 时,它丢失</SOAP-ENV:Envelope了关闭,由于某种原因,Brotli 和 Soap 不能很好地协同工作。>

于 2017-07-26T09:37:20.500 回答