0
我試圖通過Soap與WS連接,並在調用方法時遇到內容類型錯誤:content type'text/xml; charset = utf-8'不是預期的類型'application/soap + xml; charset = utf-8'PHP SOAP調用內容類型
下面是我的代碼,減少了參數和隱藏url的數量,用戶名和密碼。
當我調用ClientRegist()函數時發生錯誤。我確信我必須以不同的方式傳遞$ params,但無法在任何地方找到示例。
$url = 'http://---';
$ctx_opts = array(
'http' => array(
'header' => 'Content-Type: application/soap+xml'
),
'username' => '---',
'password' => '---',
'trace' => true,
'exceptions' => true
);
$ctx = stream_context_create($ctx_opts);
$client = new SoapClient($url, array('stream_context' => $ctx));
$params = array(
'Cardnumber' => $number,
'Name' => $name
);
try {
$client = new SoapClient($url, array('trace' => $trace, 'exceptions' => $exceptions));
$response = $client->ClientRegist($params);
}
catch (Exception $e) {
echo "Error!<br>";
echo $e -> getMessage().'<br>';
echo 'Last response: '. $client->__getLastResponse();
}
var_dump($response);