Azure自定义SOAP连接器SOAP到REST,日期时出现Logic Apps错误

问题描述 投票:0回答:2

我有一个Azure自定义连接器,用于配置SOAP到REST的SOAP API。其中一种方法将datetime作为输入:

我使用以下表达式生成DateTime:

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

使用Logic Apps的以下原始输入,我得到日期时间格式异常

{
"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'.'

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

如果我使用SOAP UI使用以下SOAP请求调用相同的端点,我会得到正确的响应。请注意,日期时间格式与Logic应用程序的RAW输入格式相同:

<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”格式。

azure soap azure-logic-apps
2个回答
1
投票

当SOAP服务有Datetime输入时,我可以重现相同的错误,我相信它不能正确解析。

我可以通过将Soap Service中的输入Datetime字段更改为string来完成此工作。

非工作SOAP服务代码:

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

0
投票

你/ KetanChawda-MSFT的回答是好的,如果你能够真正改变网络服务,但由于这是我们无法控制的,我们不得不做其他事情。

我们创建了一个单独的SOAP自定义连接器,仅适用于使用SOAP传递的这一个方法。

连接器有一个方法,配置如下,使用默认的WCF API:

  1. 网址 - http://hostname/Service1.svc/SoapPassThrough
  2. 添加两个自定义标头:Content-Type text / xml和SOAPAction methodname(我们的:http://tempuri.org/IService1/methodname,其中tempuri是命名空间
  3. 将body设置为{}(空JSON对象)

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

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

根据我们的结论,似乎自定义连接器实际上发送字符串数据类型而不是日期时间。自己创建XML请求似乎解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.