I have been working on a project to connect to our time reporting vendor's SOAP service and get a report weekly (REST doesn't offer function call for getting the desired report). They have only given us the WSDL which has not been helpful: https://secure.entertimeonline.com/ta/padnos.wsdl and https://secure.saashr.com/ta/PADNOS.soap
I have added the service reference to my solution and generated the proxy class, but each time I try to fetch the data, I get errors saying "Response is not well-formed XML." and "data at the root level is invalid. Line 1, position 1."
This is my first foray into consuming a web service and I cannot find any helpful material.
private void btnGo_Click(object sender, EventArgs e)
{
// service reference
// runReportByName
TSPHoursWorked.ServiceReference1.runReport_ByNameType rptName = new ServiceReference1.runReport_ByNameType();
rptName.version = 1;
rptName.reportCategory = "Calculated Time";
rptName.reportName = "Calculated Time By Entry";
rptName.reportSavedName = "DailyHoursWorked";
rptName.outputType = TSPHoursWorked.ServiceReference1.runReport_ByNameTypeOutputType.XML;
TSPHoursWorked.ServiceReference1.SaaSHRClient soap = new ServiceReference1.SaaSHRClient();
soap.ClientCredentials.UserName.UserName = "username";
soap.ClientCredentials.UserName.Password = "password";
var requestInterceptor = new InspectorBehavior();
soap.Endpoint.Behaviors.Add(requestInterceptor);
soap.runReport_ByName(rptName);
string requestXML = requestInterceptor.LastRequestXML;
outputText.Text = requestXML;
string responseXML = requestInterceptor.LastResponseXML;
outputText.Text += responseXML;
}
public class InspectorBehavior : IEndpointBehavior
{
public string LastRequestXML
{
get
{
return myMessageInspector.LastRequestXML;
}
}
public string LastResponseXML
{
get
{
return myMessageInspector.LastResponseXML;
}
}
private MyMessageInspector myMessageInspector = new MyMessageInspector();
public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(myMessageInspector);
}
}
public class MyMessageInspector : IClientMessageInspector
{
public string LastRequestXML { get; private set; }
public string LastResponseXML { get; private set; }
public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
{
LastResponseXML = reply.ToString();
}
public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel)
{
LastRequestXML = request.ToString();
return request;
}
}
I would just like help simply connecting to their web service, and get the report and bulk insert into SQL server. Could anyone set me on the right path?
EDIT:
I've installed SoapUI and there are no URLs listed under the soap operation "Actions" column:
The problem was with our middle-man vendor to Kronos not having any technical knowledge. After a few weeks and finally getting in touch with Kronos, I was informed that:
Then you will be able to call the RESTful service. I hope this helps someone because our vendor wasted 2 weeks of our time