如何通过 OTRS 中的 Web 服务(SOAP 或 REST)将配置项链接/获取到工单

2024-01-14

我想知道如何通过 SOAP 或 REST Web 服务获取票证并将其链接到配置项。 我已经导入了这个轻松的网络服务 https://github.com/OTRS/otrs/blob/master/development/webservices/GenericTicketConnectorREST.yml在管理控制台中并使用此网址成功创建并获取票证信息http://XXX.XXX.XXX.XXX/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/1 http://XXX.XXX.XXX.XXX/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/1.

但问题是当我获取票证信息时,链接的配置项信息没有出现。

我在谷歌上做了很多搜索,发现票证可以通过 OTRS GUI 链接到配置项,并且在 AgentTicketzoom 页面中它将显示,我希望通过网络服务来完成此操作。 任何人都可以帮助我解决这个问题,或者建议一些有关如何创建 Web 服务以从票证中获取链接对象信息的文档。

更新#1

我已成功将 Web 控制器添加到现有的票证连接器中。网址是http://XXX.XXX.XXX.XXX/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorRest/LinkObject http://XXX.XXX.XXX.XXX/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorRest/LinkObject使用 POST Call.but 我收到此错误

{"faultcode":"服务器","faultstring":"没有 ConfigObject!"}

我也检查了初始参数

$VAR1 = {  'Password' => '1234567',  'RequestMethod' => 'POST','SourceKey' => '1',  'SourceObject' => 'Ticket',  'State' => 'valid',  'TargetKey' => '2',  'TargetObject' => 'ITSMConfigItem',  'Type' => 'ParentChild',  'UserID' => '1',  'UserLogin' => '[email protected] /cdn-cgi/l/email-protection'};

$VAR1 = {  'ErrorMessage' => 'Got no ConfigObject!',  'Success' => 0};

是的,票证可以通过 GUI 链接到 configItem,并且可以通过 Web 服务完成。

