Web Service Replies
The reply from the Client Process varies depending on whether or not the call to the Web service method was successful or not. If successful a method specific reply is returned. Success is indicated by value of 0 or 1 in the first 2 bytes of the header. Successful replies have a similar structure regardless of what service or method is being accessed. Every reply IPM has the following header structure:
DEF soapam-rp-hdr.
02 reply-code TYPE BINARY 16.
02 info-code TYPE BINARY 16.
02 info-detail TYPE BINARY 16.
02 reserved TYPE CHARACTER 26.
END.
If the reply-code
value contains 0
the request was successful and the web service reply data follows the header. If the reply-code
contains the value 1
, then the request was successful but info-
fields contain information about issues that occurred during deserialization of the web service reply. The info-code
may indicate that a string field was truncated because it was too long to fit in the reply structure or array elements were truncated because there were to many to fit in the reply structure. Should this occur, it is up to the application to determine how to proceed. If the reply-code
contains the value 2
, then an error occurred. In this case, the format of the reply as described by the soapam-reply
structure shown below:
DEF soapam-reply.
02 soapam-rp-hdr TYPE soapam-rp-hdr.
02 error-source TYPE soapam-error-source.
02 filler TYPE CHARACTER 2.
02 error-detail TYPE CHARACTER 4092.
02 soapam-error-detail REDEFINES error-detail.
03 error-code TYPE soapam-error-code.
03 error-description TYPE CHARACTER 512.
03 filler TYPE CHARACTER 3578.
02 tcpip-error-detail REDEFINES error-detail.
03 host-address TYPE CHARACTER 128.
03 error-number TYPE BINARY 16.
03 error-description TYPE CHARACTER 512.
03 filler TYPE CHARACTER 3450.
02 http-error-detail REDEFINES error-detail.
03 url TYPE CHARACTER 512.
03 status-code TYPE BINARY 16.
03 reason-phrase TYPE CHARACTER 512.
03 filler TYPE CHARACTER 3066.
02 ssl-error-detail REDEFINES error-detail.
03 url TYPE CHARACTER 512.
03 error-description TYPE CHARACTER 512.
03 error-number TYPE CHARACTER 16.
03 filler TYPE CHARACTER 3052.
02 soap-fault-detail REDEFINES error-detail.
03 faultcode TYPE CHARACTER 32.
03 faultsubcode TYPE CHARACTER 32.
03 faultreason TYPE CHARACTER 1024.
03 faultdetail TYPE CHARACTER 2048.
03 filler TYPE CHARACTER 956.
END.
A COBOL example of an echo string reply processing is shown below. The echoString service is a SOAPam sample service that is available on the SOAPam demo server.
WORKING-STORAGE.
01 MESSAGE-CODE-VALUES.
02 MC-ECHOSTRING NATIVE-2 VALUE 101.
01 RQ-ECHOSTRING.
02 SOAPAM-RQ-HDR.
03 MESSAGE-CODE NATIVE-2.
03 RESERVED PIC X(30).
02 ECHOSTRING.
03 INPUTSTRING PIC X(32).
01 RP-ECHOSTRING.
02 SOAPAM-RP-HDR.
03 REPLY-CODE NATIVE-2.
03 INFO-CODE NATIVE-2.
03 INFO-DETAIL NATIVE-2.
03 RESERVED PIC X(26).
02 ECHOSTRINGRESPONSE.
03 RETURNZ PIC X(32).
. . .
PROCEDURE-DIVISION.
MOVE LOW-VALUES TO SOAPAM-RQ-HDR OF RQ-ECHOSTRING.
MOVE MC-ECHOSTRING TO MESSAGE-CODE OF RQ-ECHOSTRING.
MOVE "Hello world!" TO INPUTSTRING OF RQ-ECHOSTRING.
SEND RQ-ECHOSTRING TO "ECHO-SERVICE"
REPLY CODE 0,1 YIELDS RP-ECHOSTRING
CODE OTHER YIELDS SOAPAM-REPLY.
IF REPLY-CODE OF SOAPAM-RP-HDR OF RP-ECHOSTRING = 0
DISPLAY RETURNZ OF RP-ECHOSTRING.
WORKING-STORAGE.
01 MESSAGE-CODE-VALUES.
02 MC-ECHOSTRING NATIVE-2 VALUE 101.
01 RQ-ECHOSTRING.
02 SOAPAM-RQ-HDR.
03 MESSAGE-CODE NATIVE-2.
03 RESERVED PIC X(30).
02 ECHOSTRING.
03 INPUTSTRING PIC X(32).
01 RP-ECHOSTRING.
02 SOAPAM-RP-HDR.
03 REPLY-CODE NATIVE-2.
03 INFO-CODE NATIVE-2.
03 INFO-DETAIL NATIVE-2.
03 RESERVED PIC X(26).
02 ECHOSTRINGRESPONSE.
03 RETURNZ PIC X(32).
. . .
PROCEDURE-DIVISION.
MOVE LOW-VALUES TO SOAPAM-RQ-HDR OF RQ-ECHOSTRING.
MOVE MC-ECHOSTRING TO MESSAGE-CODE OF RQ-ECHOSTRING.
MOVE "Hello world!" TO INPUTSTRING OF RQ-ECHOSTRING.
SEND RQ-ECHOSTRING TO "ECHO-SERVICE"
REPLY CODE 0,1 YIELDS RP-ECHOSTRING
CODE OTHER YIELDS SOAPAM-REPLY.
IF REPLY-CODE OF SOAPAM-RP-HDR OF RP-ECHOSTRING = 0
DISPLAY RETURNZ OF RP-ECHOSTRING.