Using PHP Webform to Create Ticket

Moderator: crythias

Post Reply
RDSIT
OTRS newbie
Posts: 3
Joined: 21 May 2018, 22:39
OTRS Version?: 6.0.6
Real Name: IT
Company: Ricardo Defense

Using PHP Webform to Create Ticket

Post by RDSIT » 22 May 2018, 21:17

All,
I am at my wits end and I am sure that it is something that I am missing. So let me describe what I am trying to resolve.

We recently made the move form OTRS 4 to OTRS 6. In the environment of OTRS 4 we had a .php webform that allowed for an anonymous user to create a ticket. This form used the RCP.pl interface to make the ticket.

Now the problem in OTRS 6 that interface no longer has the same functionality as it did before. This is forcing us to move to the GenericInteface.pl to make the connection. I cannot seem to get the existing webform to work with that interface. The .php applet looks like:

Code: Select all

$url = "http://<FQDN>/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector";  // URL for OTRS server
$namespace = "http://<FQDN>/otrs/TicketConnector"; //Namespace in Webservice Configuration
$username = "<USER>";
$password = "<PASSWORD>"; 
$typeID = 2; // id from ticket_type table
$queueID = 2; // id from queue table
$priorityID = 1; // id from ticket_priority table
$ownerID = 2; // id from users table
$title = $_POST[title];
$severity = $_POST[severity];
$description = "First Name: " . $_POST [cust_fn] . "\n" . 
			"Last Name: " . $_POST [cust_ln] . "\n" .
			"Company Name: " . $_POST [cust_cn] . "\n" .
			"Phone Number: " . $_POST [cust_pn] . "\n" .
			"Product: " . $_POST [cpcprs] . "\n" .
			"Version: " . $_POST [cpcpv] . "\n" .
			"Type: " . $_POST [cpcpt] . "\n" .
			"Issue: " . $_POST [title] . "\n" .
			"Description: " . $_POST[description] ;
$email = $_POST[cust_ema];
$queue = $_POST[cpcprs];

$Operation = "TicketCreate"

$XMLData=array("UserLogin", $username,);

$client = new \SoapClient(
	null, 
	array(
		'location'  => $url,
		'uri'       => $namespace,
		'trace'     => 1,
		'style'     => SOAP_RPC,
		'use'       => SOAP_ENCODED,
	)
);

$msg=array(new SoapParam($username, 'ns1:UserLogin'),
		   new SoapParam($password, 'ns1:password'),
		   new SoapParm(Array(
				'CustomerUser'=> $from,
				'PriorityID'=> $priorityID,
				'Queue'=> $queue,
				'State'=> 'new',
				'Title'=> $title,
				), 'ns1:Ticket'),
			new SoapParam(Array(
			'Body'=> $description,
			'ContentType'=> 'text/plain; charset=ISO-8859-1',
			'Subject'=> $title,
			),'ns1:Article'),
);

$answer = $client->_soapCall('TicketCreate',$msg);
print_r($answer);
Other than changing the name space I am using the default GenericTicketConnector. Thank you in advance for pointing out any that I may have entered incorrectly

jojo
Moderator
Posts: 14386
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: Using PHP Webform to Create Ticket

Post by jojo » 22 May 2018, 22:55

the GenericInterface is different than rpc.pl

Have a look at our blog (blog.otrs.com) and the documentation at doc.otrs.org and in our development folder on github
"Production": OTRS™ 6, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

root
Moderator
Posts: 1303
Joined: 18 Dec 2007, 12:23
OTRS Version?: 4/5/6
Real Name: Roy Kaldung
Company: Znuny Inc.
Contact:

Re: Using PHP Webform to Create Ticket

Post by root » 23 May 2018, 08:06

Hi,

I've an working example for the REST endpoint, but not tested with OTRS 6. Maybe it help. https://github.com/rkaldung/otrs-gi-rest-php

- Roy
OTRS 4/5/6 CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

You need professional services? Check out https://www.znuny.com/

RDSIT
OTRS newbie
Posts: 3
Joined: 21 May 2018, 22:39
OTRS Version?: 6.0.6
Real Name: IT
Company: Ricardo Defense

Re: Using PHP Webform to Create Ticket

Post by RDSIT » 23 May 2018, 23:23

Thank you for the reply, I am using your sample but I am not seeing any responds in the web service windows of otrs like I was getting before.

root
Moderator
Posts: 1303
Joined: 18 Dec 2007, 12:23
OTRS Version?: 4/5/6
Real Name: Roy Kaldung
Company: Znuny Inc.
Contact:

Re: Using PHP Webform to Create Ticket

Post by root » 24 May 2018, 06:42

Hi,

Your example codes uses the SOAP, my example uses REST. Did you have both configured or just the one? Besides that, if no connect shows up in the GenericInterface debugging view I guess the endpoint URL in the client did not match your configuration. Please show your web service config.

- Roy
OTRS 4/5/6 CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

You need professional services? Check out https://www.znuny.com/

RDSIT
OTRS newbie
Posts: 3
Joined: 21 May 2018, 22:39
OTRS Version?: 6.0.6
Real Name: IT
Company: Ricardo Defense

Re: Using PHP Webform to Create Ticket

Post by RDSIT » 31 May 2018, 14:07

Roy,
Sorry it took so long to get back to you with this. I took some of the information provided and tried to discover the issue. I am still running in circles. Here is a export of the webservice let me know if you see anything.

Code: Select all

---
Debugger:
  DebugThreshold: debug
  TestMode: '0'
Description: Ticket Connector
FrameworkVersion: 6.0.6
Provider:
  Operation:
    Session::SessionCreate:
      Description: ''
      IncludeTicketData: ''
      MappingInbound: {}
      MappingOutbound: {}
      Type: Session::SessionCreate
    SessionCreate:
      Description: Creates a Session
      IncludeTicketData: ''
      MappingInbound: {}
      MappingOutbound: {}
      Type: Session::SessionCreate
    TicketCreate:
      Description: Creates a Ticket
      MappingInbound: {}
      MappingOutbound: {}
      Type: Ticket::TicketCreate
    TicketGet:
      Description: Retrieve Ticket data
      MappingInbound: {}
      MappingOutbound: {}
      Type: Ticket::TicketGet
    TicketSearch:
      Description: Search for Tickets
      MappingInbound: {}
      MappingOutbound: {}
      Type: Ticket::TicketSearch
    TicketUpdate:
      Description: Updates a Ticket
      MappingInbound: {}
      MappingOutbound: {}
      Type: Ticket::TicketUpdate
  Transport:
    Config:
      AdditionalHeaders: ~
      MaxLength: '100000000'
      NameSpace: http://<URL>/otrs/TicketConnector
      RequestNameFreeText: ''
      RequestNameScheme: Plain
      ResponseNameFreeText: ''
      ResponseNameScheme: Plain
      SOAPAction: Yes
      SOAPActionFreeText: ''
      SOAPActionScheme: NameSpaceSeparatorOperation
      SOAPActionSeparator: '#'
    Type: HTTP::SOAP
RemoteSystem: ''
Requester:
  Transport:
    Type: HTTP::SOAP

Post Reply