PHP SOAP 返回 SOAP 错误:服务器无法使用 .asmx Web 服务处理请求
我很难让 SOAP 请求正常工作,这需要 XML 字符串作为输入。
它抛出
“SOAP 错误:服务器无法处理请求。 ---> 值不能为空。参数名称:s”
无论我发送什么输入,我都使用了 nusoap 但无济于事, PHP 肥皂库。 我使用的代码是:
<?
$aOptions = array(
'location' => 'http://webserviceurl.asmx',
'uri' => 'http://tempuri.org/',
"style" => SOAP_RPC,
"use" => SOAP_ENCODED
);
$client = new SOAPClient(null, $aOptions);
$request ='<item xmlns="rmsItem">
<columns>
<column>description</column>
<column>department</column>
<column>brand</column>
<column>lastsold</column>
<column>lastupdated</column>
<column>quantityonhand</column>
<column>weight</column>
</columns>
<filters>
<filter>
<filterColumn>quantityonhand</filterColumn>
<operator>greaterthan</operator>
<filterValue>20</filterValue>
</filter>
<filter>
<filterColumn>lastsold</filterColumn>
<operator>greaterthan</operator>
<filterValue>01-01-2005</filterValue>
</filter>
</filters>
<sortColumns>
<sortColumn>
<sortColumnName>lastsold</sortColumnName>
<sortType>ascending</sortType>
</sortColumn>
<sortColumn>
<sortColumnName>quantityonhand</sortColumnName>
<sortType>descending</sortType>
</sortColumn>
</sortColumns>
</item>';
//$result = $client->__soapCall('getAllInfo',array('infoRequestXml'=>(string)($request),'errorMessage'=>'') ,array('soapaction' => 'http://webserviceurl/getAllInfo'));
$soapvar = new SoapVar($request , XSD_ANYXML);
$params = array("infoRequestXml" => $soapvar);
//print_r($params);
//$result = $this->soapclient->__soapCall("SaveItem", array("parameters"=>$params), null, $this->soapheaders);
try
{
$result=$client->__soapCall('getAllInfo',array("parameters"=>$params),array('soapaction' => 'http://webserviceurl/getAllInfo'));
}
catch (SoapFault $e) {
echo "SOAP Fault: ".$e->getMessage()."<br />\n";
}
echo "<pre>\n";
echo htmlspecialchars($client->__getLastRequest())."\n";
echo "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
echo "</pre>";
var_dump($result);
?>
过去两天我一直在用头撞墙,在谷歌上搜索这个问题,但没有得到解决或指导我解决的答案。
任何能够阐明这一点的人都将受到高度赞赏。 提前致谢。
I am having difficulty in getting a SOAP request working properly , which requires XML string as input.
It's throwing
"SOAP Fault: Server was unable to process request. ---> Value cannot be null. Parameter name: s"
no matter what input i send , i have used nusoap but to no avail , PHP soap library.
The code i am using is:
<?
$aOptions = array(
'location' => 'http://webserviceurl.asmx',
'uri' => 'http://tempuri.org/',
"style" => SOAP_RPC,
"use" => SOAP_ENCODED
);
$client = new SOAPClient(null, $aOptions);
$request ='<item xmlns="rmsItem">
<columns>
<column>description</column>
<column>department</column>
<column>brand</column>
<column>lastsold</column>
<column>lastupdated</column>
<column>quantityonhand</column>
<column>weight</column>
</columns>
<filters>
<filter>
<filterColumn>quantityonhand</filterColumn>
<operator>greaterthan</operator>
<filterValue>20</filterValue>
</filter>
<filter>
<filterColumn>lastsold</filterColumn>
<operator>greaterthan</operator>
<filterValue>01-01-2005</filterValue>
</filter>
</filters>
<sortColumns>
<sortColumn>
<sortColumnName>lastsold</sortColumnName>
<sortType>ascending</sortType>
</sortColumn>
<sortColumn>
<sortColumnName>quantityonhand</sortColumnName>
<sortType>descending</sortType>
</sortColumn>
</sortColumns>
</item>';
//$result = $client->__soapCall('getAllInfo',array('infoRequestXml'=>(string)($request),'errorMessage'=>'') ,array('soapaction' => 'http://webserviceurl/getAllInfo'));
$soapvar = new SoapVar($request , XSD_ANYXML);
$params = array("infoRequestXml" => $soapvar);
//print_r($params);
//$result = $this->soapclient->__soapCall("SaveItem", array("parameters"=>$params), null, $this->soapheaders);
try
{
$result=$client->__soapCall('getAllInfo',array("parameters"=>$params),array('soapaction' => 'http://webserviceurl/getAllInfo'));
}
catch (SoapFault $e) {
echo "SOAP Fault: ".$e->getMessage()."<br />\n";
}
echo "<pre>\n";
echo htmlspecialchars($client->__getLastRequest())."\n";
echo "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
echo "</pre>";
var_dump($result);
?>
I am banging my head against a wall from last two days, searched google for this problem but got no answer that solves or guide me through.
Anyone who can throw some light on this will be highly appreciated.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要通过 SOAPVar 运行 XML,并且如果可以的话,请利用 Web 服务的 WSDL 选项:
Don't run the XML through SOAPVar, and take advantage of the WSDL option of your web service if you can: