asp.net的程序:Service1.asmx
[WebMethod]
public string HelloWorld(string name)
{
return name + "Hello World";
}php调用的程序:
<?
require_once('./lib/nusoap.php');
//$soapPath="http://202.103.147.184/NetChracterTest/NetTestWebServices/";
$soapPath="http://localhost/webservice1/";
//$soapPath="http://localhost/zxtx/hd/"; $client=new soapclient($soapPath."Service1.asmx?wsdl",true);
//$client=new soapclient('http://localhost/zxtx/hd/test1.php?wsdl',true);
$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
}
$result=$client->call('HelloWorld', 'G2007058012');
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
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>';
}
}
?>
[WebMethod]
public string HelloWorld(string name)
{
return name + "Hello World";
}php调用的程序:
<?
require_once('./lib/nusoap.php');
//$soapPath="http://202.103.147.184/NetChracterTest/NetTestWebServices/";
$soapPath="http://localhost/webservice1/";
//$soapPath="http://localhost/zxtx/hd/"; $client=new soapclient($soapPath."Service1.asmx?wsdl",true);
//$client=new soapclient('http://localhost/zxtx/hd/test1.php?wsdl',true);
$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
}
$result=$client->call('HelloWorld', 'G2007058012');
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
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>';
}
}
?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货