Azure Custom Soap Connector SOAP与逻辑应用程序在日期休息



我有一个azure自定义连接器到SOAP API上,该连接器配置为肥皂以休息。其中一种方法将DateTime作为输入:

我正在用以下表达式生成日期时间:

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

使用逻辑应用程序的以下原始输入,我获得了DateTime格式异常

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

API的错误:

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

请注意,DateTime格式如何从API中的原始输出变为收到。这使我相信自定义连接器以某种方式改变了时间格式。

如果我使用SOAP UI调用相同的端点,并带有以下SOAP请求,我会得到正确的响应。请注意,DateTime格式与逻辑应用程序的原始输入相同:

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

有趣的是,如果我以我指定的格式通过任何其他方式将其格式化,这似乎仅对" S"格式指定符进行。我仍然会在API中遇到错误,因为它是WCF API,似乎需要" S"格式。

我可以在SOAP服务具有Datetime输入时可以重现相同的错误。

我能够通过将肥皂服务中的输入Datetime字段更改为string

非工作肥皂服务代码:

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

工作WSDL代码

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

u/ketanchawda-msft答案已经足够好,如果您能够实际更改Web服务,但是由于这是我们对此的控制,我们必须做其他事情。

我们创建了一个单独的SOAP自定义连接器,只是为了通过SOAP通过的一种方法。

该连接器具有一种配置的方法,具有默认的WCF API:

  1. url -http://hostname/service1.svc/soappassthrough
  2. 添加两个自定义标头:content-type text/xml和soapaction方法名称(我们的:http://tempuri.org/iservice1/methodname,tempuri是namepace
  3. 将车身设置为{}(空JSON对象)

在逻辑应用程序中,您可以创建一个包含标准SOAP请求的所有XML的变量。我使用SOAP UI创建了肥皂请求,并从生成的请求中粘贴在XML中。消耗服务时,该变量可以用作逻辑应用中的主体。

此资源可能对此有所帮助:https://blogs.msdn.microsoft.com/david_burgs_blog/2018/05/03/friendlier-soap-pass-pass-pass-pass-pass-pash-with-with-with-with-with-with-logic-app-designer-ux/

根据我们的结论,自定义连接器实际上是发送字符串数据类型而不是DateTime。创建XML请求我们自己似乎可以解决此问题。

最新更新