SOAP WSDL Generate Code

CAPSoapHttp / getMessage

ASP AutoIt C C (Unicode) C++ C++ (Unicode) C# DataFlex Delphi Foxpro Go Java Node.js Objective-C Perl PHP Extension PowerBuilder Powershell PureBasic Python CkPython Ruby SQL Server Swift TCL VB.NET VB6 VBScript Xojo
-- Important: See this note about {{-https://cknotes.com/sql-sp_oamethod-string-length-return-value-limitations/|||string length limitations for strings returned by sp_OAMethod calls-}}.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the {{-https://www.example-code.com/sql/default.asp|||warning about using nvarchar(max)-}}.
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @xml int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @xml OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OASetProperty @xml, 'Tag', 'soapenv:Envelope'
    DECLARE @success int
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:soapenv', 'http://schemas.xmlsoap.org/soap/envelope/'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:req', 'http://gov.fema.ipaws.services/caprequest'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:WL5G3N1', 'http://gov.fema.ipaws.services/IPAWS_CAPService/'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:capreq', 'http://gov.fema.ipaws.services/caprequest'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonUser', 'xml'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Header|WL5G3N1:request_Header|WL5G3N1:logonCogId', 'xml'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestAPI', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|WL5G3N1:getMessageTypeDef|req:requestOperation', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterName', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:comparisonOp', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:parameterValue', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|WL5G3N1:getMessageTypeDef|req:parameters|req:logicalOp', 'string'

    -- In a SOAP HTTP request, including the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) in the XML body is generally not required. 
    EXEC sp_OASetProperty @xml, 'EmitXmlDecl', 0
    DECLARE @soapRequestBody nvarchar(4000)
    EXEC sp_OAMethod @xml, 'GetXml', @soapRequestBody OUT

    DECLARE @endpoint nvarchar(4000)
    SELECT @endpoint = 'http://tdl.integration.aws.fema.gov/IPAWS_CAPService/IPAWS'
    DECLARE @soapAction nvarchar(4000)
    SELECT @soapAction = 'http://gov.fema.ipaws.services/IPAWS_CAPService/getMessage'
    --  For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
    DECLARE @contentType nvarchar(4000)
    SELECT @contentType = 'text/xml'

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT

    EXEC sp_OAMethod @http, 'ClearHeaders', NULL
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', @contentType
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'SOAPAction', @soapAction

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostXml', @resp OUT, @endpoint, @soapRequestBody, 'utf-8'
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed to send SOAP request.'
        EXEC @hr = sp_OADestroy @xml
        EXEC @hr = sp_OADestroy @http
        RETURN
      END

    -- Get the XML response body.
    DECLARE @responseXml int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @responseXml OUT

    EXEC sp_OAMethod @resp, 'GetBodyXml', @success OUT, @responseXml

    DECLARE @statusCode int
    EXEC sp_OAGetProperty @resp, 'StatusCode', @statusCode OUT

    PRINT 'response status code: ' + @statusCode

    EXEC @hr = sp_OADestroy @resp

    -- If the status code does not indicate succcess, then show the response XML,
    -- which probably contains error information.
    IF @statusCode <> 200
      BEGIN
        EXEC sp_OAMethod @responseXml, 'GetXml', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @xml
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @responseXml
        RETURN
      END

    EXEC sp_OAMethod @responseXml, 'GetXml', @sTmp0 OUT
    PRINT @sTmp0

    -- Parse the successful SOAP response XML.

    -- This is a sample of the response XML, but the namespace prefixes will be different.
    -- We can parse the result using "*" for the namespace prefixes (see below).

    DECLARE @identifier nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @identifier OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:identifier'
    DECLARE @sender nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @sender OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:sender'
    DECLARE @sent nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @sent OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:sent'
    DECLARE @status nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @status OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:status'
    DECLARE @msgType nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @msgType OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:msgType'
    DECLARE @source nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @source OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:source'
    DECLARE @scope nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @scope OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:scope'
    DECLARE @restriction nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @restriction OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:restriction'
    DECLARE @addresses nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @addresses OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:addresses'
    DECLARE @code nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @code OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:code'
    DECLARE @note nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @note OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:note'
    DECLARE @references nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @references OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:references'
    DECLARE @incidents nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @incidents OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:incidents'
    DECLARE @language nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @language OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:language'
    DECLARE @category nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @category OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:category'
    DECLARE @v_event nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @v_event OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:event'
    DECLARE @responseType nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @responseType OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:responseType'
    DECLARE @urgency nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @urgency OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:urgency'
    DECLARE @severity nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @severity OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:severity'
    DECLARE @certainty nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @certainty OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:certainty'
    DECLARE @audience nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @audience OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:audience'
    DECLARE @valueName nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @valueName OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:valueName'
    DECLARE @value nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @value OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:eventCode|*:value'
    DECLARE @effective nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @effective OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:effective'
    DECLARE @onset nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @onset OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:onset'
    DECLARE @expires nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @expires OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:expires'
    DECLARE @senderName nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @senderName OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:senderName'
    DECLARE @headline nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @headline OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:headline'
    DECLARE @description nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @description OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:description'
    DECLARE @instruction nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @instruction OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:instruction'
    DECLARE @web nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @web OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:web'
    DECLARE @contact nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @contact OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:contact'
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @valueName OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:parameter|*:valueName'
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @value OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:parameter|*:value'
    DECLARE @resourceDesc nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @resourceDesc OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:resourceDesc'
    DECLARE @mimeType nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @mimeType OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:mimeType'
    DECLARE @size nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @size OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:size'
    DECLARE @uri nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @uri OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:uri'
    DECLARE @derefUri nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @derefUri OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:derefUri'
    DECLARE @digest nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @digest OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:resource|*:digest'
    DECLARE @areaDesc nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @areaDesc OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:areaDesc'
    DECLARE @polygon nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @polygon OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:polygon'
    DECLARE @circle nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @circle OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:circle'
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @valueName OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:geocode|*:valueName'
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @value OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:geocode|*:value'
    DECLARE @altitude nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @altitude OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:altitude'
    DECLARE @ceiling nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @ceiling OUT, '*:Body|*:messageResponseTypeDef|*:alert|*:info|*:area|*:ceiling'

    EXEC @hr = sp_OADestroy @xml
    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @responseXml


END
GO
Request XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://gov.fema.ipaws.services/caprequest" xmlns:WL5G3N1="http://gov.fema.ipaws.services/IPAWS_CAPService/" xmlns:capreq="http://gov.fema.ipaws.services/caprequest">
    <soapenv:Header>
        <WL5G3N1:request_Header>
            <WL5G3N1:logonUser>xml</WL5G3N1:logonUser>
            <WL5G3N1:logonCogId>xml</WL5G3N1:logonCogId>
        </WL5G3N1:request_Header>
    </soapenv:Header>
    <soapenv:Body>
        <WL5G3N1:getMessageTypeDef>
            <req:requestAPI>string</req:requestAPI>
            <req:requestOperation>string</req:requestOperation>
            <req:parameters>
                <req:parameterName>string</req:parameterName>
                <req:comparisonOp>string</req:comparisonOp>
                <req:parameterValue>string</req:parameterValue>
                <req:logicalOp>string</req:logicalOp>
            </req:parameters>
        </WL5G3N1:getMessageTypeDef>
    </soapenv:Body>
</soapenv:Envelope>
Response XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:WL5G3N1="http://gov.fema.ipaws.services/IPAWS_CAPService/" xmlns:cap="urn:oasis:names:tc:emergency:cap:1.2">
    <soapenv:Header/>
    <soapenv:Body>
        <WL5G3N1:messageResponseTypeDef>
            <cap:alert>
                <cap:identifier>xml</cap:identifier>
                <cap:sender>xml</cap:sender>
                <cap:sent>dateTime</cap:sent>
                <cap:status>Actual</cap:status>
                <cap:msgType>Alert</cap:msgType>
                <cap:source>xml</cap:source>
                <cap:scope>Public</cap:scope>
                <cap:restriction>xml</cap:restriction>
                <cap:addresses>xml</cap:addresses>
                <cap:code>xml</cap:code>
                <cap:note>xml</cap:note>
                <cap:references>xml</cap:references>
                <cap:incidents>xml</cap:incidents>
                <cap:info>
                    <cap:language>xml</cap:language>
                    <cap:category>Geo</cap:category>
                    <cap:event>xml</cap:event>
                    <cap:responseType>Shelter</cap:responseType>
                    <cap:urgency>Immediate</cap:urgency>
                    <cap:severity>Extreme</cap:severity>
                    <cap:certainty>Observed</cap:certainty>
                    <cap:audience>xml</cap:audience>
                    <cap:eventCode>
                        <cap:valueName>xml</cap:valueName>
                        <cap:value>xml</cap:value>
                    </cap:eventCode>
                    <cap:effective>dateTime</cap:effective>
                    <cap:onset>dateTime</cap:onset>
                    <cap:expires>dateTime</cap:expires>
                    <cap:senderName>xml</cap:senderName>
                    <cap:headline>xml</cap:headline>
                    <cap:description>xml</cap:description>
                    <cap:instruction>xml</cap:instruction>
                    <cap:web>xml</cap:web>
                    <cap:contact>xml</cap:contact>
                    <cap:parameter>
                        <cap:valueName>xml</cap:valueName>
                        <cap:value>xml</cap:value>
                    </cap:parameter>
                    <cap:resource>
                        <cap:resourceDesc>xml</cap:resourceDesc>
                        <cap:mimeType>xml</cap:mimeType>
                        <cap:size>xml</cap:size>
                        <cap:uri>xml</cap:uri>
                        <cap:derefUri>xml</cap:derefUri>
                        <cap:digest>xml</cap:digest>
                    </cap:resource>
                    <cap:area>
                        <cap:areaDesc>xml</cap:areaDesc>
                        <cap:polygon>xml</cap:polygon>
                        <cap:circle>xml</cap:circle>
                        <cap:geocode>
                            <cap:valueName>xml</cap:valueName>
                            <cap:value>xml</cap:value>
                        </cap:geocode>
                        <cap:altitude>xml</cap:altitude>
                        <cap:ceiling>xml</cap:ceiling>
                    </cap:area>
                </cap:info>
            </cap:alert>
        </WL5G3N1:messageResponseTypeDef>
    </soapenv:Body>
</soapenv:Envelope>