ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to send a SOAP fault message from within an RPG ILE webservice program?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to send a SOAP fault message from within an RPG ILE webservice program?

    Hi All,

    I have written a webservice program in RPG ILE. I have deployed it on HTTPAdmin. It has an input and an output parameter. It works fine, when I call it on SoapUi.
    But I don't know how could I send a SOAP fault message from within my RPG ILE webservice program.
    Does anyone has experience about this?

    Thanks in advance,
    Klara Farkas

  • #2
    Re: How to send a SOAP fault message from within an RPG ILE webservice program?

    What I've done is send an *ESCAPE message to my caller. The IWS server will trap that message and re-send it as a SOAP fault.

    Comment


    • #3
      Re: How to send a SOAP fault message from within an RPG ILE webservice program?

      Yes I did the same and worked fine in our live env.

      here is test pgm which generate soapfault message for an error - divide by zero

      btw, any idea to implement SOAP-handler (message handler) on iws ?

      Code:
           H DFTACTGRP(*NO)
            *
           D WSCAL01R        pr
           D number1                       10  0
           D number2                       10  0
           D result                        10  0
      
           D WSCAL01R        pi
           D number1                       10  0
           D number2                       10  0
           D result                        10  0
            *
            * Send Error Message goes here...
           D SendEscMsg      pr                  extpgm('QMHSNDPM')
           D   MsgID                        7    const
           D   MsgFile                     20    const
           D   MsgDta                      80    const
           D   MsgDtaLen                   10i 0 const
           D   MsgType                     10    const
           D   MsgQ                        10    const
           D   MsgQNbr                     10i 0 const
           D   MsgKey                       4
           D   ErrorDS                     16
      
           D ErrorDS         ds            16
           D   BytesProv                   10i 0 inz(16)
           D   BytesAvail                  10i 0
           D   ExceptionID                  7
           D MsgDta          s             80
           D MsgKey          s              4
      
            /free
      
                *inlr = *on;
      
                 Monitor;
      
                   result = number1/number2;
      
                 On-Error;
      
                   MsgDta = 'Unexpected Error, Please validate your input' ;
                   SendEscMsg('CPF9898':'QCPFMSG   QSYS': MsgDta:
                              %len(MsgDta):'*ESCAPE': '*':  2: MsgKey: ErrorDS);
                 EndMon;
      
                return;
            /end-free
      soapfalut message

      PHP Code:
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
            <
      soapenv:Body>
                <
      soapenv:Fault>
                    <
      faultcode>soapenv:Server</faultcode
                    <
      faultstring>java.lang.RuntimeExceptionInvocation of program failedAS400Message (IDCPF9898 textUnexpected ErrorPlease validate your input):com.ibm.as400.access.AS400Message@1ea01ea</faultstring
                    <
      detail /> 
                </
      soapenv:Fault>
            </
      soapenv:Body>
        </
      soapenv:Envelope
      dhanuxp
      Last edited by dhanuxp; April 23, 2013, 10:41 PM.

      Comment


      • #4
        Re: How to send a SOAP fault message from within an RPG ILE webservice program?

        Thank you very much for your reply both of you!
        I appreciate it so much!!
        Klara

        Comment

        Working...
        X