2014-01-22 58 views
0

我想用php連接Intersystems緩存web服務。我不知道如何使用肥皂標題進行這項工作。僅使用soap會話,我可以在CSP中設置csp會話。任何人都可以幫助我設置此過程的肥皂標題?或者解釋如何使用最簡單的方式從緩存和php連接Web服務?如何連接Intersystems緩存Web服務和PHP?

在此先感謝!

PHP代碼:

SoapManager.php:

<?php 
    class SoapManager { 

     function execute($webService, $method, $parameters) 
     { 


      $URL = 'http://localhost:57772/csp/user/'.$webService.'.cls?wsdl=1'; 
      echo $URL; 
      //CREATE THE CLIENT INSTANCE 

       $client = new SoapClient($URL); 

      //$client = new SoapClient("http://192.168.101.202:57772/enterprise/drm$soapAddress/GHIS.$serviceName.cls?WSDL"); 

      $result = $client->__soapCall("$method",array($parameters)); 
      return $result; 
     } 
} 


?> 

Client.php:

<?php 

require_once "SoapManager.php"; 

$params = ''; 
$params = array(
'Name' => 'Subash' 
); 

//$getAuthDetail = nusoap("MyApp.MyService","TestName",$params); 
$SoapManager = new SoapManager(); 
$addCommentResult = $SoapManager->execute("MyApp.MyService","TestName",$params);  

$params = ''; 
$params = array(

); 

//$getAuthDetail = nusoap("MyApp.MyService1","Test",$params); 

$addCommentResult = $SoapManager->execute("MyApp.MyService1","Test",$params); 


?> 

MyApp.MyService.cls:

Class MyApp.MyService Extends %SOAP.WebService [ ProcedureBlock ] 
    { 

    /// Name of the WebService. 
    Parameter SERVICENAME = "MyService"; 

    /// TODO: change this to actual SOAP namespace. 
    /// SOAP Namespace for the WebService 
    Parameter NAMESPACE = "http://tempuri.org"; 

    /// Namespaces of referenced classes will be used in the WSDL. 
    Parameter USECLASSNAMESPACES = 1; 

    Parameter SOAPSESSION = 1; 

    //Parameter XMLIGNOREINVALIDATTRIBUTE=1; 

    //Parameter XMLIGNOREINVALIDTAG=1; 

    /// TODO: add arguments and implementation. 
/// Test 
    Method TestName(Name As %String) As %String [ WebMethod ] 
    { 
s ^testg=%session.SessionId 
;h 10 
Quit Name 
    } 

    } 
+0

請對您的問題給予更多的細節你想PHP向緩存Web服務發出請求(即PHP是客戶端,緩存是服務器)?或者相反,因爲你的問題是跨越多種語言,也許最好說出你需要哪個SOAP頭文件設置,我們可以幫助你設置這些。 –

+0

@BrandonHorst PHP是Cli ent並且Cache是​​服務器。我在Cache上創建Webservices並設置參數SOAPSESSION = 1。然後只有它會返回csp會話。現在,使用PHP客戶端,我想使用SoapHeader設置Request和Get Response。等一下,我會在這裏更新一些代碼供您參考。 – ragu

回答

1

第一:生成新的MyApp.MyService.cls使用w伊扎德。請注意嚮導中提供的方法名稱。 (您的例子有兩個diferent名稱(測試,測試名)

二:在PHP代碼中使用此:

//$result = $client->__soapCall("$method",array($parameters)); 

$result = $client->TestName($parameters); 

$result = $client->TestName(array('Name' => 'Subash'));