How can I communicate with the Kronos API? - c#

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_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.

You can communicate with the Kronos API using XML POST requests.
The WFC v5.0 Developer's Toolkit Programmer's Guide1 provides a general guide for communicating with the Kronos API in various languages. The first chapter covers the XML API, which is how all API requests will be sent.
Logon Request
A standard XML logon request for Kronos WFC. 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_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.
<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).
Your method of sending POST requests may vary depending on your language. However, the XML request format and API entry point (<ServerName>/wfc/XmlService) should apply to all languages.
Below is an example Python 3 script for sending a Kronos logon request:
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. However, I recommend looking into a more up-to-date XML or HTTP requests library specific to whatever language you are using.
Helpful Resources
Workforce Timekeeper v8.0.16 Developer's Toolkit Reference Guide (requires login)
WFC v5.0 Developer's Toolkit Programmer's Guide
Documentation and Service Packs for Kronos Products (requires login)
WFC-API.js - JavaScript for sending XML requests to WFC API
TimeCardView - Open source web UI to the Kronos API
Kronos Community Forums
Footnotes:
1: The quoted documentation was originally written for Kronos WFC 5.0 (API 1.0). While later versions should use the same API, I cannot guarantee accuracy for other versions. (See XML API version 6.3 to 8.0 upgrade)

You get that with the brower because the Kronos server only support POST requests and the Browser is issuing a GET Request. The reason for that is because Kronos requires an XML in the body and the POST is the most adecuate method to do so.
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:
HttpWebRequest reqFp = (HttpWebRequest)HttpWebRequest.Create(KronosServerUrl);
reqFp.Method = "POST";
reqFp.ContentType = "text/xml";
Note how the ContentType is also set to text/xml.

Also,you need to make sure you have XML API access check in the Function Access Profile in Kronos.

Not only XML Access but the user also have to have remote api access enabled

Related

Return XML when consuming a secure web service

I am currently trying to consume a generated report as a webservice to integrate some data into our system. Because the service itself is generated, the response can change frequently as things are added to it. While the endpoint and response may change, the request body will always be the same (taken from soapui):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Execute_Report>
</Execute_Report>
</soapenv:Body>
</soapenv:Envelope>
I'm trying to figure out a way to make the above request for any endpoint (different reports) and allow for changes in the response. Ideally, I want to just return the raw XML of the response as I can allow for change easier with how I handle the XML if I'm not being tied to a data contract.
It is also worth noting that the service uses WS-Security and a Username/Password is passed as part of the request.
I've used WCF and the files generated from svcutil work great when I don't expect the service to change frequently. However because these webservices are generated change is expected, and if I can get away from it, I don't want to be at the mercy of re-generating a new file with svcutil whenever things change, or have to generate a file (and maintain) for all the different generated webservices.
At the end of the day the question is: How do I consume a webservice and return the raw XML while still being able to apply WS-Security to the request?
I kept searching around and found this answer:
.NET client authentication and SOAP credential headers for a CXF web service
This allowed me to do what I was after.

Call Amazon Web Services to submit xml file throws WebException The remote name could not be resolved https

