Azure 函数和 Soap:无法访问信封:无法从给定来源创建信封:com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl

Azure Function and Soap: Could not access envelope: Unable to create envelope from given source: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl

我目前正在尝试从我的 Azure 函数调用 SOAP 服务,但出现以下错误:

但是,我能够成功处理来自 .NET 应用程序的请求。

HTTP Status 500 - Request processing failed; nested exception is org.springframework.ws.soap.saaj.SaajSoapEnvelopeException: Could not access envelope: Unable to create envelope from given source: ; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:

这是一个第三方服务,它是用Java写的。我不知道它是如何部署的,但是是的,因为它是从控制台应用程序运行的,所以我觉得该服务没有任何问题:

string soapEndPoint = "https://<<url>>/endpoints";
string serviceOperationName = "SendLotListService";

SendLotListRequest sendLotListRequest = new SendLotListRequest();
SendLotListResponse sendLotListResponse = null;
sendLotListRequest.LotList = lotRecords.ToArray();

System.ServiceModel.BasicHttpsBinding binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
binding.BypassProxyOnLocal = true;

EndpointAddress address = new EndpointAddress(soapEndPoint);

using (SendLotListServiceClient sendLotListServiceClient = new SendLotListServiceClient(binding, address))
{
    OperationDescription sendLotListOperation = new OperationDescription(serviceOperationName, new ContractDescription(serviceOperationName));
    sendLotListOperation.Messages.Add(new MessageDescription(serviceOperationName, MessageDirection.Input));
    sendLotListServiceClient.Endpoint.Contract.Operations.Add(sendLotListOperation);
    sendLotListServiceClient.Open();
    sendLotListResponse = sendLotListServiceClient.SendLotList(sendLotListRequest);
}

任何人都可以提出这里可能有什么问题吗?

在此先感谢您的帮助

MSDN 上有一个类似的 issue,MSFT 的回复解释了这种情况,对于没有发送回任何数据的请求有 230 秒的超时,请参见下文。

After some investigation, I see what's going on. There is a 230 second (i.e. a little less than 4 mins) timeout for requests that are not sending any data back. After that, the client gets the 500 you saw, even though in reality the request is allowed to continue server side.

If you are expecting to do server side processing that lasts this long, I would suggest using an alternate flow that works in a more async way. i.e. let the user queue up the report generation, and then allow them to download it when it's complete. Or as an alternative, you could upload the result to blob storage, and have it be available there for pickup.

I would argue that even without this timeout, the majority of users would themselves give up on the request if they saw it spinning in their browser for that long. So the async pattern makes for a better user experience.

希望对您有所帮助。

感谢 Peter 和 vivasaayi 的评论,我在这些方向上进行了调查。

但是,由于我无法控制服务器上的 spring 框架,所以我无法升级它。另外,就执行时间而言,我的请求持续时间相对较短,因此超时也不是问题。

我可以通过在我的 .NET 客户端中添加以下代码行来修复它

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;