<SOAP-ENV:Envelope
. . . <SOAP-ENV:Header> <ns0:AuthHeader xmlns:ns0="http://ServiceHost/SOAPHeader"> <ns0:AccessID>XYZZY</ns0:AccessID> <ns0:Password>Administrator</ns0:Password> </ns0:AuthHeader> </SOAP-ENV:Header> . . . </SOAP-ENV:Envelope> |
/* SOAPHeader2.p
An addition to SOAPHeader1.p. Calls a ficticious Web service. The first operation (OpenAccess) sends nothing in the request headers and gets back a SOAP response header containing an AccessID. The second operation (HelloWorld) sends the AccessID back in its request header. (No additional information is received in the response header.) The third operation (HelloSecureWorld) adds a Password node to the existing AccessID entry in its request header. This Password node is added as a sibling of the AccessID element and NOT as a new SOAP header entry. (Once again no additional information is received in the response header.) The Web service has only one service and port available. */ /*1*/ /* Define local variables */ DEFINE VARIABLE hWebSrvc AS HANDLE. DEFINE VARIABLE hPortType AS HANDLE. DEFINE VARIABLE cResponse AS CHARACTER FORMAT "x(72)". DEFINE VARIABLE hXdoc AS HANDLE. DEFINE VARIABLE hXnoderef1 AS HANDLE. DEFINE VARIABLE hXnoderef2 AS HANDLE. DEFINE VARIABLE hXtext AS HANDLE. DEFINE VARIABLE cPassword AS CHARACTER INIT ?. DEFINE VARIABLE g_header AS HANDLE. /* Create the Web service server object */ CREATE SERVER hWebSrvc. /* Connect to the WS */ hWebSrvc:CONNECT("-WSDL http://ServiceHost/SOAPHeader/HeaderExample.asmx?wsdl"). /* Get the method, set the port type */ RUN HeadersSoap SET hPortType ON hWebSrvc. /*2*/ /* Associate the req. & resp. callbacks with the port type */ hPortType:SET-CALLBACK-PROCEDURE("REQUEST-HEADER", "ReqHandler"). hPortType:SET-CALLBACK-PROCEDURE("RESPONSE-HEADER", "RespHandler"). /*3*/ /* Invoke the Web service with no header and display the results */ RUN OpenAccess IN hPortType (OUTPUT cResponse). DISPLAY cResponse LABEL "WS response" WITH FRAME aaa. /*4*/ /* Go again with the AccessID set from previous response */ cResponse = "". RUN HelloWorld IN hPortType (OUTPUT cResponse). DISPLAY cResponse LABEL "WS response" WITH FRAME bbb. /*5*/ /* Go again with the AccessID set from previous response */ /* header together with an added Username and Password */ cResponse = "". cPassword = "Administrator". RUN HelloSecureWorld IN hPortType (OUTPUT cResponse). DISPLAY cResponse LABEL "WS response" WITH FRAME ccc. |
/*6*/
DELETE OBJECT g_header. DELETE OBJECT hPortType. hWebSrvc:DISCONNECT(). DELETE OBJECT hWebSrvc. /**************** Internal Procedures ****************/ |