---
title: "PHP Client"
canonical: "https://docs.dk.is/space/DEV/10355997/PHP%20Client"
format: markdown
---
There are many ways to connect using PHP, but the most common way is to use SoapClient, many online resources are available!  
You can use [http://www.stccorp.net/ewsdl2php/](http://www.stccorp.net/ewsdl2php/) to generate a class library from the WSDL or use a simpler approach as shown in the following code example.


> ❌ **PHP Developers**
> ❌ 
> ❌ Sample is not created by a PHP Professional, but should give developer a good starting point.

### Example using SoapClient

You can define associative array to <span style="color: #222222">represent </span>the classes in the WSDL


##### **Store WSDL**

```powershell
PS H:\> (Invoke-WebRequest -Uri "http://webservice.dkvistun.is/demoDev/dkWSItemsCGI.exe/wsdl/IItemService").Content | Se
t-Content C:\temp\wsdl.txt
```



```php
<!DOCTYPE html>
<html> 
<body>
<h1>DK Superthin client software!</h1>     
<h2>Hello php</h2> 
<?php
error_reporting(E_ALL);     
 echo "Before";         
$client = new SoapClient('C:\temp\wsdl.txt' ,array("soap_version" => SOAP_1_2, "trace" => 1, "cache_wsdl" => WSDL_CACHE_NONE));     
$BS = array(
				"Username"=>"userX", 
				"Password"=>"passwordY",	
			);
$member = array(
				  "Name"=>"",
				  "SSNumber"=>"", 
				);
$Header = new SoapHeader("urn:dkWSValueObjects","BasicSecurity", $BS, false);            
$client->__setSoapHeaders($Header);      

try{	

     $comp = $client->GetCompany();     
	 
	 $member = $client->getMember("SOMEID",null); 	 	 
	 //echo $client->__getLastRequest();   
	 echo $member->Name;
	 echo $member->SSNumber; 	 				 			 
   }
	catch (SoapFault $exception) {
	echo $exception;      
}			  

echo "After";
?>           
</body>
</html>  
```




Related articles



> Macro (contentbylabel)


> Macro (details)
> 
> | **Related issues** |  |
> | --- | --- |