views:

37

answers:

0

I've been trying to use code below to test web service but it didn't seem to work. I keep getting exception saying

SoapFault exception: [soap:Client] System.Web.Services.Protocols.SoapHeaderException: eWAYCustomerID, Username and Password are required in soap header at ...

As I am very new to soap I'm guessing its something simple I am missing so thanks in advance for any help. The php code is:

class SOAPStruct {
    function SOAPStruct($s, $i, $f) 
    {
        $this->UserName = $s;
        $this->Password = $i;
        $this->eWAYCustomerID = $f;
    }
}

$struct = new SOAPStruct('[email protected]', "test", "87654321");

$client = new SoapClient("https://www.eway.com.au/gateway/services/TransactionReportService.asmx?wsdl"); 

$authvalues = new SoapVar($struct, SOAP_ENC_OBJECT,'SOAPStruct',"http://www.eway.com.au/gateway/services/Transaction24HourReport");

$header =  new SoapHeader("http://www.eway.com.au/gateway/services/Transaction24HourReport","eWAYHeader", $authvalues, true);

echo $client->Transaction24HourReportByInvoiceReference('1234567');

As per this pdf the structure I send should be

<soap:Header> 
<eWAYHeader 
xmlns="http://www.eway.com.au/gateway/services/Transaction24HourReport"&gt; 
 <eWAYCustomerID>87654321</eWAYCustomerID> 
 <Username>[email protected]</Username> 
 <Password>test</Password> 
</eWAYHeader> 
</soap:Header> 
<soap:Body> 
<Transaction24HourReportByInvoiceReference 
xmlns="http://www.eway.com.au/gateway/services/Transaction24HourReport"&gt; 
 <ewayCustomerInvoiceRef>1234567</ ewayCustomerInvoiceRef > 
</ Transaction24HourReportByInvoiceReference > 
</soap:Body>