gpt4 book ai didi

c# - 如何使用 soap 请求创建 otrs 票证

转载 作者:行者123 更新时间:2023-11-30 16:17:52 25 4
gpt4 key购买 nike

缺乏关于这个主题的文档,再加上我在各个方面都在学习曲线上苦苦挣扎,这让我真的不知道从哪里开始。如果可能的话,我需要使用 C# 来完成这项工作。对于这个问题的含糊不清,我深表歉意,但我真的迷路了。我想要综合指南/引用资料的链接。

在我努力完成这项工作的过程中,我遇到了以下问题:

  • 我使用 otrs gui 创建了一个网络服务,使用 CreateTicket 操作,但通过 C# 向我选择的命名空间发出的请求返回 404(未找到)。当我尝试使用该命名空间添加服务引用或 Web 引用时,我遇到了同样的错误。但是,当我将该 namespace 作为 url 插入浏览器时,它会显示“customer.pl”。

  • 我可以在不将 Web 服务添加为 visual studio 中的服务引用的情况下发送 soap 请求吗?考虑到我之前遇到的问题,我不能那样做。我是否可以构建 soap 请求字符串并将其写入以 http://domain/rpc.pl 作为 uri 的网络请求数据流?

  • 如果上一个问题的答案是肯定的...当尝试下面的代码段时,我在最后一行收到内部服务器错误 (500)。然而, header 看起来像 SOAP header ,这让我感到困惑,因为我没想到它会走那么远。

        var document = new StringBuilder();

    document.Append("<UserLogin>some user login</UserLogin>");
    document.Append("<Password>some password</Password> ");
    document.Append("<Ticket>");
    document.Append("<Title>some title</Title> ");
    document.Append("<CustomerUser>some customer user login</CustomerUser>");
    document.Append("<Queue>some queue</Queue>");
    document.Append("<State>some state</State>");
    document.Append("<Priority>some priority</Priority>");
    document.Append("</Ticket>");
    document.Append("<Article>");
    document.Append("<Subject>some subject</Subject>");
    document.Append("<Body>some body</Body>");
    document.Append("<ContentType>text/plain; charset=utf8</ContentType>");
    document.Append("</Article>");

    //var uri = new Uri("http://domain/injest");
    var uri = new Uri("http://domain/rpc.pl");
    var httpWebReq = (HttpWebRequest)WebRequest.Create(uri);
    var bytePostData = Encoding.UTF8.GetBytes(document.ToString());
    httpWebReq.Timeout = 5 * 1000;
    httpWebReq.Method = "POST";
    httpWebReq.ContentLength = bytePostData.Length;
    httpWebReq.ContentType = "text/xml;charset=utf-8";
    //httpWebReq.TransferEncoding=
    //httpWebReq.ContentType = "application/xml";
    //httpWebReq.Accept = "application/xml";
    var dataStream = httpWebReq.GetRequestStream();

    dataStream.Write(bytePostData, 0, bytePostData.Length);
    dataStream.Close();
    var httpWebResponse = (HttpWebResponse)httpWebReq.GetResponse();

即使您能提供的只是从哪里开始,这也会帮助我知道如何继续,因为我很困惑。

最佳答案

您正在使用 rpc.pl 端点,它是“旧”RPC 样式接口(interface)的一部分。您提到您通过 GUI 添加了 Web 服务,这意味着您正在使用“新的”通用接口(interface),这在 .Net 中确实要容易得多。

端点的地址是 /otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector 或您在管理部分中调用的任何网络服务。

关于c# - 如何使用 soap 请求创建 otrs 票证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16721523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com