首先,您应该编写一个新的通用接口连接器操作,它将处理方法LinkAdd from 链接对象班级 (APIdoc https://github.com/OTRS/otrs/blob/1e908159a5dbdcfb94cc35d13bf15b04ac3e6a24/Kernel/System/LinkObject.pm )

然后通过新的 XML 文件创建并注册新操作,如下所示:

文件名:GenericInterfaceLinkObjectConnector.xml

<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="1.0" init="Application">
<ConfigItem Name="GenericInterface::Operation::Module###LinkObject::LinkAdd" Required="0" Valid="1">
        <Description Translatable="1">GenericInterface module registration for the operation layer.</Description>
        <Group>GenericInterface</Group>
        <SubGroup>GenericInterface::Operation::ModuleRegistration</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Name">LinkAdd</Item>
                <Item Key="Controller">LinkObject</Item>
                <Item Key="ConfigDialog">AdminGenericInterfaceOperationDefault</Item>
            </Hash>
        </Setting>
    </ConfigItem>
</otrs_config>

之后,您可以从 OTRS GUI 发布新的提供程序 WebService,其中使用新创建的连接器。

确保传递该方法所需的所有参数!

 $True = $LinkObject->LinkAdd(
    SourceObject => 'Ticket',
    SourceKey    => '321',
    TargetObject => 'FAQ',
    TargetKey    => '5',
    Type         => 'ParentChild',
    State        => 'Valid',
    UserID       => 1,
);

UPDATE:

请阅读这个Document https://otrs.github.io/doc/manual/admin/3.2/en/html/genericinterface.html要了解通用接口是如何构建的,然后请添加一个新的连接器( LinkObject )

要注册连接器及其操作 - 将 XML 文件放入 /Kernel/Config/Files/...

然后转到 Sysconfig -> GenericInterface -> GenericInterface::Operation::ModuleRegistration 并在 GenericInterface::Operation::Module###LinkObject::LinkAdd 旁边设置一个勾号并保存更改

然后将此连接器文件添加到 /Custom/Kernel/GenericInterface/Operation/LinkObject/LinkAdd.pm

# --
# Kernel/GenericInterface/Operation/LinkObject/LinkAdd.pm - GenericInterface LinkAdd operation backend
# Copyright (C) 2016 ArtyCo (Artjoms Petrovs), http://artjoms.lv/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::GenericInterface::Operation::LinkObject::LinkAdd;

use strict;
use warnings;

use Kernel::GenericInterface::Operation::Common;
use Kernel::System::LinkObject;
use Kernel::System::VariableCheck qw(IsStringWithData IsHashRefWithData);

=head1 NAME

Kernel::GenericInterface::Operation::LinkObject::LinkAdd - GenericInterface Link Create Operation backend

=head1 SYNOPSIS

=head1 PUBLIC INTERFACE

=over 4

=cut

=item new()

usually, you want to create an instance of this
by using Kernel::GenericInterface::Operation->new();

=cut

sub new {
    my ( $Type, %Param ) = @_;

    my $Self = {};
    bless( $Self, $Type );

    # check needed objects
    for my $Needed (
        qw(DebuggerObject ConfigObject MainObject LogObject TimeObject DBObject EncodeObject WebserviceID)
        )
    {
        if ( !$Param{$Needed} ) {
            return {
                Success      => 0,
                ErrorMessage => "Got no $Needed!"
            };
        }

        $Self->{$Needed} = $Param{$Needed};
    }

    # create additional objects
    $Self->{CommonObject} = Kernel::GenericInterface::Operation::Common->new( %{$Self} );
    $Self->{LinkObject}
        = Kernel::System->LinkObject->new( %{$Self} );

    return $Self;
}

=item Run()

Create a new link.

    my $Result = $OperationObject->Run(
        Data => {
            SourceObject => 'Ticket',
            SourceKey    => '321',
            TargetObject => 'Ticket',
            TargetKey    => '12345',
            Type         => 'ParentChild',
            State        => 'Valid',
            UserID       => 1,
        },
    );

    $Result = {
        Success      => 1,                                # 0 or 1
        ErrorMessage => '',                               # In case of an error
        Data         => {
            Result => 1,                                  # 0 or 1 
        },
    };

=cut

sub Run {
    my ( $Self, %Param ) = @_;

    # check needed stuff
    if ( !IsHashRefWithData( $Param{Data} ) ) {
        return $Self->{CommonObject}->ReturnError(
            ErrorCode    => 'LinkAdd.MissingParameter',
            ErrorMessage => "LinkAdd: The request is empty!",
        );
    }



    my $LinkID = $Self->{LinkObject}->LinkAdd(
        %Param,
    );

    if ( !$LinkID ) {
        return $Self->{CommonObject}->ReturnError(
            ErrorCode    => 'LinkAdd.AuthFail',
            ErrorMessage => "LinkAdd: Authorization failing!",
        );
    }

    return {
        Success => 1,
        Data    => {
            Result => $LinkID,
        },
    };
}

1;

=back

=head1 TERMS AND CONDITIONS

This software is part of the OTRS project (L<http://otrs.org/>).

This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (AGPL). If you
did not receive this file, see L<http://www.gnu.org/licenses/agpl.txt>.

=cut

然后它应该出现并可以从管理 -> Web 服务 -> 可用操作下拉列表中使用,当然也可以用作 Web 服务。

PHP 使用示例如下:

    #### 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 and send the SOAP Function Call ####
$success = $client->__soapCall("Dispatch", 
array($username, $password,
"LinkObject", "LinkAdd",
"SourceObject", 'Ticket',
"SourceKey", $ticket_id1,
"TargetObject", 'Ticket',
"TargetKey", $ticket_id2,
"Type", 'ParentChild',
"State", 'Valid',
"UserID", '1'
));

如果出现错误 - 启用调试、查看系统日志并检查 OTRS 的所有初始设置

祝你好运!

更新#2

要注册 Web 服务 - 按添加新 Web 服务按钮,根据需要命名并设置以下设置(选择 LinkAdd 操作)并保存

更新#3

这是 OTRS 5 的更新模块文件

    # --
# Kernel/GenericInterface/Operation/LinkObject/LinkAdd.pm - GenericInterface LinkAdd operation backend
# Copyright (C) 2016 ArtyCo (Artjoms Petrovs), http://artjoms.lv/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::GenericInterface::Operation::LinkObject::LinkAdd;

use strict;
use warnings;

use Kernel::GenericInterface::Operation::Common;
use Kernel::System::LinkObject;
use Kernel::System::VariableCheck qw(IsStringWithData IsHashRefWithData);

=head1 NAME

Kernel::GenericInterface::Operation::LinkObject::LinkAdd - GenericInterface Link Create Operation backend

=head1 SYNOPSIS

=head1 PUBLIC INTERFACE

=over 4

=cut

=item new()

usually, you want to create an instance of this
by using Kernel::GenericInterface::Operation->new();

=cut

sub new {
    my ( $Type, %Param ) = @_;

    my $Self = {};
    bless( $Self, $Type );

    # check needed objects
    for my $Needed (
        qw( DebuggerObject WebserviceID )
        )
    {
        if ( !$Param{$Needed} ) {
            return {
                Success      => 0,
                ErrorMessage => "Got no $Needed!"
            };
        }

        $Self->{$Needed} = $Param{$Needed};
    }

    # create additional objects
    $Self->{CommonObject} = Kernel::GenericInterface::Operation::Common->new( %{$Self} );
    $Self->{LinkObject}
        = $Kernel::OM->Get('Kernel::System::LinkObject');

    return $Self;
}

=item Run()

Create a new link.

    my $Result = $OperationObject->Run(
        Data => {
            SourceObject => 'Ticket',
            SourceKey    => '321',
            TargetObject => 'Ticket',
            TargetKey    => '12345',
            Type         => 'ParentChild',
            State        => 'Valid',
            UserID       => 1,
        },
    );

    $Result = {
        Success      => 1,                                # 0 or 1
        ErrorMessage => '',                               # In case of an error
        Data         => {
            Result => 1,                                  # 0 or 1 
        },
    };

=cut

sub Run {
    my ( $Self, %Param ) = @_;

    # check needed stuff
    if ( !IsHashRefWithData( $Param{Data} ) ) {
        return $Self->{CommonObject}->ReturnError(
            ErrorCode    => 'LinkAdd.MissingParameter',
            ErrorMessage => "LinkAdd: The request is empty!",
        );
    }



    my $LinkID = $Self->{LinkObject}->LinkAdd(
        %Param,
    );

    if ( !$LinkID ) {
        return $Self->{CommonObject}->ReturnError(
            ErrorCode    => 'LinkAdd.AuthFail',
            ErrorMessage => "LinkAdd: Authorization failing!",
        );
    }

    return {
        Success => 1,
        Data    => {
            Result => $LinkID,
        },
    };
}

1;

=back

=head1 TERMS AND CONDITIONS

This software is part of the OTRS project (L<http://otrs.org/>).

This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (AGPL). If you
did not receive this file, see L<http://www.gnu.org/licenses/agpl.txt>.

=cut
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何通过 OTRS 中的 Web 服务(SOAP 或 REST)将配置项链接/获取到工单 的相关文章

  • 如何在附加的 sqlite 数据库中创建外键?

    我正在尝试创建一个 sqlite3 数据库作为模拟生产环境的测试环境 由于生产的设置方式 表处于多个模式中 我已经在 DBIx Class 中设置了类 使用 schema gt storage gt dbh do将数据库与架构附加在一起 并
  • 什么时候使用Jersey的@Singleton注解?

    我正在开发 RESTful Web 服务 并在阅读泽西岛时文档 https jersey java net documentation latest jaxrs resources html d0e1851我发现了一个注释 Singleto
  • 端点按资源 swagger 注释分组?

    我正在使用 Spring 进行 REST API 开发 我有一些 API 其中有很多端点 当我打开 swagger ui 时 它看起来很拥挤 我刚刚读过this https swagger io docs specification gro
  • Django模型更新或创建具有唯一约束的对象

    有一个模型 class Proxy models Model host models CharField max length 100 port models CharField max length 10 login models Cha
  • 发送变量后的 wsdl 服务响应,php

    我是 SOAP WSDL 函数的新手 我有一位客户从一家从事汽车测试的公司获得了 wsdl 文件 我的客户是他们的分包商 他们告诉我们上传有关车牌 类别等信息 一旦详细信息发送完毕 服务器就会做出成功或失败的响应 请您协助 浏览不同的信息
  • Web 服务响应包含无效的 XML 字符

    我的应用程序正在连接到 Web 服务 rpc encoded 我使用的是 Axis 1 4 当 Web 服务发送响应时 它会发送一个无效字符 然后发送一个异常 http xml apache org axis stackTrace org
  • 是否可以将 RestAngular.setBaseUrl 用于两个 api 访问点?

    是否可以使用具有 2 个不同 API 的 Restangular 来工作 我想拥有setBaseUrl 对彼此而言 只需创建两个或多个 Restangular 服务并根据需要配置它们 然后注入您想要使用的模块 UPDATE 这段代码来自 r
  • 为 NFL api 生成访问令牌

    NFL 有一个 API 服务 link https api nfl com docs getting started index html https api nfl com docs getting started index html
  • 使用 yum 和 pear 安装 php-soap 均失败

    我正在尝试在 Centos 6 4 服务器上安装 PHP 的 SOAP 扩展 我对包管理器 从 CLI 安装包并在 PHP 中配置它们相当不熟悉 我相当有能力管理 php ini 和其他 PHP 配置文件 soap ini 等 我尝试使用以
  • 从 ASP .Net Web 服务访问 MSMQ 时出现权限错误

    我写了一个从消息队列读取的 Web 服务 这在卡西尼号下工作得很好 现在我已经在 IIS 下部署了该服务 当该服务尝试访问队列时 我收到一条错误消息 队列不存在或者您没有足够的权限来执行该操作 我已将 IIS 虚拟目录上的匿名访问用户设置为
  • 如何根据域名更改视图格式

    我想知道是否有任何方法可以根据域名更改相同 Rails 应用程序的视图格式 例如 www domain com gt respond to format html api domain com gt respond to format xm
  • 为什么我的 Apache2::Log 输出用 \n 替换换行符?

    我在 apache2 mod perl 下设置了多个虚拟主机 我用的是ErrorLog指令为每个虚拟主机获取单独的错误日志 仅当我使用 Apache2 Log 时 这才按预期工作 警告 只会记录到常规错误日志中 这样就可以了 最后 但还存在
  • ASMX Web 服务 - 返回带有属性的用户定义的类

    嘿 我正在尝试从 Web 方法返回用户定义的类 该类具有属性和 或方法 给出以下网络方法 WebMethod public List
  • python suds SOAP 请求中的名称空间前缀错误

    我使用 python suds 来实现客户端 并且在发送的 SOAP 标头中得到了错误的命名空间前缀 用于定义由element ref 在 wsdl 中 wsdl 正在引用数据类型 xsd 文件 请参见下文 问题出在函数上GetRecord
  • 如何从 C# 控制器重定向到外部 url

    我使用 C 控制器作为网络服务 在其中我想将用户重定向到外部网址 我该怎么做 Tried System Web HttpContext Current Response Redirect 但没有成功 使用控制器的重定向 http msdn
  • Wiremock:如何匹配没有特定属性的 JSON 请求?

    我正在尝试模拟一个在 POST 中接受 JSON 正文的 API 调用 它有两种可能的响应 如果身体含有SearchCenter属性 回答 A 如果正文不包含SearchCenter 回答B In the 请求匹配 http wiremoc
  • 用于获取随机数动词的 RESTful Web 服务

    如果您创建一个可以返回随机数的 RESTful Web 服务 您应该使用什么动词 我个人的感觉是使用 POST 因为你每次都会创建一个新的随机数 但我听到了一些使用 GET 的令人信服的论据 因为你本质上是在获取随机数 GET也有被缓存的危
  • 根据业务实体(法定名称、业务类别、DNS 域、公司类型)标准化数据[关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我正在尝试根据合法的商业实体名称规范数据和链接记录 我在哪里可以确定法定企业名称以及该公司的一般信息 我将至少拥有以下其中一项 股票代码 DBA 简称
  • 如何在 Perl 脚本中加密或隐藏密码?

    我正在研究 Perl 脚本 它使用Expect http search cpan org dist Expect通过 telnet 登录到远程计算机 不要问 必须使用 telnet 我还根据需要执行 perforce p4 登录操作 并使用
  • 需要将用户名和密码添加到 VB.NET Web 服务客户端中的 SOAP 标头

    我需要查询一个进行基本身份验证的 Web 服务 将用户名和密码放在请求标头中 我的客户端是用 VB NET Visual Basic Express Edition 2010 编写的 我已将 Web 服务添加到服务引用中 它为我自动生成了合

随机推荐