SOAP WSDL Generate Code

FinaInvoiceB2GBinding / changeB2GIncomingInvoiceStatus

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', 'http://fina.hr/eracun/b2g/invoicewebservicecomponents/v0.1'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:v0', 'http://fina.hr/eracun/b2g/ChangeB2GIncomingInvoiceStatus/v0.1'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:b2gEracImpl', 'http://fina.hr/eracun/b2g/ws/erp/v0.1'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Header', ''
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|HeaderBuyer|MessageID', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|HeaderBuyer|BuyerID', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|HeaderBuyer|AdditionalBuyerID', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|HeaderBuyer|MessageType', 123
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|HeaderBuyer|MessageAttributes', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|v0:Data|v0:B2GIncomingInvoiceStatus|v0:InvoiceID', 123
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|v0:Data|v0:B2GIncomingInvoiceStatus|InvoiceStatus|StatusCode', 'RECEIVED'
    EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|v0:Data|v0:B2GIncomingInvoiceStatus|InvoiceStatus|CodeReason', 1042
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|v0:Data|v0:B2GIncomingInvoiceStatus|InvoiceStatus|Note', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|v0:Data|v0:B2GIncomingInvoiceStatus|InvoiceStatus|PartialAmount', '99.0'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|v0:ChangeB2GIncomingInvoiceStatusMsg|v0:Data|v0:B2GIncomingInvoiceStatus|InvoiceStatus|DocumentCurrencyCode', '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://prez.fina.hr/B2GFinaInvoiceWebService/services/B2GFinaInvoiceWebService'
    DECLARE @soapAction nvarchar(4000)
    SELECT @soapAction = 'http://fina.hr/eracun/b2g/ChangeB2GIncomingInvoiceStatus'
    --  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 @Envelope_xmlns nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetAttrValue', @Envelope_xmlns OUT, 'xmlns'
    DECLARE @MessageID nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @MessageID OUT, '*:Body|*:ChangeB2GIncomingInvoiceStatusAckMsg|MessageAck|MessageID'
    DECLARE @MessageAckID nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @MessageAckID OUT, '*:Body|*:ChangeB2GIncomingInvoiceStatusAckMsg|MessageAck|MessageAckID'
    DECLARE @MessageType int
    EXEC sp_OAMethod @responseXml, 'GetChildIntValue', @MessageType OUT, '*:Body|*:ChangeB2GIncomingInvoiceStatusAckMsg|MessageAck|MessageType'
    DECLARE @AckStatus nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @AckStatus OUT, '*:Body|*:ChangeB2GIncomingInvoiceStatusAckMsg|MessageAck|AckStatus'
    DECLARE @AckStatusCode int
    EXEC sp_OAMethod @responseXml, 'GetChildIntValue', @AckStatusCode OUT, '*:Body|*:ChangeB2GIncomingInvoiceStatusAckMsg|MessageAck|AckStatusCode'
    DECLARE @AckStatusText nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @AckStatusText OUT, '*:Body|*:ChangeB2GIncomingInvoiceStatusAckMsg|MessageAck|AckStatusText'
    DECLARE @ErrorCode nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @ErrorCode OUT, '*:Body|*:ChangeB2GIncomingInvoiceStatusAckMsg|Error|ErrorCode'
    DECLARE @ErrorMessage nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @ErrorMessage OUT, '*:Body|*:ChangeB2GIncomingInvoiceStatusAckMsg|Error|ErrorMessage'
    DECLARE @ErrorText nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @ErrorText OUT, '*:Body|*:ChangeB2GIncomingInvoiceStatusAckMsg|Error|ErrorText'

    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="http://fina.hr/eracun/b2g/invoicewebservicecomponents/v0.1" xmlns:v0="http://fina.hr/eracun/b2g/ChangeB2GIncomingInvoiceStatus/v0.1" xmlns:b2gEracImpl="http://fina.hr/eracun/b2g/ws/erp/v0.1">
    <soapenv:Header/>
    <soapenv:Body>
        <v0:ChangeB2GIncomingInvoiceStatusMsg>
            <HeaderBuyer>
                <MessageID>string</MessageID>
                <BuyerID>string</BuyerID>
                <AdditionalBuyerID>string</AdditionalBuyerID>
                <MessageType>123</MessageType>
                <MessageAttributes>string</MessageAttributes>
            </HeaderBuyer>
            <v0:Data>
                <v0:B2GIncomingInvoiceStatus>
                    <v0:InvoiceID>123</v0:InvoiceID>
                    <InvoiceStatus>
                        <StatusCode>RECEIVED</StatusCode>
                        <CodeReason>1042</CodeReason>
                        <Note>string</Note>
                        <PartialAmount>99.0</PartialAmount>
                        <DocumentCurrencyCode>string</DocumentCurrencyCode>
                    </InvoiceStatus>
                </v0:B2GIncomingInvoiceStatus>
            </v0:Data>
        </v0:ChangeB2GIncomingInvoiceStatusMsg>
    </soapenv:Body>
</soapenv:Envelope>
Response XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://fina.hr/eracun/b2g/invoicewebservicecomponents/v0.1" xmlns:v0="http://fina.hr/eracun/b2g/ChangeB2GIncomingInvoiceStatus/v0.1" xmlns:b2gEracImpl="http://fina.hr/eracun/b2g/ws/erp/v0.1">
    <soapenv:Header/>
    <soapenv:Body>
        <v0:ChangeB2GIncomingInvoiceStatusAckMsg>
            <MessageAck>
                <MessageID>string</MessageID>
                <MessageAckID>string</MessageAckID>
                <MessageType>123</MessageType>
                <AckStatus>ACCEPTED</AckStatus>
                <AckStatusCode>1042</AckStatusCode>
                <AckStatusText>string</AckStatusText>
            </MessageAck>
            <Error>
                <ErrorCode>string</ErrorCode>
                <ErrorMessage>string</ErrorMessage>
                <ErrorText>string</ErrorText>
            </Error>
        </v0:ChangeB2GIncomingInvoiceStatusAckMsg>
    </soapenv:Body>
</soapenv:Envelope>