我想使Web API接收来自外部SOAP服务的请求。
SOAP服务的工作方式:当我向外部服务发送请求时,我还提供了一个回调URL,该服务将在该URL上向我发送响应。
我想在Asp.net Core WebAPI中做到这一点。这就是我所做的。
我创建了一个WebAPI控制器来获取响应。
[Route("[controller]")]
[ApiController]
[Authorize]
public class RewardsController : ControllerBase
{
[HttpGet]
[Route("/api/B2CListener")]
public ActionResult GetData(string document)
{
return Ok();
}
}
当外部服务发送给我响应时,我得到了错误(从Logging中提取)405方法不允许。我的应用程序可以从外部服务获得响应,但是由于不允许的方法而无法在我的服务中获得响应。我尝试了HttpPost
,HttpGet
,HttpPut
,但没有任何效果。任何帮助都将不胜感激。
日志记录:这是捕获的日志。
请求
http 10.117.8.132:801/api/B2CListener/ <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><res:ResultMsg xmlns:res="http://cps.huawei.com/cpsinterface/result"><![CDATA[<?xml version="1.0" encoding="UTF-8"?><Result><ResultParameters><ResultParameter><Key>FailedReason</Key><Value>Failed to match a reason type because the Identity Subtype factor of the credit party does not match.</Value></ResultParameter></ResultParameters><ResultCode>2005</ResultCode><ResultType>0</ResultType><OriginatorConversationID>SX20130129210023</OriginatorConversationID><ResultDesc>Can not match reason type.</ResultDesc><TransactionID>000000000000</TransactionID><ConversationID>AG_20130AAS2</ConversationID></Result>]]></res:ResultMsg></soapenv:Body></soapenv:Envelope>
响应
405:
我已使用middleware
使用RequestResponse日志记录>
我想使Web API接收来自外部SOAP服务的请求。 SOAP服务的工作方式:当我向外部服务发送请求时,我还会提供一个回调URL,服务将在该URL上到达...
错误405的原因是由于SOAP请求始终为HttpPost
,并且由于请求失败而在控制器上错误地添加了[Authorize]
标记。