Reputation: 165
I want to connect Intersystems cache web services with php. I dont know how to use soap headers for this work. Using soap session only, i can set csp session in CSP. Can anyone help me to set soap headers for this process? or else explain how to connect web services from cache and php using simplest way?
Thanks in advance!!
PHP Code:
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
}
}
Upvotes: 0
Views: 1121
Reputation: 11
First: generate a new MyApp.MyService.cls using wizard. Please, take care with the method name provided in the wizard. (Your example have two diferent names (Test , TestName).
Second: use this in php code:
//$result = $client->__soapCall("$method",array($parameters));
$result = $client->TestName($parameters);
or
$result = $client->TestName(array('Name' => 'Subash'));
Upvotes: 1