2010-05-27 9 views
0

내가하려고하는 것은 SOAP 및 PHP가 포함 된 CRM 시스템으로 양식에서 캡처 된 값의로드를 보내는 것입니다. 나는 잠시 동안 SOAP에 대해 읽고 있었고, 그렇게하는 방법을 이해하지 못한다. 다른 사람들도 알고 있는가?PHP로 SOAP 메시지 보내기

답변

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

희망이 도움이됩니다.

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(); 

?> 

및 비누 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); 

?>