SOAP WSDL Generate Code

AwdbWebServiceSoapBinding / getForecastsByPubDate

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
Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoXml
    Boolean iSuccess
    String sSoapRequestBody
    String sEndpoint
    String sSoapAction
    String sContentType
    Handle hoHttp
    Variant vResp
    Handle hoResp
    Variant vResponseXml
    Handle hoResponseXml
    Integer iStatusCode
    String sCalculationDate
    String sElementCd
    Integer iExceedenceProbabilities
    String sExceedenceValues
    String sForecastPeriod
    String sPeriodAverage
    String sPublicationDate
    String sStationTriplet
    String sUnitCd
    String sTemp1
    Boolean bTemp1

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Set ComTag Of hoXml To "soapenv:Envelope"
    Get ComAddAttribute Of hoXml "xmlns:awd" "http://www.wcc.nrcs.usda.gov/ns/awdbWebService" To iSuccess
    Get ComAddAttribute Of hoXml "xmlns:soapenv" "http://schemas.xmlsoap.org/soap/envelope/" To iSuccess
    Send ComUpdateChildContent To hoXml "soapenv:Header" ""
    Send ComUpdateChildContent To hoXml "soapenv:Body|awd:getForecastsByPubDate|awd:stationTriplet" "string"
    Send ComUpdateChildContent To hoXml "soapenv:Body|awd:getForecastsByPubDate|awd:elementCd" "string"
    Send ComUpdateChildContent To hoXml "soapenv:Body|awd:getForecastsByPubDate|awd:forecastPeriod" "string"
    Send ComUpdateChildContent To hoXml "soapenv:Body|awd:getForecastsByPubDate|awd:beginPublicationDate" "string"
    Send ComUpdateChildContent To hoXml "soapenv:Body|awd:getForecastsByPubDate|awd:endPublicationDate" "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. 
    Set ComEmitXmlDecl Of hoXml To False
    Get ComGetXml Of hoXml To sSoapRequestBody

    Move "https://wcc.sc.egov.usda.gov/awdbWebService/services" To sEndpoint
    Move "" To sSoapAction
    //  For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
    Move "text/xml" To sContentType

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Send ComClearHeaders To hoHttp
    Send ComSetRequestHeader To hoHttp "Content-Type" sContentType
    Send ComSetRequestHeader To hoHttp "SOAPAction" sSoapAction

    Get ComPostXml Of hoHttp sEndpoint sSoapRequestBody "utf-8" To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed to send SOAP request."
        Procedure_Return
    End

    // Get the XML response body.
    Get Create (RefClass(cComChilkatXml)) To hoResponseXml
    If (Not(IsComObjectCreated(hoResponseXml))) Begin
        Send CreateComObject of hoResponseXml
    End
    Get pvComObject of hoResponseXml to vResponseXml
    Get ComGetBodyXml Of hoResp vResponseXml To iSuccess

    Get ComStatusCode Of hoResp To iStatusCode
    Showln "response status code: " iStatusCode

    Send Destroy of hoResp

    // If the status code does not indicate succcess, then show the response XML,
    // which probably contains error information.
    If (iStatusCode <> 200) Begin
        Get ComGetXml Of hoResponseXml To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComGetXml Of hoResponseXml To sTemp1
    Showln sTemp1

    // 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).

    Get ComGetChildContent Of hoResponseXml "*:Body|*:getForecastsByPubDateResponse|*:return|*:calculationDate" To sCalculationDate
    Get ComGetChildContent Of hoResponseXml "*:Body|*:getForecastsByPubDateResponse|*:return|*:elementCd" To sElementCd
    Get ComGetChildIntValue Of hoResponseXml "*:Body|*:getForecastsByPubDateResponse|*:return|*:exceedenceProbabilities" To iExceedenceProbabilities
    Get ComGetChildContent Of hoResponseXml "*:Body|*:getForecastsByPubDateResponse|*:return|*:exceedenceValues" To sExceedenceValues
    Get ComGetChildContent Of hoResponseXml "*:Body|*:getForecastsByPubDateResponse|*:return|*:forecastPeriod" To sForecastPeriod
    Get ComGetChildContent Of hoResponseXml "*:Body|*:getForecastsByPubDateResponse|*:return|*:periodAverage" To sPeriodAverage
    Get ComGetChildContent Of hoResponseXml "*:Body|*:getForecastsByPubDateResponse|*:return|*:publicationDate" To sPublicationDate
    Get ComGetChildContent Of hoResponseXml "*:Body|*:getForecastsByPubDateResponse|*:return|*:stationTriplet" To sStationTriplet
    Get ComGetChildContent Of hoResponseXml "*:Body|*:getForecastsByPubDateResponse|*:return|*:unitCd" To sUnitCd


End_Procedure
Request XML
<soapenv:Envelope xmlns:awd="http://www.wcc.nrcs.usda.gov/ns/awdbWebService" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
        <awd:getForecastsByPubDate>
            <awd:stationTriplet>string</awd:stationTriplet>
            <awd:elementCd>string</awd:elementCd>
            <awd:forecastPeriod>string</awd:forecastPeriod>
            <awd:beginPublicationDate>string</awd:beginPublicationDate>
            <awd:endPublicationDate>string</awd:endPublicationDate>
        </awd:getForecastsByPubDate>
    </soapenv:Body>
</soapenv:Envelope>
Response XML
<soapenv:Envelope xmlns:awd="http://www.wcc.nrcs.usda.gov/ns/awdbWebService" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
        <awd:getForecastsByPubDateResponse>
            <awd:return>
                <awd:calculationDate>string</awd:calculationDate>
                <awd:elementCd>string</awd:elementCd>
                <awd:exceedenceProbabilities>1042</awd:exceedenceProbabilities>
                <awd:exceedenceValues>99.0</awd:exceedenceValues>
                <awd:forecastPeriod>string</awd:forecastPeriod>
                <awd:periodAverage>99.0</awd:periodAverage>
                <awd:publicationDate>string</awd:publicationDate>
                <awd:stationTriplet>string</awd:stationTriplet>
                <awd:unitCd>string</awd:unitCd>
            </awd:return>
        </awd:getForecastsByPubDateResponse>
    </soapenv:Body>
</soapenv:Envelope>