SOAP WSDL Generate Code

CheckpointServiceSoap12 / VratiSubjekt

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', 'soap:Envelope'
    DECLARE @success int
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:soap', 'http://www.w3.org/2003/05/soap-envelope'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:ser', 'service.checkpoint.rs'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Header', ''
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|ser:VratiSubjekt|ser:mbr', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|ser:VratiSubjekt|ser:pib', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|ser:VratiSubjekt|ser:naziv', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|ser:VratiSubjekt|ser:token', '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 = 'https://service.checkpoint.rs/service.asmx'
    DECLARE @soapAction nvarchar(4000)
    SELECT @soapAction = 'service.checkpoint.rs/VratiSubjekt'
    --  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 @ID int
    EXEC sp_OAMethod @responseXml, 'GetChildIntValue', @ID OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:ID'
    DECLARE @MBR nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @MBR OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:MBR'
    DECLARE @PIB nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @PIB OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:PIB'
    DECLARE @Naziv_skraceni nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @Naziv_skraceni OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:Naziv_skraceni'
    DECLARE @Naziv nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @Naziv OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:Naziv'
    DECLARE @Adresa nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @Adresa OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:Adresa'
    DECLARE @Mesto nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @Mesto OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:Mesto'
    DECLARE @Opstina nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @Opstina OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:Opstina'
    DECLARE @Status_APR nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @Status_APR OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:Status_APR'
    DECLARE @Jbkjs nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @Jbkjs OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:Jbkjs'
    DECLARE @Postanski_broj nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @Postanski_broj OUT, '*:Body|*:VratiSubjektResponse|*:VratiSubjektResult|*:SubjektPretraga|*:Postanski_broj'

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


END
GO
Request XML
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="service.checkpoint.rs">
    <soap:Header/>
    <soap:Body>
        <ser:VratiSubjekt>
            <ser:mbr>string</ser:mbr>
            <ser:pib>string</ser:pib>
            <ser:naziv>string</ser:naziv>
            <ser:token>string</ser:token>
        </ser:VratiSubjekt>
    </soap:Body>
</soap:Envelope>
Response XML
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="service.checkpoint.rs">
    <soap:Header/>
    <soap:Body>
        <ser:VratiSubjektResponse>
            <ser:VratiSubjektResult>
                <ser:SubjektPretraga>
                    <ser:ID>1042</ser:ID>
                    <ser:MBR>string</ser:MBR>
                    <ser:PIB>string</ser:PIB>
                    <ser:Naziv_skraceni>string</ser:Naziv_skraceni>
                    <ser:Naziv>string</ser:Naziv>
                    <ser:Adresa>string</ser:Adresa>
                    <ser:Mesto>string</ser:Mesto>
                    <ser:Opstina>string</ser:Opstina>
                    <ser:Status_APR>string</ser:Status_APR>
                    <ser:Jbkjs>string</ser:Jbkjs>
                    <ser:Postanski_broj>string</ser:Postanski_broj>
                </ser:SubjektPretraga>
            </ser:VratiSubjektResult>
        </ser:VratiSubjektResponse>
    </soap:Body>
</soap:Envelope>