我的服务器上有一个用PHP编写的Web服务,用于更新Acomba表中的客户。该服务正确更新了客户,但是当我收到响应时网页崩溃,因为xml没有正确关闭。我用ajax调用Webservice。
我没有写过电话或网络服务,但我必须解决它......
记录错误: SoapFault异常:[Client]看起来我们在C:\ inetpub \ wwwroot \ eureka \ ajax \ syncContratAvenant.php中没有XML文档:85
堆栈跟踪: 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();
?>
答案 0 :(得分:0)
您是否尝试过更改:
'encoding' => 'ISO-8859-1'
到:
'encoding'=>'UTF-8'
? 我希望与这些内容长度略有不同,这就是我所看到的问题。
答案 1 :(得分:0)
我遇到了与无效SOAP XML相同的问题,特别是当我们的服务器使用Brotli压缩来压缩XML时,它遗漏了</SOAP-ENV:Envelope
错过了它的结束>
,出于某种原因,Brotli和Soap不在#39; t很好地协同工作。