Azure自定义SOAP连接器SOAP到REST,日期时出现Logic Apps错误 [英] Azure Custom SOAP connector SOAP to REST with Logic Apps error on Date

查看:85
本文介绍了Azure自定义SOAP连接器SOAP到REST,日期时出现Logic Apps错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


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



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

   formatDateTime    addDays   < span class ="pln"style ="margin:0px; padding:0px; border:0px; font-style:inherit; font-variant:inherit; font-weight:inherit; line-height:inherit; font-family:inherit ; vertical-align:baseline; color:#303336"> utcNow  (),     -    1  ),   's'   



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

   {  
"方法" " post"
" path" " / GetDataBetweenDates"
" retryPolicy" {
" type" "无"
},
" body" {
" getDataBetweenDates" {
" timefrom" " 2019-03-18T15:59:03"
" timeto" " 2019-03-19T15:59:03"
}
}



来自API的错误消息:

     '3/18/2019 3:59:03 PM' 无法解析  as  类型 '日期时间'  '  



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



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

 

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

解决方案

< blockquote>

你好krister.karto,


我尝试了同样的事情,我能够在我身边重新解决这个问题。我会检查一下这个问题,并会回复你。


敬请期待!


更新:


我可以通过将WSDL中的输入 Datetime 字段更改为字符串来完成此工作。


非工作WDSL代码:

 public string GetDaysBetweenDates(DateTime timefrom,DateTime timeto)
{
double value =(timeto - timefrom).TotalDays;
返回string.Format("差值为:{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);
}




&NBSP;

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": "/GetDataBetweenDates",
"retryPolicy": {
    "type": "None"
},
"body": {
    "getDataBetweenDates": {
        "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:GetDataBetweenDates> <tem:timefrom>2019-03-18T15:13:31</tem:timefrom> <tem:timeto>2019-03-19T15:13:31</tem:timeto> </tem:GetDataBetweenDates> </soapenv:Body> </soapenv:Envelope>

解决方案

Hello krister.karto,

I tried the same and I am able to repro the issue at my side. I will check this and will get back to you on this.

Stay Tuned!

Update:

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

Non Working WDSL 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);
}


 


这篇关于Azure自定义SOAP连接器SOAP到REST,日期时出现Logic Apps错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