简体   繁体   English

访问REST服务时发生访问冲突

[英]Access Violation when accessing REST service

I've built an interface to a thridparty Rest/Json web API, everything is working great with valid test cases, but when I request something invalid from the API, say a job that doesn't exist, the API returns a response where the body = 'null' and has a the content type as "application/json; charset=utf-8". 我已经建立了一个第三方Rest / Json Web API的接口,在有效的测试用例下,一切都可以正常工作,但是当我从API请求一些无效的东西时,例如说一个不存在的作业,API返回一个响应,其中body ='null',内容类型为“ application / json; charset = utf-8”。 I'm not sure if this is standard practice for a web API, but when I call Execute on the IHttpClient I end up with an Access Violation and the client exits. 我不确定这是否是Web API的标准做法,但是当我在IHttpClient上调用Execute时,我最终遇到访问冲突,并且客户端退出。

Protrace is a follows Protrace是一个关注者

    Exception code: C0000005 ACCESS_VIOLATION
    Fault address:  00007FFC6733DAAD 01:000000000077CAAD C:\Apps\Progress\117\bin\prow.dll

        ** ABL Stack Trace **

   --> Write OpenEdge.Net.HTTP.Filter.Payload.JsonEntityWriter at line 463  (OpenEdge/Net/HTTP/Filter/Payload/JsonEntityWriter.r)
        ExtractEntity OpenEdge.Net.HTTP.Lib.ABLSockets.ABLSocketLibrary at line 360  (OpenEdge/Net/HTTP/Lib/ABLSockets/ABLSocketLibrary.r)
        Execute OpenEdge.Net.HTTP.Lib.ABLSockets.ABLSocketLibrary at line 312  (OpenEdge/Net/HTTP/Lib/ABLSockets/ABLSocketLibrary.r)
        Execute OpenEdge.Net.HTTP.HttpClient at line 154  (OpenEdge/Net/HTTP/HttpClient.r)
        TryRest Tempo.TempoApi at line 1264  (D:\_Dev\OnTap-Trunk\rcode\Tempo\TempoApi.r)
        ExecuteRest Tempo.TempoApi at line 234  (D:\_Dev\OnTap-Trunk\rcode\Tempo\TempoApi.r)

TryRest is: TryRest是:

    METHOD PRIVATE INTEGER TryRest(
        INPUT  oUri AS URI,  
        INPUT  cType AS CHARACTER,
        INPUT  cContentType AS CHARACTER,
        INPUT  oContent AS Object,
        OUTPUT oResponse AS IHttpResponse ):

        DEFINE VARIABLE result AS INTEGER NO-UNDO.

        DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO.

        CASE cType:

            WHEN "GET" THEN
                oRequest = RequestBuilder:GET(oURI)
                                         :AddHeader("Authorization", "Bearer " + STRING(cAccessToken))
                                         :AcceptJson()
                                         :REQUEST.
        END CASE.    

        oResponse = ResponseBuilder:Build():Response.
        oClient:EXECUTE(oRequest,oResponse).

        RETURN oResponse:StatusCode.

        CATCH e AS Progress.Lang.Error:
            UNDO, THROW e.
        END CATCH.

    END METHOD.

I'm using the latest OpenEdge client, 11.7.2 Windows x64. 我正在使用最新的OpenEdge客户端11.7.2 Windows x64。

My question is, is it normal for a web API to return 'Null' for an invalid request? 我的问题是,对于无效请求,Web API返回“ Null”是否正常?

And secondly, this is obviously an unhandled exception in OpenEdge.Net.HTTP.Lib, which should not result in client crash.. Any ideas for working around it? 其次,这显然是OpenEdge.Net.HTTP.Lib中未处理的异常,这不应导致客户端崩溃。解决此问题的任何想法? I've tried changing AcceptJson() to AcceptAll, and AcceptHTML, but the protrace is the same, crashing in JsonEntityWriter. 我试过将AcceptJson()更改为AcceptAll和AcceptHTML,但是protrace相同,在JsonEntityWriter中崩溃。

Thanks 谢谢

No, typically RESTful APIs will return a 404 if you make a request to a route that isn't valid. 不会,如果您对无效的路由提出请求,通常RESTful API将返回404。 The only exception that I can think of off the top of my head is if you attempt to access a route that has parameters as part of the URI. 我能想到的唯一例外是,如果您尝试访问包含参数作为URI一部分的路由。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM