我要做的是使用SOAP和PHP将从表单捕获的大量值发送到CRM系统。我已经阅读了一段时间的SOAP,我不明白该怎么做,还有其他人知道吗?
答案 0 :(得分:0)
为了做到这一点,从sourceforge下载像'NuSOAP'这样的简单肥皂工具包可能是最容易的。
然后你会编写如下代码(例如提交ISBN号):
<?php
// include the SOAP classes
require_once('nusoap.php');
// define parameter array (ISBN number)
$param = array('isbn'=>'0385503954');
// define path to server application
$serverpath ='http://services.xmethods.net:80/soap/servlet/rpcrouter';
//define method namespace
$namespace="urn:xmethods-BNPriceCheck";
// create client object
$client = new soapclient($serverpath);
// make the call
$price = $client->call('getPrice',$param,$namespace);
// if a fault occurred, output error info
if (isset($fault)) {
print "Error: ". $fault;
}
else if ($price == -1) {
print "The book is not in the database.";
} else {
// otherwise output the result
print "The price of book number ". $param[isbn] ." is $". $price;
}
// kill object
unset($client);
?>
此代码段直接来自,这也是一个很好的资源来查看 http://developer.apple.com/internet/webservices/soapphp.html
希望这有帮助。
答案 1 :(得分:0)
从那时起你可能找到了一个解决方案 - 但也许以下内容可以帮助其他人浏览:
皂server.php:
<?php
class MySoapServer {
public function getMessage ()
{
return "Hello world!";
}
public function add ($n1,$n2)
{
return $n1+n2;
}
}
$option = array ('uri' => 'http://example.org/stacky/soap-server');
$server = new SoapServer(null,$option);
$server->setClass('MySoapServer');
$server->handle();
?>
和soap-client.php
<?php
$options = array ('uri' => 'http://example.org/stacky/soap-server',
'location' => 'http://localhost/soap-server.php');
$client = new SoapClient(null,$options);
echo $client ->getMessage();
echo "<br>";
echo $client ->add(41,1);
?>