DEFINE VARIABLE hWebService AS HANDLE NO-UNDO.
DEFINE VARIABLE hPortType AS HANDLE NO-UNDO.
PROCEDURE CreateMessageAuthHeader :
DEFINE OUTPUT PARAMETER hSOAPHeader AS HANDLE .
DEFINE INPUT PARAMETER cOperationNamespace AS CHARACTER .
DEFINE INPUT PARAMETER cOperationLocalName AS CHARACTER .
DEFINE OUTPUT PARAMETER lDeleteOnDone AS LOGICAL .
DEFINE VARIABLE hTmpSoapHeader AS HANDLE NO-UNDO.
DEFINE VARIABLE hSoapHeaderRef AS HANDLE NO-UNDO.
DEFINE VARIABLE hNodeAuthHead AS HANDLE NO-UNDO.
CREATE SOAP-HEADER hTmpSoapHeader.
CREATE SOAP-HEADER-ENTRYREF hSoapHeaderRef.
CREATE X-DOCUMENT hXDocAuthHeader.
CREATE X-NODEREF hNodeAuthHead.
hTmpSoapHeader:ADD-HEADER-ENTRY(hSoapHeaderRef).
hXDocAuthHeader:CREATE-NODE-NAMESPACE(hNodeAuthHead, cNsUri, cNsPrefix + ":" + "AuthHeader", "ELEMENT").
AddMessageElement(hNodeAuthHead, hXDocAuthHeader, "username", "username", cNsUri, cNsPrefix).
AddMessageElement(hNodeAuthHead, hXDocAuthHeader, "password", "password", cNsUri, cNsPrefix).
hSoapHeaderRef:SET-NODE(hNodeAuthHead).
hSoapHeader = hTmpSoapHeader.
lDeleteOnDone = TRUE.
END PROCEDURE .
FUNCTION ConnectWebService RETURNS INT ().
/*Connect to Webservice*/
CREATE SERVER hWebService.
/* replace connection string with config val */
hWebService:CONNECT("-WSDL 'http://www.someservicesite.com/webservice.asmx?wsdl'").
RUN PortType SET hPortType ON hWebService.
/* Set up webservice call/callback */
hPortType:SET-CALLBACK-PROCEDURE("REQUEST-HEADER", "CreateMessageAuthHeader").
END FUNCTION.
/***********************Web Methods*********************************/
FUNCTION GetStatus RETURNS INT
(INPUT IdNumber AS CHARACTER)
IN hPortType.
/***********************Business Methods*********************************/
FUNCTION GetMyStatus RETURNS INT (INPUT IdNumber AS CHARACTER).
ConnectWebService().
statusResult = GetStatus(IdNumber).
END FUNCTION.
No comments:
Post a Comment