OTRS。更新门票

时间:2016-08-16 06:34:30

标签: php api soap otrs

我在自定义门户网站中更新otrs门票时遇到问题。我通过Soap Api使用PHP。这是我尝试过的一些事情。 我创建了一个Web服务。 在OTRS作为提供商,网络传输,我添加了名称空间https://otrs.classic.com.np/otrs/GenericInterface/actions。< -----这是正确的????????????? 我的PHP代码如下

$url      = "https://myurl.com/otrs/nph-genericinterface.pl";  // URL for OTRS server

            $namespace = "https://myurl.com/otrs/GenericInterface/actions";
            $username = "ctdeveloper";  // SOAP username set in sysconfig
            $password = "ctdeveloper";  // SOAP password set in sysconfig


            ### Form Fields

            $new_owner =$_POST['new_owner'];
            $subject =$_POST['subject'];
            $text = $_POST['text'];
            $note_type = $_POST['note_type'];

            #### Initialize new client session ####
            $client = new SoapClient(
                null,
                array(
                    'location'  => $url,
                    'uri'       => $namespace,
                    'trace'     => 1,
                    'login'     => $username,
                    'password'  => $password,
                    'style'     => SOAP_RPC,
                    'use'       => SOAP_ENCODED
                )
            );

            #### Create a new ticket shell. The function returns the Ticket ID ####
            $TicketUpdate = $client->__soapCall(
                "Dispatch", array($username, $password,"ctdeveloper",
                    "TicketObject", "TicketUpdate",
                    "TicketID", $ticket_id,
                    "OwnerID",      $new_owner,
                )
            );

1 个答案:

答案 0 :(得分:1)

好的,我找到了这个答案。希望它能帮到每个人。 首先在管理员OTRS

中创建一个Web服务
$URL = 'https://your-url.com/otrs/nph-genericinterface.pl/Webservice/WebserviceName'; //webserviceName is the name of webservice created from admin panel of otrs
$namespace = 'https://your-url.com/otrs/GenericInterface/actions'; //namespace of soap config

$username = "username"; //// SOAP username set in sysconfig
$password = "password"; //// SOAP password set in sysconfig

// initialize a SoapClient instance
$SOAPClientInstance = new \SoapClient(null, array(
'location'=> $URL,
'uri' => $namespace,
'trace' => 1,
'login' => $username,
'password'=> $password,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,

)
);


// set the request parameters as an array of SoapParam instances
$TicketRequestArray = array(

new \SoapParam('username', 'UserLogin'), //user username
new \SoapParam('password', "Password"),// user password
);

$TicketRequestArray[] = new \SoapParam('123', 'TicketID');// ID of ticket which is to be updated
$TicketRequestArray[] = new \SoapParam(array(
'State' => 'open',
'OwnerID' => $new_owner, // you can add which parameters to update
), 'Ticket');
$Action = 'TicketUpdate';

$Response = $SOAPClientInstance->__soapCall($Action,
$TicketRequestArray
);

print "<pre>\n";
print "Request :\n".htmlspecialchars($SOAPClientInstance->__getLastRequest()) ."\n";
print "Response:\n".htmlspecialchars($SOAPClientInstance->__getLastResponse())."\n";
print "</pre>";