Error during ticket create using SOAP

Moderator: crythias

Locked
marcosaurelio
Znuny expert
Posts: 185
Joined: 08 May 2014, 16:05
Znuny Version: 6.0.10
Real Name: Marcos Aurelio Silverio
Company: Infracerta
Location: Brazil
Contact:

Error during ticket create using SOAP

Post by marcosaurelio »

When I create a ticket using the SOAP interface the request takes around 35 seconds to complete. Looking at the apache log I see this error:

Code: Select all

[Fri Jun 13 14:05:32 2014] [error] [client x.x.x.x] PHP Fatal error:  Uncaught SoapFault exception: [HTTP] Error Fetching http headers in /var/www/add_ticket_soap.php:110\nStack trace:\n#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://localhos...', 'Core#Dispatch', 1, 0)\n#1 /var/www/add_ticket_soap.php(110): SoapClient->__soapCall('Dispatch', Array)\n#2 {main}\n  thrown in /var/www/add_ticket_soap.php on line 110, referer: http://myhostaddress/new_ticket.htm
Ticket is created successfully, but I use the same code in other OTRS instance and there a ticket is created in 5 seconds without error on Apache log.

My script to create tickets via SOAP:

Code: Select all

<?PHP
error_reporting(E_ALL);
############## --  Simple web services form processor -- ###############
#                                                                      #
#         ***  OFFERED AS-IS.  USE IT AT YOUR OWN RISK!  ***           #
#                                                                      # 
#  Written by Jeff Eske - June 2012                                    #
#                                                                      #
#  Works with OTRS 3.1.6 and 3.1.7 for sure.  Probably works with      #
#  other versions as well.                                             #
#                                                                      # 
#  I don't offer support on this in any way, shape, or form.  You can  #
#  use it, but you have to figure out what to do with it.              #
#                                                                      #
#  Did I mention - USE IT AT YOUR OWN RISK!!                            #
########################################################################


#######    PLEASE SET THESE VARIABLES TO MATCH YOUR SYSTEM     #########
#  You can set others in the code below, but these should be the main  #
#  things that you may want to adjust.                                 # 
########################################################################

$url      = "http://myhostaddress/otrs/rpc.pl";  // URL for OTRS server
$username = "mysoapuser";  // SOAP username set in sysconfig
$password = "somepass";  // SOAP password set in sysconfig
$typeID = 1; // id from ticket_type table
$queueID = 3; // id from queue table
$priorityID = 1; // id from ticket_priority table
$ownerID = 1; // id from users table

########################################################################
#### You don't have to change anything below here, although you can ####
########################################################################

#### FORM FIELDS ####
$title = $_POST[title];
$from = $_POST[cust_login];
$description = $_POST['description'];
$email = $_POST[email];
echo $title;
echo '<br>';
echo $from;
echo '<br>';
echo $description;
echo '<br>';
echo $email;
	
#### Initialize new client session ####
$client = new SoapClient(
	null, 
	array(
		'location'  => $url,
		'uri'       => "Core",
		'trace'     => 1,
		'login'     => $username,
		'password'  => $password,
		'style'     => SOAP_RPC,
		'use'       => SOAP_ENCODED
	)
);

#### Create a new ticket shell. The function returns the Ticket ID ####
$TicketID = $client->__soapCall(
	"Dispatch", array($username, $password,
	"TicketObject", "TicketCreate", 
	"Title",        $title, 
	"TypeID",	$typeID, 
	"QueueID",   $queueID, 
	"LockID",  1, 
	"PriorityID",   $priorityID, 
	"State",        "new", 
	"CustomerUser", "teste.otrs", 
	"CustomerID", "TEST", //Hardcoded just fo testing
	"OwnerID",      $ownerID, 
	"UserID",       1,
	)
);


##### Create an article with the info. The function returns an Article ID #### 
$ArticleID = $client->__soapCall("Dispatch", 
	array($username, $password,
		"TicketObject",   "ArticleCreate",
		"TicketID",       $TicketID,
		"ArticleType",    "webrequest",
		"SenderType",     "customer",
		"HistoryType",    "WebRequestCustomer",
		"HistoryComment", "created from PHP",
		"From",           $email,
		"Subject",        $title,
		"ContentType",    "text/plain; charset=ISO-8859-1",
		"Body",           $description,
		"UserID",         1,
		"Loop",           0,
		"AutoResponseType", 'auto reply',
		"OrigHeader", array(
			'From' => $email,
			'To' => $from,
			'Subject' => $title,
			'Body' => $description
		),
	)
);

# Use the Ticket ID to retrieve the Ticket Number.
$TicketNum = $client->__soapCall("Dispatch", 
array($username, $password,
"TicketObject",   "TicketNumberLookup",
"TicketID",       $TicketID,
)
);

# Make sure the ticket number is not displayed in scientific notation


# Print the info to the screen.
echo "<html>\n";
echo "<head>\n";
echo "<title>Ticket Successfully Submitted</title>\n";
echo "</head>\n";
echo "<body>\n";
echo "<h1>Success!</h1>\n";
echo "<p>You have successfully created ticket number $TicketNum.</p>\n";
echo "</body>\n";
echo "</html>\n";

?>
Google gives me nothing. :(

Thanks for help.
OTRS 6.0.10 Centos 7 Mysql 5.6
Videos de OTRS no Youtube: https://www.youtube.com/channel/UCscGon ... 7hADe3AalA
http://infracerta.com.br
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Error during ticket create using SOAP

Post by crythias »

The first search result I found was this. which tends to indicate a delay of some sort.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
marcosaurelio
Znuny expert
Posts: 185
Joined: 08 May 2014, 16:05
Znuny Version: 6.0.10
Real Name: Marcos Aurelio Silverio
Company: Infracerta
Location: Brazil
Contact:

Re: Error during ticket create using SOAP

Post by marcosaurelio »

crythias wrote:The first search result I found was this. which tends to indicate a delay of some sort.
Well, something weird happened.

I disabled mail notification for agents (when a ticket is created) and it takes about 5 seconds to open a ticket. I've set the system to send messages using SMTPTLS, but after reset to default (sendmail) and reactivating mail notification all is working fine.

:?:
OTRS 6.0.10 Centos 7 Mysql 5.6
Videos de OTRS no Youtube: https://www.youtube.com/channel/UCscGon ... 7hADe3AalA
http://infracerta.com.br
Locked