OTRS SOAP responses in PHP SoapClient

English! place to talk about development, programming and coding
Post Reply
lerik
Znuny newbie
Posts: 2
Joined: 25 Oct 2011, 11:19
Znuny Version: 3.0.10
Real Name: Lars Erik Gullerud
Company: Signal Bredbånd AS

OTRS SOAP responses in PHP SoapClient

Post by lerik »

I am trying to integrate some of our internal systems with OTRS, and one of the many items I need to do is to request a list of open tickets for a particular customerID. Looks simple enough using the API, however I keep running into an annoying issue.

The particular system I am currently working on is written in PHP. When talking to OTRS using a PHP SoapClient, all responses from OTRS are wrapped in "s-gensym" tags that make the responses really hard to make sense of. A bit of googling seems to indicate that this is an artifact of Perl SOAP::Lite when not fed the data in an appropriate format. Right now I basically have to "decode" every single response differently due to these codes, because certain calls (like my search function mentioned above) returns something like this:

array(8) {
["s-gensym4"]=>
int(23827)
["s-gensym6"]=>
int(23631)
["s-gensym8"]=>
int(23180)
...

I.e. just an array of TicketIDs that are wrapped in s-gensym tags. While other functions that return name-value pairs, look like this (this particular response is from a GetUserData call):

array(48) {
["s-gensym4"]=>
string(7) "ValidID"
["s-gensym6"]=>
int(1)
["s-gensym8"]=>
string(9) "UserEmail"
["s-gensym10"]=>
string(14) "root@localhost"
...

This basically means I have to find ways to parse the output of every single SOAP call since there are no easily accessible data structures to use that make any sense. Has anyone actually used PHP to interface with OTRS before in a sensible way and have solution for this? Either on the server side or some "smart" way of solving this in the PHP client?

Any suggestions are welcome!
Andre Bauer
Znuny guru
Posts: 2189
Joined: 08 Dec 2005, 17:01
Znuny Version: 5.0.x
Real Name: André Bauer
Company: Magix Software GmbH
Location: Dresden
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by Andre Bauer »

Prod: Ubuntu Server 16.04 / Zammad 1.2

DO NOT PM ME WITH OTRS RELATED QUESTIONS! ASK IN THE FORUMS!

OtterHub.org
jeremy77
Znuny newbie
Posts: 10
Joined: 10 Dec 2010, 21:41
Znuny Version: 3.0.2

Dynamic Fields SOAP PHP 3.1.0Beta2

Post by jeremy77 »

Hello,

I've successfully used soap and php to create tickets in otrs using the example below. I was looking for a way to also populate dynamic fields using the soap client. I've looked through a lot of the documentation and searched the web but cannot find any examples for how to work with dynamic fields. Any help would be appreciated. I should not that I am using OTRS 3.1.0Beta2

Code: Select all

<?PHP
error_reporting(E_ALL);

# Please define the connection information here:
$url      = "http://10.2.170.106/otrs/rpc.pl";
$username = "mysecretotrssoapusername";
$password = "mysecretotrssoappassword";
$title    = "My Test Ticket via SOAP and PHP";
$from     = $_GET[email];


echo "<html>\n";
echo "<head>\n";
echo "<title>Test SOAP-Interface</title>\n";
echo "</head>\n";
echo "<body>\n";
echo "<h1>Test SOAP-interface of OTRS</h1>\n";

# Set up a new SOAP connection:
$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. The function returns the Ticket ID.
$TicketID = $client->__soapCall("Dispatch", array($username, $password,
"TicketObject", "TicketCreate",
"Title",        $title,
"Queue",        "Postmaster",
"Lock",         "Unlock",
"PriorityID",   2,
"State",        "new",
"CustomerUser", $from,
"OwnerID",      1,
"UserID",       1,
));

# A ticket is not usefull without at least one article. 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",           $from,
"Subject",        $title,
"ContentType",    "text/plain; charset=ISO-8859-1",
"Body",           "This is the body",
"UserID",         1,
"Loop",           0,
"AutoResponseType", 'auto reply',
"OrigHeader", array(
        'From' => $from,
        'To' => 'Postmaster',
        'Subject' => $title,
        'Body' => "This is the body"
    ),
));


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

