I've been hunting for several days for a solution to this but had no luck.
I got my starter code from http://www.codingfriends.com/index.php/2010/04/16/soap-client-calling-net-web-service/ .
Here's the code as adjusted (with a fake key):
<?php
// create a connection to the local host mono .NET pull back the wsdl to get the functions names
// and also the parameters and return values
$client = new SoapClient("https://realServer/events.asmx?WSDL",
array(
"trace" => 1, // enable trace to view what is happening
"exceptions" => 0, // disable exceptions
"cache_wsdl" => 0) // disable any caching on the wsdl, encase you alter the wsdl server
);
// get a response from the WSDL zend server function getQuote for the day monday
print_r( $client->GetSingleEvent(array("APIKey" => "HISY20Y4-8405-91SK-L0S7-9A17252E548A", "EventId" => "2559")));
// display what was sent to the server (the request)
echo "<p>Request :".htmlspecialchars($client->__getLastRequest()) ."</p>";
// display the response from the server
echo "<p>Response:".htmlspecialchars($client->__getLastResponse())."</p>";
?>
Here's what the actual xml request should look like (as tested in Soap UI)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:cer="http://cermsystem.net/">
<soapenv:Header>
<tem:Credentials>
<!--Optional:-->
<tem:APIKey>HISY20Y4-8405-91SK-L0S7-9A17252E548A</tem:APIKey></tem:Credentials>
</soapenv:Header>
<soapenv:Body>
<tem:GetSingleEvent>
<!--Optional:-->
<cer:GetEventByIDRQ>
<!--Optional:-->
<cer:EventId>2559</cer:EventId></cer:GetEventByIDRQ>
</tem:GetSingleEvent>
</soapenv:Body>
</soapenv:Envelope>
This is the current output I am getting from the script after sending to .NET SOAP server:
SoapFault Object ( [message:protected] => Server was unable to process request. ---> Object reference not set to an instance of an object.
[string:Exception:private] => [code:protected] => 0 [file:protected] => /Library/WebServer/Documents/soap6.php [line:protected] => 15 [trace:Exception:private] => Array ( [0] => Array ( [file] => /Library/WebServer/Documents/soap6.php [line] => 15 [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => GetSingleEvent [1] => Array ( [0] => Array ( [APIKey] => 8F0A395B-8405-480B-871C-9A17252E548A ) ) ) ) [1] => Array ( [file] => /Library/WebServer/Documents/soap6.php [line] => 15 [function] => GetSingleEvent [class] => SoapClient [type] => -> [args] => Array ( [0] => Array ( [APIKey] => 8F0A395B-8405-480B-871C-9A17252E548A ) ) ) ) [previous:Exception:private] => [faultstring] => Server was unable to process request. ---> Object reference not set to an instance of an object. [faultcode] => soap:Server [detail] => )
Request :<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:GetSingleEvent/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Response:<?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>
I think the problem is that the .NET server isn't receiving the right inputs for APIKey and EventId, but I've been unable to get that part to work. Does the APIKey need to be sent as part of the header? If so how would I do that in combination with reading the WSDL