9 Replies Latest reply: Aug 22, 2013 7:36 AM by 8d4b01bf-3d32-47c4-a892-8975f524d7a3 RSS

    Ora-31011 with a very, very simple native webservice

    Edwin van Meerendonk
      I set up the Native webservices in our 11.2.0.1 environment like it's mentioned in the manual.
      I created a packaged function without input parameter that just returns a varchar2.
      In its simplest form I returned a value 'x'

      the url I used was http://localhost:8080/orawsv/ENER/HANDLER/GET_METERSTANDEN --> package HANDLER, function GET_METERSTANDEN

      The WSDL looks correct. However, when I call my function by the above URL I get:

      <soap:Envelope><soap:Body><soap:Fault><faultcode>soap:Client</faultcode>
      <faultstring>Error processing input</faultstring>
      <detail><OracleErrors><OracleError>
      <ErrorNumber>ORA-31011</ErrorNumber>
      <Message>XML parsing failed
      </Message></OracleError></OracleErrors></detail></soap:Fault></soap:Body></soap:Envelope></code>

      so, "something" is wrong with my input (?? there is none) and parsing of the(?) XML failed.

      Is there a way to see the generated XML?
      And anyone encountered the same error while following the example in the manual to the letter?
        • 1. Re: Ora-31011 with a very, very simple native webservice
          Marco Gralike
          Hereby a re-runnable demo script based on Mark Drake's code here somewhere on this forum
          clear screen
          clear buffer
          
          connect / AS sysdba
          
          -- call dbms_xdb.sethttpport(80);
          -- alter system register;
          
          grant dba, xdbadmin to scott;
          
          alter user scott identified by tiger account unlock;
          
          set echo on
          set termout on
          set feed on
          cle scre
          ---------------------------------------------------------
          
          -- Show User and "orawsv" new xdbconfig.xml entry
          
          ----------------------------------------------------------
          
          show user
          --
          DECLARE
            SERVLET_NAME VARCHAR2(32) := 'orawsv';
          BEGIN
            DBMS_XDB.deleteServletMapping(SERVLET_NAME);
            DBMS_XDB.deleteServlet(SERVLET_NAME);
            DBMS_XDB.addServlet(NAME => SERVLET_NAME,
                                        LANGUAGE => 'C',
                                        DISPNAME => 'Oracle Query Web Service',
                                        DESCRIPT => 'Servlet for issuing queries as a Web Service',
                                        SCHEMA => 'XDB');
            DBMS_XDB.addServletSecRole(SERVNAME => SERVLET_NAME,
                                       ROLENAME => 'XDB_WEBSERVICES',
                                       ROLELINK => 'XDB_WEBSERVICES');
            DBMS_XDB.addServletMapping(PATTERN => '/orawsv/*',
                                       NAME => SERVLET_NAME);
          END;
          /
          
          pause
          --
          def USERNAME=SCOTT
          def PASSWORD=tiger
          --
          pause
          clear screen
          ----------------------------------------------------------
          
          -- Drop the Access Control List XML file if it exists
          
          ----------------------------------------------------------
          begin
            dbms_network_acl_admin.drop_acl('/public/localhost.xml');
          end;
          /
          commit;
          pause
          clear screen
          ----------------------------------------------------------
          
          -- Create and Assign ACL's to localhost
          
          ----------------------------------------------------------
          begin
            --
            dbms_network_acl_admin.create_acl('/public/localhost.xml',
                                              'ACL for 127.0.0.1',
                                              '&USERNAME'
                                              , true
                                              , 'connect');
            --
            dbms_network_acl_admin.assign_acl('/public/localhost.xml'
                                              , '127.0.0.1');
          end;
          /
          COMMIT
          /
          pause
          clear screen
          ----------------------------------------------------------
          
          -- Show and grant NDWS Roles to a user account
          
          ----------------------------------------------------------
          
          -- Only HTTPS allowed
          GRANT XDB_WEBSERVICES TO &USERNAME
          /
          -- HTTP also allowed
          GRANT XDB_WEBSERVICES_OVER_HTTP TO &USERNAME
          /
          -- Access also allowed that are accessible to PUBLIC.
          GRANT XDB_WEBSERVICES_WITH_PUBLIC TO &USERNAME
          /
          pause
          clear screen
          
          connect &USERNAME/&PASSWORD
          
          set echo on
          set termout on
          set feed on
          SET long 10000
          clear screen
          
          ----------------------------------------------------------
          
          -- Show the now active WSDL URL
          
          ----------------------------------------------------------
          
          show user
          
          var url varchar2(700)
          
          BEGIN
            :url :=   'http://&USERNAME:&PASSWORD@localhost:'
                      || dbms_xdb.getHttpPort()
                      || '/orawsv?wsdl';
          end;
          /
          
          print url
          
          pause
          SET long 10000 pages 0
          cle scre
          
          ----------------------------------------------------------
          
          -- Show the output via PL/SQL when WSDL URL called
          
          ----------------------------------------------------------
          SELECT  httpuritype( :url ).getXML()
          FROM    dual
          /
          pause
          cle scre
          
          ----------------------------------------------------------
          
          -- Create simple function that can be called via the NDWS
          
          ----------------------------------------------------------
          create or replace function GET_SQRT (INPUT_VALUE number) return number
          as
           begin
            return SQRT(INPUT_VALUE);
           end;
          /
          
          pause
          SET long 10000 pages 0
          cle scre
          ----------------------------------------------------------
          
          -- Setting the URL as input for consumption 
          
          ----------------------------------------------------------
          BEGIN
            :url :=   'http://&USERNAME:&PASSWORD@localhost:'
                      || dbms_xdb.getHttpPort()
                      || '/orawsv/SCOTT/GET_SQRT';
          end;
          /
          print url
          
          SELECT  httpuritype( :url ).getXML()
          FROM    dual
          /
          cle scre
          
          ----------------------------------------------------------
          
          -- Consume NDWS function call via PL/SQL
          
          ----------------------------------------------------------
          set serveroutput on
          --
          DECLARE
            V_SOAP_REQUEST      XMLTYPE := XMLTYPE(
          '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                              xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
                              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                              xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <SOAP-ENV:Body>
              <m:SNUMBER-GET_SQRTInput xmlns:m="http://xmlns.oracle.com/orawsv/&USERNAME/GET_SQRT">
                  <m:INPUT_VALUE-NUMBER-IN>2</m:INPUT_VALUE-NUMBER-IN>
              </m:SNUMBER-GET_SQRTInput>
            </SOAP-ENV:Body>
          </SOAP-ENV:Envelope>');
            V_SOAP_REQUEST_TEXT CLOB := V_SOAP_REQUEST.getClobVal();
            V_REQUEST           UTL_HTTP.REQ;
            V_RESPONSE          UTL_HTTP.RESP;
            V_BUFFER            VARCHAR2(1024);
          BEGIN
          
            V_REQUEST := UTL_HTTP.BEGIN_REQUEST(URL => :URL, METHOD => 'POST');
            UTL_HTTP.SET_HEADER(V_REQUEST, 'User-Agent', 'Mozilla/4.0');
            V_REQUEST.METHOD := 'POST';
            UTL_HTTP.SET_HEADER (R => V_REQUEST, NAME => 'Content-Length', VALUE => DBMS_LOB.GETLENGTH(V_SOAP_REQUEST_TEXT));
            UTL_HTTP.WRITE_TEXT (R => V_REQUEST, DATA => V_SOAP_REQUEST_TEXT);
          
            V_RESPONSE := UTL_HTTP.GET_RESPONSE(V_REQUEST);
            LOOP
              UTL_HTTP.READ_LINE(V_RESPONSE, V_BUFFER, TRUE);
              DBMS_OUTPUT.PUT_LINE(V_BUFFER);
            END LOOP;
            UTL_HTTP.END_RESPONSE(V_RESPONSE);
          EXCEPTION
            WHEN UTL_HTTP.END_OF_BODY THEN
              UTL_HTTP.END_RESPONSE(V_RESPONSE);
          END;
          /
          Met vriendelijke groet ;-)

          Marco
          • 2. Re: Ora-31011 with a very, very simple native webservice
            Edwin van Meerendonk
            Dank u!

            Hoped to hear from the great master :-)

            And I am not happy: the script gave no error.
            At least now I know my installation is correct.

            Seems like the request, generated by SOAPUI isn't what the servlet expected.

            Is there a way to debug the servlet to see the request he is trying to parse?
            • 3. Re: Ora-31011 with a very, very simple native webservice
              Edwin van Meerendonk
              But.....looking closer, I seem to be to hasty

              In the step "Setting the URL as input for consumption " I still get:

              SQL> SELECT httpuritype( :url ).getXML()
              2 FROM dual
              3 /

              <?xml version="1.0" ?>
              <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
              <soap:Body>
              <soap:Fault>
              <faultcode>soap:Client</faultcode>
              <faultstring>Error processing input</faultstring>
              <detail>
              <OracleErrors xmlns="http://xmlns.oracle.com/orawsv/faults">
              <OracleError>
              <ErrorNumber>ORA-31011</ErrorNumber>
              <Message><![CDATA[XML parsing failed]]></Message>
              </OracleError>
              </OracleErrors>
              </detail>
              </soap:Fault>
              </soap:Body>
              </soap:Envelope>

              The next step however is able to "consume" the service.
              • 4. Re: Ora-31011 with a very, very simple native webservice
                Marco Gralike
                Oh yes, sorry. That step is needed during a presentation to demonstrate that you need to "fake" a SOAP call via PL/SQL or use something like soapUI.
                • 6. Re: Ora-31011 with a very, very simple native webservice
                  1005987
                  Hi,
                  I am facing the same parser issue. Have you resolved the issue???
                  If so, can you pls update me ?
                  Thanks
                  • 7. Re: Ora-31011 with a very, very simple native webservice
                    8d4b01bf-3d32-47c4-a892-8975f524d7a3

                    Hi Marco

                     

                    If i run the same script ,its showed error me error on URL,that "could not found the path"

                     

                    Do we need some help of "java or any other language else than oracle" as well in this (any kinda help)??

                     

                    Thanks

                    Vipin

                    • 8. Re: Ora-31011 with a very, very simple native webservice
                      Marco Gralike

                      What are you trying to do and on which database version. The script mentioned is executed via SQL*Plus...

                      • 9. Re: Ora-31011 with a very, very simple native webservice
                        8d4b01bf-3d32-47c4-a892-8975f524d7a3

                        I am trying to configure soap and restful web services for synchronous and asynchronous in oracle 11g without the help of java or any other client but unable to do so.

                        I Tried to add servlet with in oracle with the help of oracle inbuilt packages for soap webservices but ended with error and that was "path couldn't found".

                        and about restful services ,just clueless that how can even I start for configuration.