0

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
  }

  }
ragu
  • 165
  • 3
  • 6
  • 15
  • Please give more detail to your question. Would you like PHP to make request to a Cache Web Service (that is, PHP is the Client and Cache is the Server)? Or the other way around? Because your question is spanning multiple languages, perhaps it would be good to say which SOAP headers you need to set, and we can help you set those. – Brandon Horst Jan 22 '14 at 13:56
  • @BrandonHorst PHP is the Client and the Cache is the Server. I create Webservices on Cache and set Parameter SOAPSESSION=1. Then only it will return the csp session. Now, Using PHP client, I want to set Request and Get Response using SoapHeader. Wait I will update some Code here for your reference. – ragu Jan 28 '14 at 10:01

1 Answers1

1

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'));
Simon MᶜKenzie
  • 8,344
  • 13
  • 50
  • 77
Pere
  • 11
  • 1