I am building a tool to translate some CSV files into XML files and then upload them via the Amazon Web Services to upload products to a market place store.
I am testing the tool and the CSV to XML translation is fine and valid xml is created but I am having trouble calling the AWS services and sending the files. At the moment I can't even succesfully call the AWS service let alone try sending a file.
When I create a HttpWebRequest and try and call the method "GetRequestStream" I get a WebException:
"The remote name could not be resolved https"
There is no inner exception or anything useful to help me.
The properties I have set to the webRequest are
Address - https://mws.amazonservices.co.uk/Action=SubmitFeed&MarketplaceIdList.Id.1=MarketPlaceId&Merchant .................
Headers -
+ Headers {User-Agent: Funkyrox/1.0 (Language=C#; =)
Content-Type: application/octet-stream
Content-MD5: 4BDPHUko1//iVAdb5wr/Vw==
Host: mws.amazonservices.co.uk
} System.Net.WebHeaderCollection
Host -
"mws.amazonservices.co.uk"
Method - POST
RequestUri -
https://mws.amazonservices.co.uk/Action=SubmitFeed&MarketplaceIdList.Id.1=MarketPlaceId&Merchant......................
There are others if needed as well.
When I ping https://mws.amazonservices.co.uk I get a response so I think the it's valid
I can't seem to find really useful examples of how to do this. I downloaded an C# tool from Amazon and have used a lot of the code in there but can't see how to call the service correctly.
Anyone with any ideas?

Add Web Service Reference fails

I'm trying to connect a SAP soap provider with a C# program...
#Edit: SAP on it's non-public webservice provider, prompts for user and password (before anything)
Using the info here:
I came to the webservice I have to attach to, and when user/password prompted, I've placed it. However I think I've written the password wrong (See EDIT II down below), because the soap response is this one:
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
- <soap:Body>
- <soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>No binding data for configuration key: "005056AA63891ED480C5CC2F714805E3"</faultstring>
- <detail xmlns:slibfault="http://xml.sap.com/2005/11/esi/slib/fault/">
<slibfault:timestamp>Tue, 15 Jul 2014 16:01:21 GMT</slibfault:timestamp>
- <slibfault:exception>
<slibfault:text>No binding data for configuration key: "005056AA63891ED480C5CC2F714805E3"</slibfault:text>
<slibfault:position program="CL_SRT_WSP_WSDL_HANDLER=======CP" include="CL_SRT_WSP_WSDL_HANDLER=======CM00K" line="82" />
</slibfault:exception>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Now, User and Password aren't prompted, as if a "Remind My Password" checkbox were checked.
Is there any way to refresh the "Visual Studio WebService cache" or something?
#EDIT II: I've tried twice now (by adding it to another project with the same results) and it's not problem that the passwd has been miswritten, the pass is correct, but the reference builder keeps showing this.
WebServices Found at this URL:
There was an error downloading 'http://fooserver:8000/sap/bc/srt/wsdl/srvc_005056AA63891ED480C5CC2F714805E3/wsdl11/allinone/ws_policy/document?sap-client=400/_vti_bin/ListData.svc/$metadata'.
The request failed with the error message:
--
<soap:Envelope xmlns:soap="http://s
Any Ideas?
When this response is the one you receive from SAP, it means the service exposed has been deprecated.
I cannot explain what is happening from the SAP side, (since I'm a C# dev), but What I do can tell you is that the SAP side is intentionally (manual abap developer handling) not expecting further communications from clients.
So... ask your ABAPer on your SAP side, he may have done something with the service you where trying to connect to, since it's no longer available.
You can also verify that by going to the wsdl page "manually" by placing it in the browser. You'll see the same XML response.
#Icing-on-the-cake Edit: If you encounter the issue that credentials is somewhat stored/cached by .Net, simply
go to the Solution Panel,
left click on the project on which you tried to add the reference
and select unload project.
Afterwards repeat that but to Load that same project.
That will "refresh" the credentials "stored".

Web API response xml language

I am having this simple POST url to which my clients will send a POST request.
http://mydomain.com/requests/request
POST Data:
<Request>
<OrderId>1E008921</OrderId>
<OrderName>MC1</OrderName>
</Request>
to which I respond by sending back them a XML
<SRequest>
<RequestedBy>Client 1 </RequestedBy>
<RequestName>Test Name</RequestName>
<RequestStatus>Success</RequestStatus>
<SRequest>
Now client wants the above XML in a different language (say French)
How to handle this ? How to send the response language preference in Web API ? specially with the POST scenario like this ? (Append a language string ? or what is the best practices ?)
I suggest you either include it in URL: http://mydomain.com/fr/requests/request or use HTTP header like Accept-Language. You could read more in the answer to: Good way to changing language resources dynamically by request

Https Communication to Java Server with Dotnet Client

I need to send financial messages(transactions) to a bank with the help of HTTPS communication. Bank server is written on Java while my application is in .Net.
Following are only details I received from their side:
Https request:
• The entire ISO request for https should be sent as an attachment to the following
servlet:
https:///Servlet/IBSOtherVendorRequestServlet
What are other components or documents required from their side and which namespace of .Net can I use for this communication?
Kindly help me on how to proceed.
You have to know how to query the servlet : SOAP ? REST ? what are the parameters and which method should be used ? result in plain text, XML or JSON ?
It looks like you have to POST a request to this Servlet. You have to know what is an "entire ISO request" then POST it to this url using HttpClient or HttpWebRequest. It will probably look like this : Upload files with HTTPWebrequest (multipart/form-data)

Categories

Resources