Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object hasn't 'source' property in

user1932809 picture user1932809 · May 13, 2013 · Viewed 7.8k times · Source

I am trying to connect osticket support system with opencart. I tried to integrate with this SOAP

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

$osticket = new SoapClient('http://www.website.com/osticket/api/soap/index.php?wsdl');

// Set up the parameters
$args = array(
    'username'      => 'WebService',
    'password'      => 'MySecr3tp@ssword',
    'origin'        => 'Web',
    'alertUser'     => true,
    'alertStaff'    => true,
    'ticketData'    => array(
        'name'      => utf8_encode('sir Test'),
        'email'     => utf8_encode('[email protected]'),
        'subject'   => utf8_encode('testing'),
        'message'   => utf8_encode('this is a message'),
        'topicId'   => 3, //topic Website Support
        'deptId'    => 2, //department Sales
        'staffId'   => null,
        'duedate'   => null,
        'time'      => null,
        'pri'       => 2, // default priority
        'phone'     => null,
    )
);

try {
    // Send the request and receive the ticketID
    $result = $osticket->__call('ostTicket.open',$args);
}
catch (SoapFault $e) {
    throw $e;
}
?>

The error I get is

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object hasn't 'source' property in /home/website/website.com/catalog/view/theme/testtheme/template/information/contact.tpl:60 
Stack trace: 
#0 /home/website/website.com/catalog/view/theme/testtheme/template/information/contact.tpl(60): SoapClient->__call('ostTicket.open', Array) 
#1 /home/website/website.com/vqmod/vqcache/vq2-system_engine_controller.php(67): require('/home/website/tu...') 
#2 /home/website/website.com/catalog/controller/information/contact.php(127): Controller->render() 
#3 /home/website/website.com/vqmod/vqcache/vq2-system_engine_front.php(43): ControllerInformationContact->index() 
#4 /home/website/website.com/vqmod/vqcache/vq2-system_engine_front.php(29): Front->execute(Array, Array) 
#5 /home/website/website.com/index.php(238): Front->dispatch(Object(Action)) 
#6 {main} thrown in/home/website/website.com/catalog/view/theme/testtheme/template/information/contact.tpl on line 60 

Here is the line 60 (/template/information/contact.tpl):

$result = $osticket->__call('ostTicket.open',$args);

I'd be grateful if anyone kindly help me in this issue.

SOAP Info

This is from phpinfo

Soap Client enabled
Soap Server enabled

Directive   Local Value Master Value
soap.wsdl_cache 1   1
soap.wsdl_cache_dir /tmp    /tmp
soap.wsdl_cache_enabled 1   1
soap.wsdl_cache_limit   5   5
soap.wsdl_cache_ttl 86400   86400

Answer

ctrvanessa picture ctrvanessa · Aug 27, 2013

I'm also having same problem, and I've been searching the web and found no answer. So, I traced it myself. And I loved to share how I fixed it.

As you can see on the http://www.website.com/osticket/api/soap/index.php?wsdl (change it to your URL)

under the ( xsd:complexType name="TicketData" ),which parameters needed for ostTicket.open

you can see that there's an element (xsd:element name="source" type="xsd:string") named source, so that's what is missing on the ticketData array. Just add that inside your ticketData array, can be assigned w/ null.

ex. 'source' => null,

This solved my problem. Hope it helps.