SOAP WSDL Generate Code

OrganisationServiceWsHttpEndpoint / Search

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:tra', 'http://training.gov.au/services/12/'
    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:arr', 'http://schemas.microsoft.com/2003/10/Serialization/Arrays'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Header', ''
    EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'soap:Body|tra:Search|tra:request|tra:PageNumber', 1042
    EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'soap:Body|tra:Search|tra:request|tra:PageSize', 1042
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|tra:Search|tra:request|tra:ClassificationFilters|tra:ClassificationFilter|tra:Scheme', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|tra:Search|tra:request|tra:ClassificationFilters|tra:ClassificationFilter|tra:Values|arr:string', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|tra:Search|tra:request|tra:CurrentNamesOnly', 'true'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|tra:Search|tra:request|tra:ExcludeNotRtos', 'true'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|tra:Search|tra:request|tra:ExcludeRtoWithoutActiveRegistration', 'true'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|tra:Search|tra:request|tra:Filter', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|tra:Search|tra:request|tra:IncludeCode', 'true'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|tra:Search|tra:request|tra:IncludeLegacyData', 'true'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soap:Body|tra:Search|tra:request|tra:RegistrationManagers|arr:string', '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://ws.staging.training.gov.au/Deewr.Tga.WebServices/OrganisationServiceV12.svc/Organisation12'
    DECLARE @soapAction nvarchar(4000)
    SELECT @soapAction = 'http://training.gov.au/services/12/IOrganisationService/Search'
    --  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 @Count int
    EXEC sp_OAMethod @responseXml, 'GetChildIntValue', @Count OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Count'
    DECLARE @PageNumber int
    EXEC sp_OAMethod @responseXml, 'GetChildIntValue', @PageNumber OUT, '*:Body|*:SearchResponse|*:SearchResult|*:PageNumber'
    DECLARE @PageSize int
    EXEC sp_OAMethod @responseXml, 'GetChildIntValue', @PageSize OUT, '*:Body|*:SearchResponse|*:SearchResult|*:PageSize'
    DECLARE @Code nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @Code OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:Code'
    DECLARE @DataManagerCode nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @DataManagerCode OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:DataManagerCode'
    DECLARE @HasActiveRegistration nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @HasActiveRegistration OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:HasActiveRegistration'
    DECLARE @IsLegacyData nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @IsLegacyData OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:IsLegacyData'
    DECLARE @LegalPersonName nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @LegalPersonName OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:LegalPersonName'
    DECLARE @RegistrationStatus nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @RegistrationStatus OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:RegistrationStatus'
    DECLARE @TradingName nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @TradingName OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:TradingName'
    DECLARE @DateTime nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @DateTime OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:UpdatedDate|*:DateTime'
    DECLARE @OffsetMinutes int
    EXEC sp_OAMethod @responseXml, 'GetChildIntValue', @OffsetMinutes OUT, '*:Body|*:SearchResponse|*:SearchResult|*:Results|*:OrganisationSearchResultItem|*:UpdatedDate|*:OffsetMinutes'

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


END
GO
Request XML
<soap:Envelope xmlns:tra="http://training.gov.au/services/12/" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <soap:Header/>
    <soap:Body>
        <tra:Search>
            <tra:request>
                <tra:PageNumber>1042</tra:PageNumber>
                <tra:PageSize>1042</tra:PageSize>
                <tra:ClassificationFilters>
                    <tra:ClassificationFilter>
                        <tra:Scheme>string</tra:Scheme>
                        <tra:Values>
                            <arr:string>string</arr:string>
                        </tra:Values>
                    </tra:ClassificationFilter>
                </tra:ClassificationFilters>
                <tra:CurrentNamesOnly>true</tra:CurrentNamesOnly>
                <tra:ExcludeNotRtos>true</tra:ExcludeNotRtos>
                <tra:ExcludeRtoWithoutActiveRegistration>true</tra:ExcludeRtoWithoutActiveRegistration>
                <tra:Filter>string</tra:Filter>
                <tra:IncludeCode>true</tra:IncludeCode>
                <tra:IncludeLegacyData>true</tra:IncludeLegacyData>
                <tra:RegistrationManagers>
                    <arr:string>string</arr:string>
                </tra:RegistrationManagers>
            </tra:request>
        </tra:Search>
    </soap:Body>
</soap:Envelope>
Response XML
<soap:Envelope xmlns:sys="http://schemas.datacontract.org/2004/07/System" xmlns:tra="http://training.gov.au/services/12/" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header/>
    <soap:Body>
        <tra:SearchResponse>
            <tra:SearchResult>
                <tra:Count>1042</tra:Count>
                <tra:PageNumber>1042</tra:PageNumber>
                <tra:PageSize>1042</tra:PageSize>
                <tra:Results>
                    <tra:OrganisationSearchResultItem>
                        <tra:Code>string</tra:Code>
                        <tra:DataManagerCode>string</tra:DataManagerCode>
                        <tra:HasActiveRegistration>true</tra:HasActiveRegistration>
                        <tra:IsLegacyData>true</tra:IsLegacyData>
                        <tra:LegalPersonName>string</tra:LegalPersonName>
                        <tra:RegistrationStatus>string</tra:RegistrationStatus>
                        <tra:TradingName>string</tra:TradingName>
                        <tra:UpdatedDate>
                            <sys:DateTime>dateTime</sys:DateTime>
                            <sys:OffsetMinutes>442</sys:OffsetMinutes>
                        </tra:UpdatedDate>
                    </tra:OrganisationSearchResultItem>
                </tra:Results>
            </tra:SearchResult>
        </tra:SearchResponse>
    </soap:Body>
</soap:Envelope>