I am trying to pass data to an ASP.NET based Web Service using the WSDL file containing the below:
<s:element minOccurs="1" maxOccurs="1" name="ContactId" nillable="true" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="GenderId" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="EthnicityId" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Initials" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Honours" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Surname" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Salutation" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Position" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Department" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Organisation" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="AccessRequirements" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="DietaryNeeds" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="BirthDate" nillable="true" type="s:dateTime"/>
<s:element minOccurs="1" maxOccurs="1" name="IsNewContact" type="s:boolean"/>
<s:element minOccurs="1" maxOccurs="1" name="HoldingId" nillable="true" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="WebId" nillable="true" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="RecruitedId" type="s:int"/>
The data I am passing to the above in PHP is:
'ContactId'=>NULL
'GenderId'=>1
'EthnicityId'=>1
'Title'=>'Mr'
'Initials'=>'JB'
'Honours'=>'Degree'
'FirstName'=>'Joe'
'Surname'=>'Bloggs'
'Salutation'=>'Dear Joe Bloggs'
'Position'=>'Manager'
'Department'=>'Executive'
'Organisation'=>'Organisation'
'AccessRequirements'=>'None'
'DietaryNeeds'=>'None'
'BirthDate'=>NULL
'IsNewContact'=>TRUE
'HoldingId'=>NULL
'WebId'=>NULL
'RecruitedId'=>-1
The error I get back when passing data to the Web Service is:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Server was unable to process request. ---> Object reference not set to an instance of an object.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
This is the code I am using to call the Web Service:
$url='http://domain.com/webservice.asmx?wsdl';
$client = new SoapClient($url,array(
"trace" => 1,
"exceptions" => 1));
$params = array('ContactId'=>$contactid,
'GenderId'=>$gender,
'EthnicityId'=>$ethnicity,
'Title'=>$title,
'Initials'=>$initials,
'Honours'=>$honours,
'FirstName'=>$firstname,
'Surname'=>$surname,
'Salutation'=>$salutation,
'Department'=>$department,
'Organisation'=>$organisation,
'AccessRequirements'=>$accessreq,
'DietaryNeeds'=>$dietary,
'BirthDate'=>$birthdate,
'IsNewContact'=>$isnew,
'HoldingId'=>$holdingid,
'WebId'=>$webid,
'RecruitedId'=>$recruitedid);
try {
$client->PersonalDetails_Update((object)$params);
} catch (SoapFault $e){
var_dump($e, $client->__getLastRequest());
}
print htmlentities($client->__getLastResponse());
I have asked the Web Service provider to allow HoldID to be 'nillable'. I have also tried to isolate the issue to birthDate as I had a hunch that it might be the birthDate value wasn't set correctly, so that's nillable too. Still getting the problem though.
Here is the Fault String that is being outputted when I run the code:
["faultstring"]=>
string(96) "Server was unable to process request. ---> Object reference not set to an instance of an object."
["faultcode"]=>
string(11) "soap:Server"
["detail"]=>
string(0) ""