# Make sure the ticket number is not displayed in scientific notation
# See http://forums.otrs.org/viewtopic.php?f=53&t=5135
$big_integer = 1202400000;
$Formatted_TicketNr = number_format($TicketNr, 0, '.', '');

# Print the info to the screen.
echo "<p>You have just created ticket id $TicketID with article id "
."$ArticleID. The ticket number is $Formatted_TicketNr.</p>\n";
echo "</body>\n";
echo "</html>\n";

?>
olivier972
Znuny newbie
Posts: 8
Joined: 04 Jan 2012, 20:57
Znuny Version: 3.1.0 beta3
Real Name: Olivier Jacques

Re: OTRS SOAP responses in PHP SoapClient

Post by olivier972 »

Hi Jeremy,

I, too, was looking for a way to create a ticket with dynamic fields.
It seems the API documentation was missing the new API to do so.
I opened a bug about it : http://bugs.otrs.org/show_bug.cgi?id=8086

Later, I found that in the OTRS CVS documentation (http://dev.otrs.org/) :
Kernel::GenericInterface::Operation::Ticket::TicketCreate
and it looks like some new API to create a ticket with article and WITH dynamic fields.

So, I tought, "that's great" !

I tried adapting the PHP example code to use the new API but with absolutely no success.

If someone @OTRS can give us a hint on how to adapt PHP creation ticket code to use this new API, that would be just wonderful!

Thanks in advance to anyone that could help.
jeremy77
Znuny newbie
Posts: 10
Joined: 10 Dec 2010, 21:41
Znuny Version: 3.0.2

Re: OTRS SOAP responses in PHP SoapClient

Post by jeremy77 »

I've upgraded to 3.1beta5 and still cannot get this to work. The current framework seems to be using the the AgentFreeText action which I thought was being deprecated:

<input type="hidden" name="Action" value="AgentTicketFreeText"/>
<input type="hidden" name="Subaction" value="Store"/>
<input type="hidden" name="TicketID" value="3"/>

If anyone has made progress on updating dynamic fields with php soap clients I would very much like to hear how you have done it.
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by jojo »

are you using rpc.pl?
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
jeremy77
Znuny newbie
Posts: 10
Joined: 10 Dec 2010, 21:41
Znuny Version: 3.0.2

Re: OTRS SOAP responses in PHP SoapClient

Post by jeremy77 »

yes i am using rpc.pl
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by jojo »

try to switch to the generic interface with the generic ticket connector (it is in beta 5)
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
olivier972
Znuny newbie
Posts: 8
Joined: 04 Jan 2012, 20:57
Znuny Version: 3.1.0 beta3
Real Name: Olivier Jacques

Re: OTRS SOAP responses in PHP SoapClient

Post by olivier972 »

Jojo,

I'm using rpc.pl too.

Any hint on how to modify the PHP example code (provided here https://faq.otrs.org/otrs/public.pl?Act ... ItemID=369 and also here http://wiki.otrs.org/index.php?title=Cr ... HP_via_RPC) for creating a ticket with dynamic fields ?

I'm kind of stuck here.

Thanks again for any help.

Olivier
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by jojo »

rpc.pl is depricated in near future. try to switch to the generic interface with the generic ticket connector (it is in beta 5)
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
jeremy77
Znuny newbie
Posts: 10
Joined: 10 Dec 2010, 21:41
Znuny Version: 3.0.2

Re: OTRS SOAP responses in PHP SoapClient

Post by jeremy77 »

I created the interface at 'http://127.0.0.1/otrs/nph-genericinterf ... Connector/' and was able to create the ticket but still cannot add the dynamic fields?

I was not able to create a php file that would generate the ticket but I did use the perl example in the otrs documentation to successfully create ticket. I tried both article and ticket dynamic fields



<Ticket>
<Title>some title</Title>
<Queue>Postmaster</Queue>
<State>new</State>
<DynamicField>
<Name>Product</Name>
<Value>notebook</Value>
</DynamicField>
<PriorityID>2</PriorityID>
<CustomerUser>email</CustomerUser>
</Ticket>
<Article>
<Subject>some subject</Subject>
<Body>some body</Body>
<ContentType>text/plain; charset=utf8</ContentType>
<TimeUnits>minutes</TimeUnits>
<TimeUnit>3</TimeUnit>
<DynamicField>
<Name>department</Name>
<Value>team</Value>
</DynamicField>

</Article>
jeremy77
Znuny newbie
Posts: 10
Joined: 10 Dec 2010, 21:41
Znuny Version: 3.0.2

Re: OTRS SOAP responses in PHP SoapClient

Post by jeremy77 »

I discovered my problem. As per the documentation

http://doc.otrs.org/3.1/en/html/generic ... s-examples

the dynamic fields tags are outside the article and ticket tags. Once I moved the tags it worked.

Now to translate the perl code to php
olivier972
Znuny newbie
Posts: 8
Joined: 04 Jan 2012, 20:57
Znuny Version: 3.1.0 beta3
Real Name: Olivier Jacques

Re: OTRS SOAP responses in PHP SoapClient

Post by olivier972 »

Jeremy,

I'm glad you succeed.

Now if someone can translate this to PHP code, that would be just wonderful.
jeremy77
Znuny newbie
Posts: 10
Joined: 10 Dec 2010, 21:41
Znuny Version: 3.0.2

Re: OTRS SOAP responses in PHP SoapClient

Post by jeremy77 »

I have been able to get the following code to post to the interface via php and soap. I'm sure it could use some refining but it works.

Code: Select all

error_reporting(E_ALL);
# Please define the connection information here:
$url      = "http://127.0.0.1/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector/";
$username = "root@localhost";
$title    = "My Test Ticket via SOAP and PHP";
$from     = "me@myemail.com";
$NameSpace = 'http://www.otrs.org/TicketConnector/';

$Operation = "TicketCreate";
//attachments
// Read in our file attachment
 $attachment = file_get_contents('attachment.txt');
 $encoded = base64_encode($attachment);
 $attached = chunk_split($encoded);
 $contenttype = "text/plain; charset=utf8";

$XMLData=array(

"UserLogin", "root",
);
$client = new SoapClient(null, array('location'  =>
$url,
                                     'uri'      => "CORE",
                                     'trace'    => 1,
                                     'style'     => SOAP_RPC,
                                     'use'       => SOAP_ENCODED));
$msg=array(new SoapParam('root@localhost', 'ns1:UserLogin'),
new SoapParam('mysupersecretpassword', 'ns1:Password'),
new SoapParam(Array(
        'CustomerUser'=> 'customer@email.com',
        'PriorityID' => '2',
        'Queue' => 'Postmaster',
        'State' => 'new',
        'Title' => 'some title',
), 'ns1:Ticket'),
new SoapParam(Array(
        'Body' => 'some body',
        'ContentType' => 'text/plain; charset=utf8',
        'Subject' => 'some subject',
        'TimeUnit' => '3',
        'TimeUnits' => 'minutes'
), 'ns1:Article'),
new SoapParam(Array(
        'Name' => 'Product',
        'Value' => 'Notebook',
), 'ns1:DynamicField'),
new SoapParam(Array(
        'Name' => 'department',
        'Value' => 'Team',
), 'ns1:DynamicField'),
new SoapParam(Array(
        'Content' => $attached,
        'ContentType' => $contenttype,
        'Filename' => 'Attatchment.txt'
), 'ns1:Attachment')

);
$answer = $client->__soapCall('TicketCreate',$msg);
print_r($answer);
olivier972
Znuny newbie
Posts: 8
Joined: 04 Jan 2012, 20:57
Znuny Version: 3.1.0 beta3
Real Name: Olivier Jacques

Re: OTRS SOAP responses in PHP SoapClient

Post by olivier972 »

Thanks Jeremy for posting this.

I also finally managed to make it work with a code quiet similar to yours.

I'm posting it below, maybe it can help someone.

Code: Select all

$url = 'http://<OTRS_FQDN>/nph-genericinterface.pl/Webservice/[the name of the webservice you created]

# Set up a new SOAP connection:
try {
	$client = new SoapClient(null, array('location'  => $url,
	                                     'uri'       => 'my_name_space',      // make sure it's the same as the namespace in network config of the webservice
	                                     'trace'     => true,
	                                     'style'     => SOAP_RPC,
	                                     'use'       => SOAP_ENCODED));
} catch (Exception $e) {
	echo "<h2>Exception Error!</h2>";
	echo $e->getMessage();
}

var_dump($client);

$Operation = 'ticketCreate';
try {
	$TicketID = $client->__soapCall($Operation, array(

		new SoapParam($username, "UserLogin"),
		new SoapParam($password, "Password"),

		new SoapParam(array(
			"Title" => "my very first PHP ticket",
			"CustomerUser" => "john",      // this one must exist as a customer
			"Queue" => "Postmaster",
			"State" => "new",
			"PriorityID" => 1,
			"Type" => "default"
		), "Ticket"),

		new SoapParam(array(
			"Subject" => "sujet",
			"Body" => $body,
			"ContentType" => 'text/html; charset=utf8'
		), "Article") ,
		
		new SoapParam(array(
			"Name" => "my_dynamic_field_name",
			"Value" => "ABCDEF"
		), "DynamicField")
	));
} catch (SoapFault $fault) {
	echo "REQUEST:\n".$client->__getLastRequest()."\n";
	echo "RESPONSE:\n".$client->__getLastResponse()."\n";
	echo "</pre>";
	exit;
}
var_dump($TicketID);
mwillstedt
Znuny newbie
Posts: 8
Joined: 17 Jan 2012, 17:09
Znuny Version: 3.0.10
Real Name: Martin Willstedt
Company: TechTrade International AB
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by mwillstedt »

Hi and thnx for the examples of this new nph-genericinterface.pl!

Has anyone had this problem with the soap response? I get this SOAPFault saying "Error fetching HTML header", my error_log at the OTRS-server says "[warn] /otrs/nph-genericinterface.pl/Webservice/myname did not send an HTTP header".

This new great debugger says everything is just fine...
jeremy77
Znuny newbie
Posts: 10
Joined: 10 Dec 2010, 21:41
Znuny Version: 3.0.2

Re: OTRS SOAP responses in PHP SoapClient

Post by jeremy77 »

mwillstedt is your network transport set to soap or left blank. In my php example file is should be set to soap.
mwillstedt
Znuny newbie
Posts: 8
Joined: 17 Jan 2012, 17:09
Znuny Version: 3.0.10
Real Name: Martin Willstedt
Company: TechTrade International AB
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by mwillstedt »

the network transport is set to SOAP yes, i got this feeling something else is wrong..
jeremy77
Znuny newbie
Posts: 10
Joined: 10 Dec 2010, 21:41
Znuny Version: 3.0.2

Re: OTRS SOAP responses in PHP SoapClient

Post by jeremy77 »

I'm having a problem creating tickets for customers stored in ldap. I get the following error:

TicketCreate.InvalidParameter [ErrorMessage] => TicketCreate: Ticket->CustomerUser parameter is invalid!

if I run the same script against a customer in the database it works. Any ideas?
mwillstedt
Znuny newbie
Posts: 8
Joined: 17 Jan 2012, 17:09
Znuny Version: 3.0.10
Real Name: Martin Willstedt
Company: TechTrade International AB
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by mwillstedt »

Still stuck on this..

I run this code localy, its a perl-script now...

Code: Select all

my $URL = 'my valid url';
my $NameSpace = 'my valid namespace';

my $XMLData = '
<UserLogin>user</UserLogin>
<Password>pwd</Password>
<TicketID>977</TicketID>
<UserID>2</UserID>
';

# ---

# create a SOAP::Lite data structure from the provided XML data structure.
my $SOAPData = SOAP::Data
    ->type( 'xml' => $XMLData );

my $SOAPObject = SOAP::Lite
    ->uri($NameSpace)
    ->proxy($URL)
    ->$Operation($SOAPData);

# check for a fault in the soap code.
if ( $SOAPObject->fault ) {
    print $SOAPObject->faultcode, " ", $SOAPObject->faultstring, "\n";
}
The answer? Its "500 Server closed connection without sending any data back at myscript.pl line 68"

httpd error_log says:
[Thu Feb 23 10:29:18 2012] [error] [client 127.0.0.1] malformed header from script. Bad header=HTTP/1.1 200 OK: nph-genericinterface.pl
[Thu Feb 23 10:29:18 2012] [warn] /otrs/nph-genericinterface.pl/Webservice/mywb did not send an HTTP header

Debugger says:

Outgoing data after mapping (2012-02-23 10:29:18, debug)
$VAR1 = {
'Ticket' => [
{
'Age' => 783556,
and so on...

Returning provider data to remote system (HTTP Code: 200) (2012-02-23 10:29:18, debug)
783556n82012-02-21 10:32:46113292058022012-02-14 08:50:026641 and so on..

I tried all possible configurations in the web services gui, i dont even know where to start investigate this problem.
sanzzes
Znuny newbie
Posts: 7
Joined: 13 Mar 2012, 11:31
Znuny Version: 31112
Real Name: Steven

Re: OTRS SOAP responses in PHP SoapClient

Post by sanzzes »

Solution for HTTP Headers error:
Excuse me for my Bad english Im German.
(Based on Linux)
Login to Your Rootserver

Go to
/etc/apache2/sites-enabled
in it is a otrs named file open it

at after that

# set mod_perl2 options
<Location /otrs>
# ErrorDocument 403 /otrs/customer.pl
ErrorDocument 403 /otrs/index.pl
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
Options +ExecCGI
PerlOptions +ParseHeaders
PerlOptions +SetupEnv
Order allow,deny
Allow from all
</Location>

this:

# set mod_perl2 option for generic interface
<Location /otrs/nph-genericinterface.pl>
PerlOptions -ParseHeaders
</Location>

And it will work 4 you
mwillstedt
Znuny newbie
Posts: 8
Joined: 17 Jan 2012, 17:09
Znuny Version: 3.0.10
Real Name: Martin Willstedt
Company: TechTrade International AB
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by mwillstedt »

Thx sanzzes, works lika a charm! I missed that in my 3.1.1 installation..
virusmoere
Znuny newbie
Posts: 4
Joined: 26 Mar 2012, 22:50
Znuny Version: 3.1.2

Re: OTRS SOAP responses in PHP SoapClient

Post by virusmoere »

Hi,

I user OTRS with nginx in fcgi mode an I currently try to add tickets through the generic interface. Unfortunately I always get an error response from OTRS:

Code: Select all

Request Details
Communication sequence started (2012-03-28 00:59:12, debug)
$VAR1 = {
  'CONTENT_LENGTH' => '533',
  'CONTENT_TYPE' => 'text/xml; charset=utf-8',
  'DOCUMENT_ROOT' => '/home/otrs/otrs/var/httpd/htdocs',
  'DOCUMENT_URI' => '/otrs/nph-genericinterface.pl/Webservice/generic',
  'FCGI_ROLE' => 'RESPONDER',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'HTTP_ACCEPT' => 'application/soap',
  'HTTP_CONNECTION' => 'TE, close',
  'HTTP_CONTENT_LENGTH' => '533',
  'HTTP_CONTENT_TYPE' => 'text/xml; charset=utf-8',
  'HTTP_HOST' => 'otrs.somedomain.com',
  'HTTP_SOAPACTION' => '"http://www.otrs.org/TicketConnector/#"',
  'HTTP_TE' => 'deflate,gzip;q=0.3',
  'HTTP_USER_AGENT' => 'SOAP::Lite/Perl/0.714',
  'QUERY_STRING' => '',
  'REMOTE_ADDR' => '1.2.3.4',
  'REMOTE_PORT' => '47536',
  'REQUEST_METHOD' => 'POST',
  'REQUEST_URI' => '/otrs/nph-genericinterface.pl/Webservice/generic',
  'SCRIPT_FILENAME' => '/home/otrs/otrs/bin/fcgi-bin/nph-genericinterface.pl',
  'SCRIPT_NAME' => '/otrs/nph-genericinterface.pl/Webservice/generic',
  'SERVER_ADDR' => '1.2.3.4',
  'SERVER_NAME' => 'otrs.somedomain.com',
  'SERVER_PORT' => '80',
  'SERVER_PROTOCOL' => 'HTTP/1.1',
  'SERVER_SOFTWARE' => 'nginx'
};
Could not read input data (2012-03-28 00:59:12, error)
No data provided
Request could not be processed (2012-03-28 00:59:12, error)
Could not read input data
Returning provider data to remote system (HTTP Code: 500) (2012-03-28 00:59:12, error)
Could not read input data
nginx error log:

Code: Select all

2012/03/28 00:59:12 [error] 17371#0: *5137 FastCGI sent in stderr: "ERROR: GenericInterfaceProvider-10 Perl: 5.10.1 OS: linux Time: Wed Mar 28 00:59:12 2012

 Message: DebugLog error:  Summary: Could not read input data  Data   : No data provided.

 Traceback (9421):
   Module: Kernel::GenericInterface::Debugger::DebugLog (v1.17) Line: 241
   Module: Kernel::GenericInterface::Debugger::Error (v1.17) Line: 335
   Module: Kernel::GenericInterface::Transport::HTTP::SOAP::_Error (v1.41) Line: 667
   Module: Kernel::GenericInterface::Transport::HTTP::SOAP::ProviderProce" while reading response header from upstream, client: 1.2.3.4, server: otrs.somedomain.com, request: "POST /otrs/nph-genericinterface.pl/Webservice/generic HTTP/1.1", upstream: "fastcgi://unix:/var/run/otrs/otrs.somedomain.com.nph-genericinterface.pl.sock:", host: "otrs.somedomain.com"
2012/03/28 00:59:12 [error] 17371#0: *5137 FastCGI sent in stderr: "ssRequest (v1.41) Line: 175
   Module: Kernel::GenericInterface::Transport::ProviderProcessRequest (v1.12) Line: 144
   Module: Kernel::GenericInterface::Provider::Run (v1.22) Line: 187
   Module: /home/otrs/otrs/bin/fcgi-bin/nph-genericinterface.pl (v1.1) Line: 49

ERROR: GenericInterfaceProvider-10 Perl: 5.10.1 OS: linux Time: Wed Mar 28 00:59:12 2012

 Message: DebugLog error:  Summary: Request could not be processed  Data   : Could not read input data.

 Traceback (9421):
   Module: Kernel::Gen" while reading response header from upstream, client: 1.2.3.4, server: otrs.somedomain.com, request: "POST /otrs/nph-genericinterface.pl/Webservice/generic HTTP/1.1", upstream: "fastcgi://unix:/var/run/otrs/otrs.somedomain.com.nph-genericinterface.pl.sock:", host: "otrs.somedomain.com"
2012/03/28 00:59:12 [error] 17371#0: *5137 FastCGI sent in stderr: "ericInterface::Debugger::DebugLog (v1.17) Line: 241
   Module: Kernel::GenericInterface::Debugger::Error (v1.17) Line: 335
   Module: Kernel::GenericInterface::Provider::Run (v1.22) Line: 191
   Module: /home/otrs/otrs/bin/fcgi-bin/nph-genericinterface.pl (v1.1) Line: 49

ERROR: GenericInterfaceProvider-10 Perl: 5.10.1 OS: linux Time: Wed Mar 28 00:59:12 2012

 Message: DebugLog error:  Summary: Returning provider data to remote system (HTTP Code: 500)  Data   : Could not read input data.

 Tracebac" while reading response header from upstream, client: 1.2.3.4, server: otrs.somedomain.com, request: "POST /otrs/nph-genericinterface.pl/Webservice/generic HTTP/1.1", upstream: "fastcgi://unix:/var/run/otrs/otrs.somedomain.com.nph-genericinterface.pl.sock:", host: "otrs.somedomain.com"
2012/03/28 00:59:12 [error] 17371#0: *5137 FastCGI sent in stderr: "k (9421):
   Module: Kernel::GenericInterface::Debugger::DebugLog (v1.17) Line: 241
   Module: Kernel::GenericInterface::Transport::HTTP::SOAP::_Output (v1.41) Line: 752
   Module: Kernel::GenericInterface::Transport::HTTP::SOAP::ProviderGenerateResponse (v1.41) Line: 277
   Module: Kernel::GenericInterface::Transport::ProviderGenerateResponse (v1.12) Line: 191
   Module: Kernel::GenericInterface::Provider::_GenerateErrorResponse (v1.22) Line: 369
   Module: Kernel::GenericInterface::Provider::Run" while reading response header from upstream, client: 1.2.3.4, server: otrs.somedomain.com, request: "POST /otrs/nph-genericinterface.pl/Webservice/generic HTTP/1.1", upstream: "fastcgi://unix:/var/run/otrs/otrs.somedomain.com.nph-genericinterface.pl.sock:", host: "otrs.somedomain.com"
2012/03/28 00:59:12 [error] 17371#0: *5137 FastCGI sent in stderr: "(v1.22) Line: 196
   Module: /home/otrs/otrs/bin/fcgi-bin/nph-genericinterface.pl (v1.1) Line: 49" while reading response header from upstream, client: 1.2.3.4, server: otrs.somedomain.com, request: "POST /otrs/nph-genericinterface.pl/Webservice/generic HTTP/1.1", upstream: "fastcgi://unix:/var/run/otrs/otrs.somedomain.com.nph-genericinterface.pl.sock:", host: "otrs.somedomain.com"

Anyone got this running on fastcgi mode?


Regards,
Daniel
isulegig
Znuny newbie
Posts: 1
Joined: 14 May 2012, 21:53
Znuny Version: 34851
Real Name: Raducu Mihai
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by isulegig »

I have exactly the same problem.... :( Please help!!
artjoms15
Znuny advanced
Posts: 121
Joined: 30 Aug 2011, 10:48
Znuny Version: 3.3.8 && 4.0.9
Real Name: Artjoms Petrovs
Location: Latvia

Re: OTRS SOAP responses in PHP SoapClient

Post by artjoms15 »

Is it possible to create articles with attachments via new Generic Interface? Haven't seen any examples or realizations of this.
Can anyone guide me the right direction - if there is any kind of API to do so, or should it be done in separate steps, like step1: upload attachment to server step2: Create article with link to new content?

Thanks in Advance! :)
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS SOAP responses in PHP SoapClient

Post by jojo »

yes, it is.

Have a look at the wsdl file and also the Perl prototype script here: http://source.otrs.org/viewvc.cgi/otrs/ ... bservices/

Also check admin manual
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
artjoms15
Znuny advanced
Posts: 121
Joined: 30 Aug 2011, 10:48
Znuny Version: 3.3.8 && 4.0.9
Real Name: Artjoms Petrovs
Location: Latvia

Re: OTRS SOAP responses in PHP SoapClient

Post by artjoms15 »

Thanks. Will try to dig into this! :)
Ar cieņu / Kind regards,
----------------------------------------
Artjoms Petrovs
Sistēmu analītiķis/Programmētājs /
Systems Analyst/Programmer
Niklaus
Znuny newbie
Posts: 14
Joined: 17 Jan 2013, 09:07
Znuny Version: 3.1.12
Real Name: Niklas Lampén
Company: Aava Kotisivupalvelu

Re: OTRS SOAP responses in PHP SoapClient

Post by Niklaus »

sanzzes wrote:Solution for HTTP Headers error:
Excuse me for my Bad english Im German.
(Based on Linux)

# set mod_perl2 option for generic interface
<Location /otrs/nph-genericinterface.pl>
PerlOptions -ParseHeaders
</Location>
I love you for this. Thanks!
FairFight
Znuny newbie
Posts: 14
Joined: 29 Sep 2011, 22:51
Znuny Version: 3.0.10

Re: OTRS SOAP responses in PHP SoapClient

Post by FairFight »

This ticket has been very helpful when using the SOAP interface.
However I am not able to set a CustomerID when I create a ticket.
Can someone advise me how to do it?
jeremyk
Znuny newbie
Posts: 21
Joined: 18 Jul 2013, 15:29
Znuny Version: 3.2.8
Real Name: Jeremy Kessous
Company: DataMotion

Re: OTRS SOAP responses in PHP SoapClient

Post by jeremyk »

olivier972 wrote:Thanks Jeremy for posting this.

I also finally managed to make it work with a code quiet similar to yours.

I'm posting it below, maybe it can help someone.

Code: Select all

$url = 'http://<OTRS_FQDN>/nph-genericinterface.pl/Webservice/[the name of the webservice you created]

# Set up a new SOAP connection:
try {
	$client = new SoapClient(null, array('location'  => $url,
	                                     'uri'       => 'my_name_space',      // make sure it's the same as the namespace in network config of the webservice
	                                     'trace'     => true,
	                                     'style'     => SOAP_RPC,
	                                     'use'       => SOAP_ENCODED));
} catch (Exception $e) {
	echo "<h2>Exception Error!</h2>";
	echo $e->getMessage();
}

var_dump($client);

$Operation = 'ticketCreate';
try {
	$TicketID = $client->__soapCall($Operation, array(

		new SoapParam($username, "UserLogin"),
		new SoapParam($password, "Password"),

		new SoapParam(array(
			"Title" => "my very first PHP ticket",
			"CustomerUser" => "john",      // this one must exist as a customer
			"Queue" => "Postmaster",
			"State" => "new",
			"PriorityID" => 1,
			"Type" => "default"
		), "Ticket"),

		new SoapParam(array(
			"Subject" => "sujet",
			"Body" => $body,
			"ContentType" => 'text/html; charset=utf8'
		), "Article") ,
		
		new SoapParam(array(
			"Name" => "my_dynamic_field_name",
			"Value" => "ABCDEF"
		), "DynamicField")
	));
} catch (SoapFault $fault) {
	echo "REQUEST:\n".$client->__getLastRequest()."\n";
	echo "RESPONSE:\n".$client->__getLastResponse()."\n";
	echo "</pre>";
	exit;
}
var_dump($TicketID);

Oliver,

I am wondering, in the line for "CustomerUser", you state that it is required that this is an existing customer. When I create a ticket with customeruser set to someone that is already registered as a customer, it populates the customerid field. However if i use an email address that does not exist in our customers, it does not put anything for customerid.

I am using this function in a web form so that people can log on to our support site and put in a ticket. However, it is not required of them to register as a customer, because that would defeat the purpose of a generic web form. if they are already a registered user, they can just log into the customer portal and submit a ticket.

What I am wondering is, is there any way that I can make it so that it just takes customeruser and sets the customerid accordingly. When I was previously doing this using rpc.pl, it did set the customerid regardless of if the customer existed or not.
OTRS v3.2.8 running on Debian 7 with MySQL
Miskra
Znuny newbie
Posts: 3
Joined: 03 Sep 2013, 16:32
Znuny Version: 3.2.7
Real Name: Marcin Iskra

Re: OTRS SOAP responses in PHP SoapClient

Post by Miskra »

Hi,

I have a similar problem as Jeremy.

I am supporting Customers without asking them for registration, therefore I am not able to register each customer in OTRS. Tickets are being created via webservice, where customer can enter his e-mail address. When creating Ticket, I'm sending customers e-mail address in tags:

Code: Select all

 <Ticket>
    [...]
    <CustomerUser>customer@test.pl</CustomerUser>
 </Ticket>
 <Article>
    <From>customer@test.pl</From>
     [...]
 </Article>
The Ticket is created and the e-mail address is present in the "From:" field.
The Problem is: when I'm selecting "Reply" in OTRS and new window opens, the TO: field is empty. Customers e-mail address is not entered in any of the fields. I registered the e-mail address as a Customer in OTRS and created a new Ticket via webservice. When I hit the "Reply", customers e-mail address was entered into CC: field. TO: field was still empty.

Did any of you had same problem? Is there any way to solve it? Currently agents answering the e-mails will have to copy the e-mail address from customers e-mail and then paste it into the TO: field which is quite troublesome.

I'm using OTRS 3.2.7 at the moment.
BenI
Znuny newbie
Posts: 72
Joined: 18 Mar 2014, 13:09
Znuny Version: 5.0.19
Real Name: Ben Ipinge
Company: Telecom Namibia

Re: OTRS SOAP responses in PHP SoapClient

Post by BenI »

I know the post is old, but I am busy setting up web service for integration to another system. I am running OTRS 5, it seems that everything else works but when I run a request against any operation I get the following error message

Code: Select all

[Mon Aug 12 20:00:04.766314 2019] [core:error] [pid 988:tid 140445656983296] [client 192.68.29.06:61995] malformed header from script 'nph-genericinterface.pl': Bad header:
[Mon Aug 12 20:00:04.766371 2019] [perl:warn] [pid 988:tid 140445656983296] /nph-genericinterface.pl/Webservice/TestWS did not send an HTTP header
Not sure if its a code bug as some articles suggest or web server configuration issue which has been thoroughly checked. I am stuck!
BenI
Znuny newbie
Posts: 72
Joined: 18 Mar 2014, 13:09
Znuny Version: 5.0.19
Real Name: Ben Ipinge
Company: Telecom Namibia

Re: OTRS SOAP responses in PHP SoapClient

Post by BenI »

Another output message

Code: Select all

[Tue Aug 20 11:38:04 2019] [error] [client 192.68.29.26] malformed header from script. Bad header=HTTP/1.1 200 OK: nph-genericinterface.pl
[Tue Aug 20 11:38:04 2019] [warn] /nph-genericinterface.pl/Webservice/TestWS did not send an HTTP header
Post Reply