【问题标题】:How to create an otrs ticket using a soap request如何使用肥皂请求创建 otrs 票
【发布时间】:2013-05-19 06:16:15
【问题描述】:

缺乏关于这个主题的文档,再加上我在各个方面都在努力学习曲线,这让我很困惑从哪里开始。如果可能的话,我需要使用 C# 来完成这项工作。对于这个问题的含糊之处,我深表歉意,但我真的迷路了。我希望获得指向综合指南/参考的链接。

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

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

  • 我能否在不将 Web 服务添加为 Visual Studio 中的服务引用的情况下发送一个肥皂请求?鉴于我之前遇到的问题,我不能那样做。我是否只需构建soap 请求字符串并将其写入Web 请求的数据流,以http://domain/rpc.pl 作为uri?

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

        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();
    

即使你能提供的只是从哪里开始,它也会帮助我知道如何继续,因为我很难过。

【问题讨论】:

    标签: c# .net soap webrequest otrs


    【解决方案1】:

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

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

    【讨论】:

    • 是否有任何关于如何通过 .Net 执行此操作的文档?我什么都找不到。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多