SOAP WSDL Generate Code

AwdbWebServiceSoapBinding / getData

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
#include <CkXmlW.h>
#include <CkHttpW.h>
#include <CkHttpResponseW.h>

void ChilkatSample(void)
    {
    CkXmlW xml;
    xml.put_Tag(L"soapenv:Envelope");
    xml.AddAttribute(L"xmlns:awd",L"http://www.wcc.nrcs.usda.gov/ns/awdbWebService");
    xml.AddAttribute(L"xmlns:soapenv",L"http://schemas.xmlsoap.org/soap/envelope/");
    xml.UpdateChildContent(L"soapenv:Header",L"");
    xml.UpdateChildContent(L"soapenv:Body|awd:getData|awd:stationTriplets",L"string");
    xml.UpdateChildContent(L"soapenv:Body|awd:getData|awd:elementCd",L"string");
    xml.UpdateChildContentInt(L"soapenv:Body|awd:getData|awd:ordinal",1042);
    xml.UpdateChildContent(L"soapenv:Body|awd:getData|awd:heightDepth|awd:unitCd",L"string");
    xml.UpdateChildContent(L"soapenv:Body|awd:getData|awd:heightDepth|awd:value",L"99.0");
    xml.UpdateChildContent(L"soapenv:Body|awd:getData|awd:duration",L"DAILY");
    xml.UpdateChildContent(L"soapenv:Body|awd:getData|awd:getFlags",L"true");
    xml.UpdateChildContent(L"soapenv:Body|awd:getData|awd:beginDate",L"string");
    xml.UpdateChildContent(L"soapenv:Body|awd:getData|awd:endDate",L"string");
    xml.UpdateChildContent(L"soapenv:Body|awd:getData|awd:alwaysReturnDailyFeb29",L"true");

    // In a SOAP HTTP request, including the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) in the XML body is generally not required. 
    xml.put_EmitXmlDecl(false);
    const wchar_t *soapRequestBody = xml.getXml();

    const wchar_t *endpoint = L"https://wcc.sc.egov.usda.gov/awdbWebService/services";
    const wchar_t *soapAction = L"";
    //  For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
    const wchar_t *contentType = L"text/xml";

    CkHttpW http;

    http.ClearHeaders();
    http.SetRequestHeader(L"Content-Type",contentType);
    http.SetRequestHeader(L"SOAPAction",soapAction);

    CkHttpResponseW *resp = http.PostXml(endpoint,soapRequestBody,L"utf-8");
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        wprintf(L"Failed to send SOAP request.\n");
        return;
    }

    // Get the XML response body.
    CkXmlW responseXml;
    resp->GetBodyXml(responseXml);

    int statusCode = resp->get_StatusCode();
    wprintf(L"response status code: %d\n",statusCode);

    delete resp;

    // If the status code does not indicate succcess, then show the response XML,
    // which probably contains error information.
    if (statusCode != 200) {
        wprintf(L"%s\n",responseXml.getXml());
        return;
    }

    wprintf(L"%s\n",responseXml.getXml());

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

    const wchar_t *beginDate = responseXml.getChildContent(L"*:Body|*:getDataResponse|*:return|*:beginDate");
    const wchar_t *collectionDates = responseXml.getChildContent(L"*:Body|*:getDataResponse|*:return|*:collectionDates");
    const wchar_t *duration = responseXml.getChildContent(L"*:Body|*:getDataResponse|*:return|*:duration");
    const wchar_t *endDate = responseXml.getChildContent(L"*:Body|*:getDataResponse|*:return|*:endDate");
    const wchar_t *flags = responseXml.getChildContent(L"*:Body|*:getDataResponse|*:return|*:flags");
    const wchar_t *stationTriplet = responseXml.getChildContent(L"*:Body|*:getDataResponse|*:return|*:stationTriplet");
    const wchar_t *values = responseXml.getChildContent(L"*:Body|*:getDataResponse|*:return|*:values");
    }
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:getData>
            <awd:stationTriplets>string</awd:stationTriplets>
            <awd:elementCd>string</awd:elementCd>
            <awd:ordinal>1042</awd:ordinal>
            <awd:heightDepth>
                <awd:unitCd>string</awd:unitCd>
                <awd:value>99.0</awd:value>
            </awd:heightDepth>
            <awd:duration>DAILY</awd:duration>
            <awd:getFlags>true</awd:getFlags>
            <awd:beginDate>string</awd:beginDate>
            <awd:endDate>string</awd:endDate>
            <awd:alwaysReturnDailyFeb29>true</awd:alwaysReturnDailyFeb29>
        </awd:getData>
    </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:getDataResponse>
            <awd:return>
                <awd:beginDate>string</awd:beginDate>
                <awd:collectionDates>string</awd:collectionDates>
                <awd:duration>DAILY</awd:duration>
                <awd:endDate>string</awd:endDate>
                <awd:flags>string</awd:flags>
                <awd:stationTriplet>string</awd:stationTriplet>
                <awd:values>99.0</awd:values>
            </awd:return>
        </awd:getDataResponse>
    </soapenv:Body>
</soapenv:Envelope>