【发布时间】:2015-11-13 16:03:30
【问题描述】:
我正在使用 BizTalk 2013 R1 通过 http 从网站下载二进制 blob。当我收到 blob 时,我只是将消息存储在 XmlDocument 中。但是,有时该站点会返回我想要的文件,有时它会以包含错误信息的 http 页面的形式返回错误。
我试图通过在我的返回消息上运行 xpath 来对此进行筛选。特别是,我正在寻找 /html/head/title 中出现的“错误”。我的想法是,如果它找到该文本,或者它完全解析为 Xml,我就会得到一个错误,我应该抛出一个异常。
但实际上,当我尝试运行该 xpath 时,我得到了这个:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 128.30.52.100:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenAndPush(Uri uri)
at System.Xml.XmlTextReaderImpl.PushExternalEntityOrSubset(String publicId, String systemId, Uri baseUri, String entityName)
at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset(String systemId, String publicId)
at System.Xml.DtdParser.ParseExternalSubset()
at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
at System.Xml.DtdParser.System.Xml.IDtdParser.ParseInternalDtd(IDtdParserAdapter adapter, Boolean saveInternalSubset)
at System.Xml.XmlTextReaderImpl.ParseDtd()
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(TextReader txtReader)
at Microsoft.XLANGs.Core.Value.GetXmlDocument()
at Microsoft.XLANGs.Core.Value.RetrieveAs(Type t)
at Microsoft.XLANGs.Core.Part.get_XmlDocument()
at Microsoft.XLANGs.Core.Part.XPathLoad(Part sourcePart, String xpath, Type dstType)
at QTC.BizTalk.LSPDispatchIMNL.SendCommercialInvoice.segment3(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
看到这一点,这是有道理的,因为我相信 BizTalk 在后台将消息作为流处理。突然间,在 XmlDocuments 中隐藏二进制文件的技术变得有意义了。所以也许我的测试本身导致了不同的问题。
不过,我希望能够以某种方式验证我的回复。我可以做些什么来分析我从网站获得的响应,而不导致消息加载?上下文属性中没有什么有用的东西,所以我很好奇我能做什么。
【问题讨论】:
-
不能依靠下载响应的HTTP状态码来识别错误吗?
-
我猜你是在编排中这样做的?您采用什么方法来调用 Web 服务?通过发送端口或表达式形状请求?它是您从其请求数据的 RESTful 服务吗?
-
@Gruff 这是在编排中完成的,是的。它配置为使用发送端口,并且发送端口使用 BizTalk 2013 WCF-WebHttp 与 REST 服务进行交互。
-
@Filburt 遗憾的是,在跟踪消息中查看消息时,似乎即使服务返回错误页面,InboundHttpStatusCode 和 InboundHttpStatusDescription 上下文属性都是“OK”,尽管返回消息被打包错误信息。
-
可能是响应长度/消息大小阈值来区分数据和错误消息?
标签: stream blob biztalk biztalk-2013