4 Replies Latest reply: Apr 23, 2013 4:12 AM by user12040707 RSS

    Restful webservice 404 not found - No candidate found for: POST

    user12040707
      Geting 405 - Method Not Allowed, when launching via Apex Tester button
      Geting 404 - The server has not found anything matching the Request-URI. , when launching via RESTclient

      Oracle Environment:
      Database 11.2.0.2
      Application Express 4.2.0
      apex_listener.2.0.1.64.14.25 - standalone


      The Apex constructed URL for testing a simple POST restful webservice is:
      http://<IP>:18080/apex/htmlclient/sms/pushnotification/testresponsetext


      Workspace: htmlclient
      PathPrefix:htmlclient
      Webservice definition
      URI Template:sms/pushnotification/{response_msg}
      Method: POST
      SourceType: PL/SQL
      RequireSecureAccess: No

      Anonymous PL/SQL block
      declare
      x varchar2(4000);
      begin
      x := :response_msg;
      end;

      What needs to be changed to resolve the 404/405 issues ?
      (For 405 It looks like the Apex tester is sending a GET and not a POST,
      For 404 not sure - No candidate found for: POST sms/pushnotification in context: http://<IP>:18080/apex/htmlclient/ ?
      suspecting the url-mapping although not sure what need changing, any thoughts?)

      The request will be of Content Type: application/xml, Do I need to define this (and how)?

      The successful response should be HTTP Status Code: 200, Do I need to explicitly define this?


      Listener Configuration:
      default database connection is named: apex

      url-mapping.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <pool-config xmlns="http://xmlns.oracle.com/apex/pool-config">
      <pool base-path="/htmlclient" name="apex" workspace-id="htmlclient" updated="2013-04-19T14:46:42.971Z"/>
      </pool-config>



      This is the output from having logging enabled: (having replaced the public IP with <IP>)

      405
      ==

      Request Path passes syntax validation
      Mapping request to database pool: PoolMap [_poolName=apex, _regex=null, _workspaceIdentifier=htmlclient, _failed=false, _lastUpdate=1366382802971, _template=/htmlclient/, _type=BASE_PATH]
      Applied database connection info
      Attempting to process with PL/SQL Gateway
      Not processed as PL/SQL Gateway request
      Attempting to process as a RESTful Service
      sms/pushnotification/{response_msg} matches: sms/pushnotification/testresponsetext score: 0
      Choosing: oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as current candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=1037823610730649|2632725339868462, uriTemplate=sms/pushnotification/{response_msg}], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true]
      Determining if request can be dispatched as a Tenanted RESTful Service
      Request path has one path segment, continuing processing
      Tenant Principal already established, cannot dispatch
      Chose oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as the final candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=1037823610730649|2632725339868462, uriTemplate=sms/pushnotification/{response_msg}], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true] for: GET sms/pushnotification/testresponsetext
      sms/pushnotification/testresponsetext is a public resource

      WebException [statusCode=405, allowableMethods=[POST]]
      at oracle.dbtools.rt.web.WebException.webException(WebException.java:326)
      at oracle.dbtools.rt.web.WebException.methodNotAllowed(WebException.java:262)
      at oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplates.allowableMethods(JDBCResourceTemplates.java:207)

      404:

      Mapping request to database pool: PoolMap [_poolName=apex, _regex=null, _workspaceIdentifier=htmlclient, _failed=false, _lastUpdate=1366382802971, _template=/htmlclient/, _type=BASE_PATH]
      Applied database connection info
      Attempting to process with PL/SQL Gateway
      Not processed as PL/SQL Gateway request
      Attempting to process as a RESTful Service
      Determining if request can be dispatched as a Tenanted RESTful Service
      Request path has one path segment, continuing processing
      Tenant Principal already established, cannot dispatch
      No candidate found for: POST sms/pushnotification in context: http://<IP>:18080/apex/htmlclient/
      </pre>
      </p>
      <p>
      <pre>WebException [statusCode=404]
      at oracle.dbtools.rt.web.WebException.webException(WebException.java:326)
        • 1. Re: Restful webservice 404 not found - No candidate found for: POST
          AndyH
          user12040707 wrote:
          Geting 405 - Method Not Allowed, when launching via Apex Tester button
          The test button can only perform 'GET' request tests.
          Geting 404 - The server has not found anything matching the Request-URI. , when launching via RESTclient
          No candidate found for: POST sms/pushnotification in context: http://<IP>:18080/apex/htmlclient/
          Is the RESTclient call correct? Does it include the /message bit?
          • 2. Re: Restful webservice 404 not found - No candidate found for: POST
            user12040707
            Thanks for clarifying the use of the "Test" button,

            Perhaps the Apex user interface should disable the test button when the test capability doesn't exist for the web service method (as it is currently GET only)


            For the POST - when testing, I was actually passing the response_msg in the request body and not part of the URL.
            When passing the response_msg as part of the URL, the request actually executes although fails with illegal characters in URL (>WebException [statusCode=400, reasons=[The request path contains illegal characters]])

            response_msg (simple) parameter value:

            <InboundMessage><Id>PUSH12345678980</Id><MessageId>MSGID2345678980</MessageId><AccountId>309320</AccountId><MessageText>9</MessageText></InboundMessage>


            How can I re-configure the web service to accept response_msg in the following form?

            Request: application/xml
            Request body: the response_msg which is in XML format

            Or is there another approach that should be used in this scenario?
            • 3. Re: Restful webservice 404 not found - No candidate found for: POST
              Colm Divilly-Oracle
              user12040707 wrote:
              Thanks for clarifying the use of the "Test" button,

              Perhaps the Apex user interface should disable the test button when the test capability doesn't exist for the web service method (as it is currently GET only)
              This is fixed in APEX 4.2.1

              >
              For the POST - when testing, I was actually passing the response_msg in the request body and not part of the URL.
              When passing the response_msg as part of the URL, the request actually executes although fails with illegal characters in URL (>WebException [statusCode=400, reasons=[The request path contains illegal characters]])

              response_msg (simple) parameter value:

              <InboundMessage><Id>PUSH12345678980</Id><MessageId>MSGID2345678980</MessageId><AccountId>309320</AccountId><MessageText>9</MessageText></InboundMessage>


              How can I re-configure the web service to accept response_msg in the following form?

              Request: application/xml
              Request body: the response_msg which is in XML format

              Or is there another approach that should be used in this scenario?
              When you want to process the content body of a POST or PUT operation you need to dereference the implicit :body parameter as shown in the example here:

              http://docs.oracle.com/cd/E21611_01/doc.11/e21058/rest_api.htm#BGBDHHEJ

              In your case you will want to pass the :body parameter to XMLType or XMLQuery and parse out the data your interested in. Just in case it's not clear :body will be a BLOB parameter.
              • 4. Re: Restful webservice 404 not found - No candidate found for: POST
                user12040707
                Thanks for pointing me in the right direction, much appreciated