2017-03-28 78 views
0

我對SOAP和PHP相當陌生,而且我遇到了一些麻煩,希望Stack Overflow中的某個人能夠幫助我。將xml發佈到SOAP服務

我想用這段代碼發佈一個xml文件(retursvar.xml)。

我使用這個代碼後的文件:

<?php 
$url = "https://someserver/somefunction"; 

$options = array(
       'login' => 'someusername', 
       'password' => 'somepassword', 
       'trace' => 1 
); 

$client = new SoapClient($url.'?wsdl', $options); 

$document = file_get_contents('retursvar.xml'); 

$params = array('SubmitDocument' => $document); 
$response = $client->__soapCall('submitDocument', $params); 

,但我得到這個錯誤在Apache的錯誤日誌:

PHP Fatal error: Uncaught SoapFault exception: [bpws:forcedTermination] business exception in /var/www/html/soaptest.php:15\nStack trace:\n#0 /var/www/html/soaptest.php(15): SoapClient->__soapCall('submitDocument', Array)\n#1 {main}\n thrown in /var/www/html/soaptest.php on line 15 

如果我叫:

var_dump($client->__getFunctions()); 

之後:

$client = new SoapClient($url.'?wsdl', $options); 

我得到這樣的輸出:

array(1) { [0]=> string(62) "SubmitDocumentResponse submitDocument(SubmitDocument $payload)" } 

我在做什麼錯?

回答

0

它說你沒有發現異常。嘗試在try catch塊內包裝你的代碼。

+0

如果我抓到了SoapFault,我在瀏覽器中得到了這個:'<?xml version =「1.0」encoding =「UTF-8」?> 在' –