10 Replies Latest reply: Oct 28, 2011 12:34 PM by 837984 RSS

    ODSI - Fault Handling

    837984
      Hi,

      Can someone here please suggest the best practices to implement fault handling in ODSI Data Services.

      Thanks in Advance.

      Regards
        • 1. Re: ODSI - Fault Handling
          mikereiche
          Start from the requirements of your client application and handle every type of fault according to those requirements.

          For read-only operations, you can either let the whole call fail, and retry the call (if retrying might succeed), or you could handle the fault inside the call using some form of the the fn-bea:fail-over function. http://download.oracle.com/docs/cd/E13162_01/odsi/docs10gr3/xquery/extensions.html

          Also look at the section in the link in the "Best Practices" notice in this forum - http://download.oracle.com/docs/cd/E13162_01/odsi/docs10gr3/odsi10gr3/Best%20Practices%20When%20Building%20Data%20Services.html#BestPracticesWhenBuildingDataServices-ExercisingCarewhenUsingFailover%2CFailoverretry%2CandTimeout

          For updates, handle them as you would any jdbc update. There is also try/catch http://download.oracle.com/docs/cd/E13162_01/odsi/docs10gr3/xquery/xqse.html

          And this - http://download.oracle.com/docs/cd/E13162_01/odsi/docs10gr3/odsi10gr3/How%20To%20Develop%20Good%20XQSEs.html
          • 2. Re: ODSI - Fault Handling
            837984
            Information you provided was helpful.

            Do we have any mechanism to capture the standard faults and send a fault response to the invoking client ?

            And more over the articrafts referred in the documentation are not accessible it seems all the links have broken.

            Thanks in Advance.

            Regards
            • 3. Re: ODSI - Fault Handling
              mikereiche
              Do we have any mechanism to capture the standard faults and send a fault response to the invoking client ?
              Use fn-bea:fail-over() with an alternate-expression argument of fn-error(). Whatever arguments you pass to fn-error() will be thrown.
              all the links have broken.
              I tried them all before I posted and I tried them all again just now, both from my browser and from http://www.webpagetest.org. They're all good. Not sure what to say about that. You could try navigating to them from Google

              http://www.google.com/search?q=site%3Adownload.oracle.com%2Fdocs%2Fcd%2FE13162_01%2Fodsi+fn-bea%3Afail-over
              • 4. Re: ODSI - Fault Handling
                837984
                Hi ,


                I was not referring to the links posted on this thread were broken they are working perfectly , I was referring to the downloads and artifacts specified in the documents which i have accessed through the links you have provided.

                Thanks in Advance.

                Regards
                • 5. Re: ODSI - Fault Handling
                  mikereiche
                  If you tell me which links are broken, I might be able to find where they moved to.

                  The product download is at http://www.oracle.com/technetwork/middleware/data-service-integrator/downloads/index.html

                  There are some samples here :

                  https://www.samplecode.oracle.com/tracker/tracking/linkid/prpl1004/action/ExecuteQuery?sfLoginToken=5F1BF0377F4161557A7BE03FD3BD0530&sfProj=codesamples&isLoggedIn=true&query=aqualogic_data_services_platform_aldsp_&dapCheckedPassed=false

                  The links to edocs.bea.com will not work - BEA was purchased by Oracle in 2008.
                  • 6. Re: ODSI - Fault Handling
                    837984
                    Hi,

                    The samples provide would help.

                    I was referring to the link below :

                    http://edocs.bea.com/aldsp/docs30/code/XQSE-How-To-artifacts-32.zip

                    Thanks in advance

                    Regards
                    • 7. Re: ODSI - Fault Handling
                      837984
                      hi,

                      I think the real question is :
                      How can I throw SOAP Fault from the data services. ie. the service producer throws a fault, back to the service consumer.
                      • 8. Re: ODSI - Fault Handling
                        mikereiche
                        You don't have to do anything.

                        If your data service is exposed and called as a web-service, and an exception occurs, your client will get a SOAP Fault containing the exception that was thrown. You expose a dataservice (.ds file) as a web service by Right-click -> create web service map. You can test the generated .ws from the right-click menu. Here I've forced an error by changing the table name :

                        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                        <soapenv:Header />
                        <soapenv:Body>
                        <soapenv:Fault>
                        <faultcode>soapenv:Server</faultcode>
                        <faultstring>ld:CUSTOMER.ds, line 98, column 7: {bea-err}RDBW0004: [cgDataSource-nonXA]: [SELECT t1."ADDR_ID" AS c1, t1."ALIAS" AS c2, t1."CITY" AS c3, t1."COUNTRY" AS c4,
                          t1."CUSTOMER_ID" AS c5, t1."DAY_PHONE" AS c6, t1."EVE_PHONE" AS c7, t1."FIRST_NAME" AS c8,
                          t1."IS_DEFAULT" AS c9, t1."LAST_NAME" AS c10, t1."STATE" AS c11, t1."STATUS" AS c12, ...</faultstring>
                              <detail>com.bea.dsp.wrappers.rdb.exceptions.RDBWrapperException: ld:CUSTOMER.ds, line 98, column 7: {bea-err}RDBW0004: [cgDataSource-nonXA]: [SELECT t1."ADDR_ID" AS c1, t1."ALIAS" AS c2, t1."CITY" AS c3, t1."COUNTRY" AS c4,
                          t1."CUSTOMER_ID" AS c5, t1."DAY_PHONE" AS c6, t1."EVE_PHONE" AS c7, t1."FIRST_NAME" AS c8,
                          t1."IS_DEFAULT" AS c9, t1."LAST_NAME" AS c10, t1."STATE" AS c11, t1."STATUS" AS c12,
                          t1."STREET_ADDRESS1" AS c13, t1."STREET_ADDRESS2" AS c14, t1."ZIPCODE" AS c15
                        FROM "RTLCUSTOMER"."ADDRESS_XXX" t1
                        WHERE (? = t1."CUSTOMER_ID")]: [CUSTOMER1]: Error executing SQL query: Invalid table name "ADDRESS_XXX" specified at position 369.
                        at com.bea.dsp.wrappers.rdb.exceptions.RDBWrapperException.create(RDBWrapperException.java:89)
                        at weblogic.xml.query.exceptions.XQueryException.create(XQueryException.java:127)
                        at weblogic.xml.query.exceptions.XQueryException.create(XQueryException.java:175)
                        at weblogic.xml.query.exceptions.XQueryException.create(XQueryException.java:162)
                        at com.bea.dsp.wrappers.rdb.runtime.DBSession.executeQuery(DBSession.java:113)
                        at com.bea.dsp.wrappers.rdb.runtime.ExecuteSQLQueryBase.executeSQL(ExecuteSQLQueryBase.java:19)
                        at com.bea.dsp.wrappers.rdb.runtime.ExecuteSQLRuntimeBase.prepareAndExecuteQuery(ExecuteSQLRuntimeBase.java:170)
                        at com.bea.dsp.wrappers.rdb.runtime.ExecuteSQLRuntimeBase.fetchNext(ExecuteSQLRuntimeBase.java:95)
                        at weblogic.xml.query.iterators.GenericIterator.hasNext(GenericIterator.java:133)
                        at weblogic.xml.query.runtime.core.CountMapIterator.fetchNext(CountMapIterator.java:138)
                        at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
                        at weblogic.xml.query.runtime.querycide.QueryAssassin.fetchNext(QueryAssassin.java:54)
                        at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
                        at weblogic.xml.query.runtime.qname.InsertNamespaces.fetchNext(InsertNamespaces.java:160)
                        at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
                        at weblogic.xml.query.runtime.core.ExecutionWrapper.fetchNext(ExecutionWrapper.java:88)
                        at weblogic.xml.query.iterators.GenericIterator.hasNext(GenericIterator.java:133)
                        at weblogic.xml.query.xdbc.util.Serializer.serializeItems(Serializer.java:241)
                        at com.bea.ld.server.ResultPusher$DSP25CompatibilityPusher.next(ResultPusher.java:236)
                        at com.bea.ld.server.ResultPusher.pushResults(ResultPusher.java:112)
                        at com.bea.ld.server.XQueryInvocation.execute(XQueryInvocation.java:770)
                        at com.bea.ld.EJBRequestHandler.invokeQueryInternal(EJBRequestHandler.java:624)
                        at com.bea.ld.EJBRequestHandler.invokeOperationInternal(EJBRequestHandler.java:478)
                        at com.bea.ld.EJBRequestHandler.invokeOperation(EJBRequestHandler.java:323)
                        at com.bea.ld.ServerWrapperBean.invoke(ServerWrapperBean.java:153)
                        at com.bea.ld.ServerWrapperBean.invokeOperation(ServerWrapperBean.java:80)
                        at com.bea.ld.ServerWrapper_s9smk0_ELOImpl.invokeOperation(ServerWrapper_s9smk0_ELOImpl.java:63)
                        at com.bea.dsp.ws.RoutingHandler$PriviledgedRunner.run(RoutingHandler.java:96)
                        at com.bea.dsp.ws.RoutingHandler.handleResponse(RoutingHandler.java:217)
                        at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:287)
                        at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:271)
                        at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:176)
                        at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:80)
                        at weblogic.wsee.server.servlet.SoapProcessor.handlePost(SoapProcessor.java:66)
                        at weblogic.wsee.server.servlet.SoapProcessor.process(SoapProcessor.java:44)
                        at weblogic.wsee.server.servlet.BaseWSServlet$AuthorizedInvoke.run(BaseWSServlet.java:285)
                        at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:169)
                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
                        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
                        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
                        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
                        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
                        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
                        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                        at weblogic.security.service.SecurityManager.runAs(Unknown Source)
                        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
                        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
                        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
                        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
                        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
                        Caused by: java.sql.SQLException: Invalid table name "ADDRESS_XXX" specified at position 369.
                        at com.pointbase.net.netJDBCPrimitives.handleResponse(Unknown Source)
                        at com.pointbase.net.netJDBCPrimitives.handleJDBCObjectResponse(Unknown Source)
                        at com.pointbase.net.netJDBCConnection.prepareStatement(Unknown Source)
                        at weblogic.jdbc.common.internal.ConnectionEnv.makeStatement(ConnectionEnv.java:1338)
                        at weblogic.jdbc.common.internal.ConnectionEnv.getCachedStatement(ConnectionEnv.java:1019)
                        at weblogic.jdbc.common.internal.ConnectionEnv.getCachedStatement(ConnectionEnv.java:995)
                        at weblogic.jdbc.common.internal.ConnectionEnv.getCachedStatement(ConnectionEnv.java:988)
                        at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:487)
                        at com.bea.dsp.wrappers.rdb.runtime.DBSession.executeQuery(DBSession.java:79)
                        ... 45 more
                        </detail>
                        </soapenv:Fault>
                        </soapenv:Body>
                        </soapenv:Envelope>


                        If you don't like how that looks, you can use fail-over( expression, alternateExpression) and use fn-error() as the alternateExpression with your own message. Below I have encapsulated the getADDRESS() function with my own getADDRESS_MyError() function.


                        (::pragma function <f:function xmlns:f="urn:annotations.ld.bea.com" visibility="public" kind="navigate" roleName="ADDRESS"/>::)

                        declare function f1:getADDRESS_MyError($pk as element(t2:CUSTOMER)) as element(t1:ADDRESS)*
                        {
                             fn-bea:fail-over( f1:getADDRESS($pk), fn:error(xs:QName("I_WANT_MY_OWN_ERROR"), "something bad happened"))
                        };


                        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                        <soapenv:Header />
                        <soapenv:Body>
                        <soapenv:Fault>
                        <faultcode>soapenv:Server</faultcode>
                        <faultstring>ld:CUSTOMER.ds, line 107, column 40: I_WANT_MY_OWN_ERROR: something bad happened</faultstring>
                        <detail>weblogic.xml.query.exceptions.XQueryUserException: ld:CUSTOMER.ds, line 107, column 40: I_WANT_MY_OWN_ERROR: something bad happened
                        at weblogic.xml.query.runtime.core.Error.fetchNext(Error.java:61)
                        at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
                        at weblogic.xml.query.runtime.failover.FailOver.fetchNext(FailOver.java:123)
                        at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
                        at weblogic.xml.query.runtime.querycide.QueryAssassin.fetchNext(QueryAssassin.java:54)
                        at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
                        at weblogic.xml.query.runtime.qname.InsertNamespaces.fetchNext(InsertNamespaces.java:160)
                        at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
                        at weblogic.xml.query.runtime.core.ExecutionWrapper.fetchNext(ExecutionWrapper.java:88)
                        at weblogic.xml.query.iterators.GenericIterator.hasNext(GenericIterator.java:133)
                        at weblogic.xml.query.xdbc.util.Serializer.serializeItems(Serializer.java:241)
                        at com.bea.ld.server.ResultPusher$DSP25CompatibilityPusher.next(ResultPusher.java:236)
                        at com.bea.ld.server.ResultPusher.pushResults(ResultPusher.java:112)
                        at com.bea.ld.server.XQueryInvocation.execute(XQueryInvocation.java:770)
                        at com.bea.ld.EJBRequestHandler.invokeQueryInternal(EJBRequestHandler.java:624)
                        at com.bea.ld.EJBRequestHandler.invokeOperationInternal(EJBRequestHandler.java:478)
                        at com.bea.ld.EJBRequestHandler.invokeOperation(EJBRequestHandler.java:323)
                        at com.bea.ld.ServerWrapperBean.invoke(ServerWrapperBean.java:153)
                        at com.bea.ld.ServerWrapperBean.invokeOperation(ServerWrapperBean.java:80)
                        at com.bea.ld.ServerWrapper_s9smk0_ELOImpl.invokeOperation(ServerWrapper_s9smk0_ELOImpl.java:63)
                        at com.bea.dsp.ws.RoutingHandler$PriviledgedRunner.run(RoutingHandler.java:96)
                        at com.bea.dsp.ws.RoutingHandler.handleResponse(RoutingHandler.java:217)
                        at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:287)
                        at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:271)
                        at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:176)
                        at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:80)
                        at weblogic.wsee.server.servlet.SoapProcessor.handlePost(SoapProcessor.java:66)
                        at weblogic.wsee.server.servlet.SoapProcessor.process(SoapProcessor.java:44)
                        at weblogic.wsee.server.servlet.BaseWSServlet$AuthorizedInvoke.run(BaseWSServlet.java:285)
                        at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:169)
                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
                        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
                        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
                        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
                        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
                        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
                        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                        at weblogic.security.service.SecurityManager.runAs(Unknown Source)
                        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
                        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
                        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
                        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
                        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
                        </detail>
                        </soapenv:Fault>
                        </soapenv:Body>
                        </soapenv:Envelope>
                        • 9. Re: ODSI - Fault Handling
                          mikereiche
                          the download you were looking for is at http://download.oracle.com/docs/cd/E13167_01/aldsp/docs30/code/XQSE-How-To-artifacts-32.zip.

                          (courtesy of Alex)
                          • 10. Re: ODSI - Fault Handling
                            837984
                            Thanks for the information and as well the download.

                            Regards