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
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";
?>

Thanks for help.