Use ChilkatAx-9.5.0-win32.pkg
Procedure TestHandle hoXml
Boolean iSuccess
String sSoapRequestBody
String sEndpoint
String sSoapAction
String sContentType
Handle hoHttp
Variant vResp
Handle hoResp
Variant vResponseXml
Handle hoResponseXml
Integer iStatusCode
String sActonId
String sBeginDate
String sCountyName
String sElevation
String sEndDate
String sFipsCountryCd
String sFipsCountyCd
String sFipsStateNumber
String sHuc
String sHud
String sLatitude
String sLongitude
String sName
String sShefId
String sStationDataTimeZone
String sStationTimeZone
String sStationTriplet
String sTemp1
Boolean bTemp1
Get Create (RefClass(cComChilkatXml)) To hoXml
If (Not(IsComObjectCreated(hoXml))) BeginSend CreateComObject of hoXml
EndSetComTagOf hoXml To"soapenv:Envelope"GetComAddAttributeOf hoXml "xmlns:awd""http://www.wcc.nrcs.usda.gov/ns/awdbWebService"To iSuccess
GetComAddAttributeOf hoXml "xmlns:soapenv""http://schemas.xmlsoap.org/soap/envelope/"To iSuccess
SendComUpdateChildContentTo hoXml "soapenv:Header"""SendComUpdateChildContentTo hoXml "soapenv:Body|awd:getStationMetadataMultiple|awd:stationTriplets""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. SetComEmitXmlDeclOf hoXml ToFalseGetComGetXmlOf 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))) BeginSend CreateComObject of hoHttp
EndSendComClearHeadersTo hoHttp
SendComSetRequestHeaderTo hoHttp "Content-Type" sContentType
SendComSetRequestHeaderTo hoHttp "SOAPAction" sSoapAction
GetComPostXmlOf hoHttp sEndpoint sSoapRequestBody "utf-8"To vResp
If (IsComObject(vResp)) BeginGet Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
EndGetComLastMethodSuccessOf hoHttp To bTemp1
If (bTemp1 = False) BeginGetComLastErrorTextOf hoHttp To sTemp1
Showln sTemp1
Showln"Failed to send SOAP request."Procedure_ReturnEnd// Get the XML response body.Get Create (RefClass(cComChilkatXml)) To hoResponseXml
If (Not(IsComObjectCreated(hoResponseXml))) BeginSend CreateComObject of hoResponseXml
End
Get pvComObject of hoResponseXml to vResponseXml
GetComGetBodyXmlOf hoResp vResponseXml To iSuccess
GetComStatusCodeOf 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) BeginGetComGetXmlOf hoResponseXml To sTemp1
Showln sTemp1
Procedure_ReturnEndGetComGetXmlOf 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).GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:actonId"To sActonId
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:beginDate"To sBeginDate
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:countyName"To sCountyName
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:elevation"To sElevation
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:endDate"To sEndDate
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:fipsCountryCd"To sFipsCountryCd
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:fipsCountyCd"To sFipsCountyCd
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:fipsStateNumber"To sFipsStateNumber
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:huc"To sHuc
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:hud"To sHud
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:latitude"To sLatitude
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:longitude"To sLongitude
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:name"To sName
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:shefId"To sShefId
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:stationDataTimeZone"To sStationDataTimeZone
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:stationTimeZone"To sStationTimeZone
GetComGetChildContentOf hoResponseXml "*:Body|*:getStationMetadataMultipleResponse|*:return|*:stationTriplet"To sStationTriplet
End_Procedure