Ask not what osTicket community can do for you - ask what you can do for osTicket community

Go Back   osTicket Forums > osTicket 1.6.x > Mods and Customizations

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-17-2012, 01:48 AM
NotionCommotion NotionCommotion is offline
Junior Member
 
Join Date: Jun 2012
Posts: 8
Default Does osTicket SOAP not work with associate arrays?

Hi! First start with the SOAP mod is great. But don't understand why I sometimes get Uncaught SoapFault exception errors. Then, I found that the order of the elements in the $args array has an impact. Didn't expect that! See how the following first call works but not the second. Is it the Mod, or my server? Please provide any thoughts and suggestions. Thank you!

PHP Code:
<?php

require_once('api/soap/lib/classes/nusoap.class.php');

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

$args = array(
    
'username'        => 'username',
    
'password'        => 'password',
    
'ticketData'    => array(
        
'name'      => utf8_encode('sir Test'),
        
'email'     => utf8_encode('some@email.com'),
        
'subject'   => utf8_encode('testing'),
        
'message'   => utf8_encode('this is a message'),
        
'topicId'   => 3//topic Website Support
        
'pri'       => 2// default priority
        
'phone'     => '012-345678'
    
)
);

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

$args = array(
    
'password'        => 'password',
    
'username'        => 'username',
    
'ticketData'    => array(
        
'name'      => utf8_encode('sir Test'),
        
'email'     => utf8_encode('some@email.com'),
        
'subject'   => utf8_encode('testing'),
        
'message'   => utf8_encode('this is a message'),
        
'topicId'   => 3//topic Website Support
        
'pri'       => 2// default priority
        
'phone'     => '012-345678'
    
)
);

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

?>
Reply With Quote
  #2  
Old 06-17-2012, 02:28 AM
teryakisan teryakisan is offline
Member
 
Join Date: Jun 2011
Location: Beaumont, Tx
Posts: 143
Send a message via AIM to teryakisan Send a message via Yahoo to teryakisan Send a message via Skype™ to teryakisan
Arrow

I've dealt with a similar problem in the past. See post #2 in this thread.

http://osticket.com/forums/showthread.php?t=7833

While not a direct answer, the explanation of the code should get you pointed in the right direction.

In essence is says that there must be another array there that yours is dependent upon. You must make sure they are BOTH in the same order.

I have never applied the SOAP mod but I'll bet a nickel that's the problem.
Reply With Quote
  #3  
Old 06-17-2012, 12:10 PM
NotionCommotion NotionCommotion is offline
Junior Member
 
Join Date: Jun 2012
Posts: 8
Default

Hi teryakisan,

Thank you for your reply.

Your example is dealing with paired arrays and appears to be different.

I am passing the data via SOAP. At the other side, it is retrieved (see below). For some reason, the data passed has to be in this same order as how it is retrieved. What is the purpose of giving a name to the name-value pairs if this is the case? Maybe it is how I configured PHP/SOAP?

PHP Code:
    $server->register('ostTicket.open',
        array(
            
'username'      => 'xsd:string',
            
'password'      => 'xsd:string',
            
'ticketData'    => 'tns:TicketData'
        
),
        array(
            
'ticketId'    => 'xsd:int'
        
),
        
SOAP_NAMESPACE,
        
false,false,false,
        
'Adds a ticket to the system'
    
); 
Reply With Quote
  #4  
Old 06-19-2012, 05:34 PM
NotionCommotion NotionCommotion is offline
Junior Member
 
Join Date: Jun 2012
Posts: 8
Default

Turns out SOAP (or some versions of it) requires names in order, and might not even care what the specific name is as long as it is in the correct order. Silly, but at least I can get it working.
Reply With Quote


Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:03 AM.