我有 3 个客户端站点,它们都依赖于外部 Web 服务。Web 服务曾经位于 ColdFusion 服务器上,但它刚刚转换为 .NET 服务器。我的客户端代码不再工作,我没有任何运气来修复它。客户端站点在 php 上并使用 nusoap 调用 web 服务。
我设置了这个测试,像以前一样使用 wsdl:
<?php
// Call the nuSOAP library
require_once('/home/realtywest/www/lib/nusoap.php');
// Create the client instance
$client = new soapclientnusoap('http://webservices.reiwa.com/RMHPServices/ListingsService.svc?wsdl', true);
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('getListingDetail', array('ListingNumber' => 3000975));
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>
该脚本的结果可以在这里看到:http ://www.realtywest.com.au/listings/test_wsdl.php
这会返回一个内部服务错误..
我用谷歌搜索了我的问题,发现了这个非常古老的论坛帖子:http ://www.sitepoint.com/forums/showthread.php?t= 97632 他们建议有时.NET web 服务的设置不同,而不是将其传递给nusoap 作为 wsdl,在调用时也可以实际传递请求,而不仅仅是变量数组。
所以我尝试了这种方式:
<?php
// Call the nuSOAP library
require_once('/home/realtywest/www/lib/nusoap.php');
// Create the client instance
$client = new soapclientnusoap('http://webservices.reiwa.com/RMHPServices/ListingsService.svc', false);
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('getListingDetail', '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:getListingDetail>
<!--Optional:-->
<tem:strListingNumber>3000975</tem:strListingNumber>
</tem:getListingDetail>
</soapenv:Body>
</soapenv:Envelope>');
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>
请参见此处: http ://www.realtywest.com.au/listings/test.php 这次得到一个 Action Not supported 错误。在第二条消息中发送的请求是从 SOAP UI 复制的,我实际上可以在其中得到结果,所以我知道网络服务确实有效..
我相信有人可以查看调试消息并知道问题所在..我非常感谢您对此提供的任何帮助..