简体   繁体   English

如何与 Kronos API 通信?

[英]How can I communicate with the Kronos API?

I have a Kronos entry point http://kronos../wfc/XmlService that I should be able to access however when I open it in the brower the response is:我有一个Kronos入口点http://kronos../wfc/XmlService我应该可以访问但是当我在浏览器中打开它时,响应是:

<Kronos_WFC>
<Response Status="Failure" ErrorCode="1332" Message="WFP-01110 The MIME type of the request is invalid. Type Found: . Valid types: text/xml, application/xml."></Response>
</Kronos_WFC>

What should I do to use the web services?我应该怎么做才能使用网络服务?

By the way, I'm using C# to communicate with the server.顺便说一下,我使用 C# 与服务器进行通信。

You can communicate with the Kronos API using XML POST requests.您可以使用 XML POST 请求与 Kronos API 通信。

The WFC v5.0 Developer's Toolkit Programmer's Guide 1 provides a general guide for communicating with the Kronos API in various languages. WFC v5.0 Developer's Toolkit Programmer's Guide 1提供了使用各种语言与 Kronos API 进行通信的通用指南。 The first chapter covers the XML API, which is how all API requests will be sent.第一章介绍了 XML API,即所有 API 请求的发送方式。

Logon Request 登录请求

A standard XML logon request for Kronos WFC. Kronos WFC 的标准 XML 登录请求。 This must be sent first before any other requests.这必须在任何其他请求之前首先发送。

<Kronos_WFC version="1.0">
  <Request Object="System" Action="Logon" Username="ValidUsername" Password="ValidPassword"/>
</Kronos_WFC>

Response:回复:

<Kronos_WFC version="1.0" TimeStamp="11/15/2017 3:35PM GMT-05:00">
    <Response Status="Success" Timeout="1800" PersonKey="123456" Object="System" Username="ValidUsername" Action="Logon" PersonNumber="112233">
    </Response>
</Kronos_WFC>

Logoff Request注销请求

This logoff request will end your active Kronos session.此注销请求将结束您的活动 Kronos 会话。

<Kronos_WFC version="1.0">
  <Request Object="System" Action="Logoff"/>
</Kronos_WFC>

Pay Period Total Request支付期间总请求

This request loads the Pay Period Total for employee 12345 between October 20th 2017 and October 27th 2017.此请求在 2017 年 10 月 20 日至 2017 年 10 月 27 日之间加载员工12345的工资期总计。

<Kronos_WFC version="1.0">
  <Request Action="Load">
    <Timesheet>
      <Employee>
        <PersonIdentity PersonNumber="12345"/>
      </Employee>
      <Period>
        <TimeFramePeriod PeriodDateSpan="10/20/2017 - 10/27/2017"/>
      </Period>
    </Timesheet>
  </Request>
</Kronos_WFC>

A full list of Kronos API tags can be found in the Workforce Timekeeping Developer Toolkit Reference Guide ( requires login ).可以在Workforce Timekeeping Developer Toolkit Reference Guide需要登录)中找到 Kronos API 标签的完整列表。


Your method of sending POST requests may vary depending on your language.您发送 POST 请求的方法可能因您的语言而异。 However, the XML request format and API entry point ( <ServerName>/wfc/XmlService ) should apply to all languages.但是,XML 请求格式和 API 入口点 ( <ServerName>/wfc/XmlService ) 应适用于所有语言。

Below is an example Python 3 script for sending a Kronos logon request:以下是用于发送 Kronos 登录请求的 Python 3 脚本示例:

import requests

url = "http://localhost/wfc/XmlService"
headers = {'Content-Type': 'text/xml'}
data = """<Kronos_WFC version = "1.0">
              <Request Object="System" Action="Logon" Username="SomeUsername" Password="SomePassword"/>
          </Kronos_WFC>"""

# Login to Kronos and print response
session = requests.Session()  # preserve login cookies across requests
response = session.post(url, data=data, headers=headers)
print(response.text)

Chapter 2 of the WFC Developer's Toolkit Programmer's Guide includes examples for sending XML requests in Java and Visual Basic . WFC 开发人员工具包程序员指南的第 2 章包括在JavaVisual Basic 中发送 XML 请求的示例。 However, I recommend looking into a more up-to-date XML or HTTP requests library specific to whatever language you are using.但是,我建议查看特定于您使用的任何语言的更新的 XML 或 HTTP 请求库。


Helpful Resources有用的资源

Footnotes:脚注:

1 : The quoted documentation was originally written for Kronos WFC 5.0 (API 1.0). 1引用的文档最初是为 Kronos WFC 5.0 (API 1.0) 编写的。 While later versions should use the same API, I cannot guarantee accuracy for other versions.虽然以后的版本应该使用相同的 API,但我不能保证其他版本的准确性。 (See XML API version 6.3 to 8.0 upgrade ) (参见XML API 版本 6.3 到 8.0 升级

You get that with the brower because the Kronos server only support POST requests and the Browser is issuing a GET Request.您可以通过浏览器实现这一点,因为 Kronos 服务器仅支持 POST 请求,而浏览器正在发出 GET 请求。 The reason for that is because Kronos requires an XML in the body and the POST is the most adecuate method to do so.这样做的原因是因为 Kronos 需要正文中的 XML,而 POST 是最合适的方法。

The way to access the Kronos XML API, is making a WebRequest to the URL you have with the Method set to POST like this:访问 Kronos XML API 的方法是向您拥有的 URL 发出WebRequest ,方法设置为 POST,如下所示:

HttpWebRequest reqFp = (HttpWebRequest)HttpWebRequest.Create(KronosServerUrl);
reqFp.Method = "POST";
reqFp.ContentType = "text/xml";

Note how the ContentType is also set to text/xml.请注意 ContentType 如何也设置为 text/xml。

此外,您需要确保在 Kronos 的函数访问配置文件中进行了 XML API 访问检查。

不仅 XML 访问,而且用户还必须启用远程 api 访问

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让 Azure 中的 API 与服务通信? - How can I make my API in Azure communicate with a service? 如何在插件之间进行通信? - How can I communicate between plugins? 我可以使用Microsoft Lync API与Communicator 2007/2007 R2进行通信吗? - Can I use the Microsoft Lync API to communicate with Communicator 2007/2007 R2? 如何与WPF用户控件中托管的Delphi窗口通信? - How can I communicate with a Delphi window hosted in a WPF User Control? 如何使用C#与Chrome(Chrome扩展程序)进行通信? - How Can I communicate with Chrome(Chrome Extension) using C#? 如何通过C#应用程序中的PPP连接进行通信? - How can I communicate over a PPP connection in a C# application? 如何在Windows窗体应用程序和WebBrowser控件之间进行通信 - How can I communicate between a windows forms application and a WebBrowser control C# 如何在 winfirms 应用程序和 unity android 应用程序之间进行通信? - C# How can I communicate between winfirms app and unity android app? 如何使用缺少CA的客户端证书与外部Web服务通信? - How can I use a client certificate with a missing CA to communicate with a external Web service? 如何从 1 个脚本公开“enemyDamage”integer,与另一个脚本通信? - How can I make a public “enemyDamage” integer from 1 script, communicate with another script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM