public function testSoapAction() { ini_set("soap.wsdl_cache_enabled", "0"); $objSoapClient = new \SoapClient("http://127.0.0.1/rulestest/rulestest/web/app_dev.php/ws/GamificationAPI?wsdl", ['trace' => true, 'cache_wsdl' => WSDL_CACHE_NONE, 'soap_version' => SOAP_1_1, 'exceptions' => true, 'user_agent' => 'PHPSoapClient']); $objSoapClient = new \SoapClient("http://localhost/rulestest/rulestest/web/app_dev.php/ws/GamificationAPI?wsdl"); try { $result = $objSoapClient->test(1); } catch (\Exception $ex) { die("exception"); } return new Response($result); }
<?php class AuthHeader { public $username; public $password; } // ----- $options = array('location' => 'http://localhost/test/web-service/server/auth/SoapServer.php', 'uri' => 'http://localhost', 'exceptions' => true); $Client = new SoapClient(null, $options); // ----- $AuthHeader = new AuthHeader(); $AuthHeader->username = '******'; $AuthHeader->password = '******'; $Headers[] = new SoapHeader('http://localhost', 'AuthHeader', $AuthHeader); $Client->__setSoapHeaders($Headers); // ----- //$Result = $Client->sum(1,2); try { echo $Client->test(); //$Result = $Client->sum(1,2); //echo $Result; } catch (Exception $e) { echo 'error'; }
public $var1; } class CT_A2 extends CT_A1 { public $var2; } class CT_A3 extends CT_A2 { public $var3; } // returns A2 in WSDL function test($a1) { $a3 = new CT_A3(); $a3->var1 = $a1->var1; $a3->var2 = "var two"; $a3->var3 = "var three"; return $a3; } $classMap = array("A1" => "CT_A1", "A2" => "CT_A2", "A3" => "CT_A3"); $client = new SoapClient(dirname(__FILE__) . "/bug36575.wsdl", array("trace" => 1, "exceptions" => 0, "classmap" => $classMap)); $a2 = new CT_A2(); $a2->var1 = "one"; $a2->var2 = "two"; $client->test($a2); $soapRequest = $client->__getLastRequest(); echo $soapRequest; $server = new SoapServer(dirname(__FILE__) . "/bug36575.wsdl", array("classmap" => $classMap)); $server->addFunction("test"); $server->handle($soapRequest); echo "ok\n";
/** * @test */ public function cookie() { $obj = new CurlSoapClient(null, array('location' => 'http://localhost:8000/tests/server.php', 'uri' => 'http://test-uri/', 'trace' => true)); $original_obj = new \SoapClient(null, array('location' => 'http://localhost:8000/tests/server.php', 'uri' => 'http://test-uri/', 'trace' => true)); $this->assertEquals(array(), $obj->__getCookies()); $this->assertEquals(array(), $original_obj->__getCookies()); $obj->__setCookie('CookieTest', 'HelloWorld'); $obj->__setCookie('CookieTest2', 'HelloWorld2'); $original_obj->__setCookie('CookieTest', 'HelloWorld'); $original_obj->__setCookie('CookieTest2', 'HelloWorld2'); $this->assertEquals(array('CookieTest' => array('HelloWorld'), 'CookieTest2' => array('HelloWorld2')), $obj->__getCookies()); $this->assertEquals(array('CookieTest' => array('HelloWorld'), 'CookieTest2' => array('HelloWorld2')), $original_obj->__getCookies()); $this->assertEquals(array(1, 'a', false), $obj->test(array(1, 'a', false))); $this->assertEquals(array(1, 'a', false), $original_obj->test(array(1, 'a', false))); // difference of CurlSoapClient from SoapClient [";" -> "; "] $this->assertTrue(stripos($obj->__getLastRequestHeaders(), 'Cookie: CookieTest=HelloWorld; CookieTest2=HelloWorld2') !== false); $this->assertTrue(stripos($original_obj->__getLastRequestHeaders(), 'Cookie: CookieTest=HelloWorld;CookieTest2=HelloWorld2') !== false); }
<?php $client = new SoapClient(NULL, array("location" => "test://", "uri" => "test://", "exceptions" => 0, "trace" => 1)); $client->test(); echo $client->__getLastRequest(); $client->__setSoapHeaders(new SoapHeader("test://", "HDR1")); $client->test(); echo $client->__getLastRequest(); $client->test(); echo $client->__getLastRequest(); $client->__setSoapHeaders(); $client->test(); echo $client->__getLastRequest(); $client->__setSoapHeaders(array(new SoapHeader("test://", "HDR1"), new SoapHeader("test://", "HDR2"))); $client->test(); echo $client->__getLastRequest(); $h = array(new SoapHeader("test://", "HDR0")); $client->__soapCall("test", array(), null, $h); echo $client->__getLastRequest();
<?php class foo { public $a = "a"; private $b = "b"; protected $c = "c"; } $x = new SoapClient(NULL, array("location" => "test://", "uri" => "test://", "exceptions" => 0, "trace" => 1)); $x->test(new foo()); echo $x->__getLastRequest(); echo "ok\n";
<?php ini_set("soap.wsdl_cache_enabled", 0); $client = new SoapClient(null, array('location' => 'http://localhost/ifa/soap/', 'uri' => 'service.php', 'version' => SOAP_1_2)); var_dump($client->test());