I tried to write a code in php to call a web server to add a client details, however, it's seem not working for me and display the following error:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in D:\www\web_server.php:15 Stack trace: #0 [internal function]: SoapClient-_doRequest('_call('AddClient', Array) #2 D:\www\web_server.php(15): SoapClient-AddClientArray) #3 {main} thrown in D:\www\web_server.php on line 15
Refer below for the code that I wrote in php:
<s:element name="AddClient">
-
<s:complexType>
-
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="username" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="clientRequest" type="tns:ClientRequest"/>
</s:sequence>
</s:complexType>
</s:element>
-
<s:complexType name="ClientRequest">
-
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="customerCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="customerFullName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ref" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="phoneNumber" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Date" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="AddClientResponse">
-
<s:complexType>
-
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="AddClientResult" type="tns:clientResponse"/>
<s:element minOccurs="0" maxOccurs="1" name="response" type="tns:ServiceResponse"/>
</s:sequence>
</s:complexType>
</s:element>
-
<s:complexType name="ClientResponse">
-
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="testNumber" type="s:string"/>
</s:sequence>
</s:complexType>
<?php
$client = new SoapClient($url);
$result = $client->AddClient(array('username' => 'test','password'=>'testing','clientRequest'=>array('customerCode'=>'18743','customerFullName'=>'Gaby Smith','ref'=>'','phoneNumber'=>'0413496525','Date'=>'12/04/2013')));
echo $result->AddClientResponse;
?>
Does anyone where I gone wrong for this code?