我正在从 php 程序请求 java soap web 服务。我的代码就像跟随
<?php
$options = array('features' =>
SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
try{
$sClient = new SoapClient('http://192.168.1.101:8080/person/Person.wsdl');
// $sClient = new SoapClient('http://192.168.1.11:8080/DNAHMS/webservice/onlineBooking/Hotel.wsdl',$options);
//$params = array('Id'=> '1');
echo "<pre>";
print_r($sClient->__getFunctions());
echo "</pre>";
$parms = array("Id"=>1);
$response = $sClient->__call('getPerson',$parms);
echo "<pre>";
print_r($response);
echo "</pre>";
} catch(SoapFault $e){
echo "<pre>";
var_dump($e);
echo "<pre>";
}
?>
这里我是 Person.wsdl,当我直接调用浏览器时它没有错误,而且这是有效的 xml 文件。当我运行它时,我会得到如下所示的肥皂故障:
cvc-complex-type.4:属性“Id”必须出现在元素“ns1:GetPersonRequest”上