因此,我试图让Azure Logic Apps监视我的电子邮件收件箱,然后调用基于某些条件设置的Web服务。通过从本地计算机调用Web服务,我已经成功部署和测试了Web服务。但是,在测试我创建的调用Web服务的azure函数时,我仅收到“ 500 Internal Server Error”,没有更多信息。
逻辑应用程序的代码如下:
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("message", "Test Ticket via Run");
string methodName = "CreateTicket";
string soapStr =
@"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soap:Body>
<{0} xmlns=""http://tempuri.org/"">
{1}
</{0}>
</soap:Body>
</soap:Envelope>";
string postValues = "";
foreach (var param in parameters)
{
postValues += string.Format("<{0}>{1}</{0}>", param.Key, param.Value);
}
soapStr = string.Format(soapStr, methodName, postValues);
HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(<HttpsURL>);
webreq.Headers.Add("SOAPAction", @"http://tempuri.org/<ServiceName>/CreateTicket");
webreq.ContentType = "text/xml;charset=\"utf-8\"";
webreq.Accept = "text/xml";
webreq.Method = "POST";
using (Stream stream = webreq.GetRequestStream())
{
using (StreamWriter sWriter = new StreamWriter(stream))
{
sWriter.Write(soapStr);
}
}
try
{
using (StreamReader responseReader = new StreamReader(webreq.GetResponse().GetResponseStream()))
{
string response = responseReader.ReadToEnd();
return (ActionResult)new OkObjectResult("Message Sent Successfully");
}
}
catch (Exception e)
{
Console.WriteLine(e);
return new BadRequestObjectResult(e.InnerException);
}
}
我尝试过的东西:
关闭自定义错误:
<system.web>
<customErrors mode="Off"/>
</system.web>
运输绑定:
<webHttpBinding>
<binding name="WebConfiguration" maxBufferSize="65536" maxReceivedMessageSize="2000000000" transferMode="Streamed">
<security mode="Transport"/>
</binding>
</webHttpBinding>
详细的错误(尝试获取500条异常消息)
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
</system.webServer>
我也尝试过将具有服务器证书的集成帐户与Azure上的资源组相关联,但这也没有任何区别。为我托管的Web服务启用了失败的请求跟踪,但是未生成任何日志。
基本上,我已经在本地使用该Web服务的标注,但是我无法让Logic Apps成功调用它,也无法获取任何有关失败原因的有用信息。我的问题如下:
1)在服务器和/或Azure上获取更详细的错误消息的最佳方法是什么? 2)是否需要在Azure上启用特殊权限才能与外部API进行通信? 3)这是让Logic Apps调用端点的正确方法吗?
感谢您的帮助!让我知道是否需要更多信息!
〜乔什