调用 Web 服务的过程中,在期望的时间内未返回响应时,后续发生的情况由业务操作的几个设置来控制。(请注意,这也与非 SOAP 简单 HTTP 调用等有关)

 

3 个主要设置为:

  • 响应超时
  • 指定从远程 Web 服务器获取响应的超时时间。

  • 重试间隔
  • 尝试与 Ensemble 之外的目标进行连接之间等待的秒数。

  • 故障超时
  • 尝试与 Ensemble 之外的目标保持连接的总秒数。 经过此秒数时间后,业务操作将丢弃消息数据并返回错误代码。

     

    归纳一下就是这样:

    我们将等待 Web 服务器的响应,时间为“响应超时”所用的时间。 如果此时间过后未收到响应,我们将在“重试间隔”时间过后再次调用 Web 服务器。 如此继续尝试,直到时间(从第一次尝试算起)达到“故障超时”设置的时间秒数。

     

    以下举例进行说明:

     

    假定以下设置:

     

    就是说:

    响应超时 - 等待 7 秒以响应

    重试间隔 - 每 10 秒重试一次

    故障超时 – 30 秒后“放弃”重试

     

    假定在 8 秒后返回响应,则情况如下:

  • 在 00:00,我们进行第一次调用
  • 在 00:07,由于未返回任何响应,我们在内部确认发生了“响应超时”错误(并在“事件日志”中记录“错误事件”),并根据重试策略和设置再次尝试 – “故障超时”尚未到达,因此引发了“需要重试标志”。
  • [在 00:08,Web 服务器返回一个响应,但由于我们已经将其记录为超时错误,因此我们不会收到此响应]
  • 在 00:10,重试间隔时间已到,并且由于引发了“需要重试标志”,我们将再次调用 Web 服务。
  • 在 00:17,如果仍未返回任何响应,我们将再次达到“响应超时”时间(请注意,在上面的“00:08/第 3 段中,返回的响应已被“忽略/丢弃”),因此我们再次在内部将此认为是错误(但这次不会再添加一个“错误事件日志”条目,只会在第一次尝试时记录此错误,而不是每次重试失败时都记录),由于我们尚未达到“故障超时”时间,因此需要再次引发“需要重试标志”。
  • [在 00:18,Web 服务器返回一个响应,这次我们还是接收不到]
  • 在 00:20,又达到重试间隔时间,我们将尝试第 3 次调用。
  • 在 00:27,仍无响应,再次发生“响应超时”错误,需要重试(仍未达到“故障超时”)。
  • [在 00:28,服务器未发回响应]
  • 在 00:30,再次达到重试间隔时间,我们进行第 4 次尝试(也是最后一次)。
  • 在 00:37,“响应超时”再次发生 – 这次,已达到“故障超时”时间,因此我们不会引发“需要重试标志”,而是放弃 – 我们在事件日志中记录一个错误事件,指出已达到故障超时时间,并且返回业务操作调用错误。
  •  

    以下是上述示例的调用“证据”。

     

    首先是服务器端 [来自 SOAP 日志] – 可以看到,其收到了 4 次调用/请求,均相隔 10 秒,每次在请求发出 8 秒后返回一个响应:

    * * *
    05/31/2016 14:18:45 *********************
    Input to Web service with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...

     

    05/31/2016 14:18:53 *********************
    Output from Web service with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...

     

    05/31/2016 14:18:55 *********************
    Input to Web service with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...

     

    05/31/2016 14:19:03 *********************
    Output from Web service with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...

     

    05/31/2016 14:19:05 *********************
    Input to Web service with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...

     

    05/31/2016 14:19:13 *********************
    Output from Web service with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...

     

    05/31/2016 14:19:15 *********************
    Input to Web service with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...

     

    05/31/2016 14:19:23 *********************
    Output from Web service with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...

     

    现在,从 Ensemble BO/客户端,可以看到,有 4 次尝试,均相隔 10 秒,每次在 7 秒后记录响应超时错误。

     

    客户端

     

    05/31/2016 14:18:45 *********************
    Output from Web client with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...
     
    05/31/2016 14:18:52 *********************
    Input to Web client with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ERROR #5922: Timed out waiting for response
    string**** SOAP client return error. method=GetResponse, action=http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
         ERROR #5922: Timed out waiting for response
     
    05/31/2016 14:18:55 *********************
    Output from Web client with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...
     
    05/31/2016 14:19:02 *********************
    Input to Web client with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ERROR #5922: Timed out waiting for response
    string**** SOAP client return error. method=GetResponse, action=http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
         ERROR #5922: Timed out waiting for response
     
    05/31/2016 14:19:05 *********************
    Output from Web client with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...
     
    05/31/2016 14:19:12 *********************
    Input to Web client with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ERROR #5922: Timed out waiting for response
    string**** SOAP client return error. method=GetResponse, action=http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
         ERROR #5922: Timed out waiting for response
     
    05/31/2016 14:19:15 *********************
    Output from Web client with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ...
     
    05/31/2016 14:19:22 *********************
    Input to Web client with SOAP action = http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
    ERROR #5922: Timed out waiting for response
    string**** SOAP client return error. method=GetResponse, action=http://tempuri.org/Test.WSTimeouts.WebService.GetResponse
         ERROR #5922: Timed out waiting for response

     

    以下是对 Ensemble 的可视化跟踪:

    以下是事件日志条目:

     

    以下为跟踪事件的日志示例[您可能需要放大以更好地读取文字]:

    由此,可以看到上述示例的一些“内部运作”:

    在日志行 ID #684,执行了首次调用 – 时间:17:09:16。

    然后,在 7 秒之后 (09:23),我们收到响应超时错误 (#685)。 然后,操作记录了此错误 (#687),并确定等待 3 秒钟,直到达到重试间隔时间;10 秒重试间隔时间减去 7 秒响应超时时间 (#688-#690)。

    经过 3 秒等待( 09:26;#691)之后,进行第 2 次尝试 (#692),结果相同,继续重复操作,直到第 4 次尝试 (#704) 。 在第 4 次尝试失败(09:53;#705)之后,由于达到超时时间(30 秒),因此未进行另一次尝试。