0
votes

I have an Azure Custom Connector to a SOAP API that is configured with SOAP to REST. One of the methods have datetime as input:

I am genereting the DateTime with the following expression:

formatDateTime(addDays(utcNow(), -1), 's')

With the following raw input from Logic Apps, I get datetime format exception

{
"method": "post",
"path": "/MethodWithDates",
"retryPolicy": {
    "type": "None"
},
"body": {
    "MethodWithDates": {
        "timefrom": "2019-03-18T15:59:03",
        "timeto": "2019-03-19T15:59:03"
    }
}

Errormessage from API:

The value '3/18/2019 3:59:03 PM' cannot be parsed as the type 'DateTime'.'

Notice how the datetime format has changed from raw output to recieved in the API. This leads me to believe the custom connector somehow changes the time format.

If I call the same endpoint with SOAP UI with the following SOAP request I get correct response. Notice the Datetime format is same as in RAW input from Logic app:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:MethodWithDates>
         <tem:timefrom>2019-03-18T15:13:31</tem:timefrom>
         <tem:timeto>2019-03-19T15:13:31</tem:timeto>
      </tem:MethodWithDates>
   </soapenv:Body>
</soapenv:Envelope>

Interestingly, this seems only to happen for the "s" format specifier, if I format the value in any other way it is passed through in the format I specify. I still get an error in the API as its a WCF API and it seems to require the "s" format.

2

2 Answers

1
votes

I can reproduce the same error when SOAP service has a Datetime input which I believe is not parsing correctly.

I am able to make this work by changing the input Datetime fields in Soap Service to string.

Non Working SOAP Service code:

public string GetDaysBetweenDates(DateTime timefrom, DateTime timeto)
{
  double value = (timeto - timefrom).TotalDays;
  return string.Format("Difference is: {0}", value);
}

Working WSDL Code

public string GetDaysBetweenDates(string timefrom, string timeto)
{
  DateTime fromdate = DateTime.Parse(timefrom);
  DateTime toDate = DateTime.Parse(timeto);
  double value = (fromdate - toDate).TotalDays;
  return string.Format("Difference is: {0}", value);
}
0
votes

u/KetanChawda-MSFT answer is good enough, if you are able to actually change the webservice, but since this was out of our control on this one we had to do something else.

We created a separate SOAP custom connector, just for this one method with SOAP pass through.

The connector has one method, configured like this, with a default WCF API:

  1. Url - http://hostname/Service1.svc/SoapPassThrough
  2. Add two custom headers: Content-Type text/xml and SOAPAction methodname (ours: http://tempuri.org/IService1/methodname where tempuri is namespace
  3. Set body to {} (Empty JSON Object)

In your logic app, you can then create a variable that contain all of the XML for a standard Soap Request. I Used SOAP UI to create a SOAP request and just pasted in the XML from the generated request. This variable can be used as body in the logic app when you consume the service.

This resource can be helpful for this: https://blogs.msdn.microsoft.com/david_burgs_blog/2018/05/03/friendlier-soap-pass-through-with-logic-app-designer-ux/

From what we have concluded, it seems like the custom connector actually sends a string datatype instead of a datetime. Creating the XML request ourself seems to fix this issue.