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 sValidateResponseOutput_success
String sValidateResponseOutput_interrupted
String sValidateResponseOutput_mostSevereErrorLevel
String sResult_success
String sResult_artifactType
String sResult_artifactPath
String sItem_errorLevel
String sItem_errorID
String sItem_errorFieldName
String sItem_errorLocation
String sItem_errorText
String sItem_test
String sException
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:pep""http://peppol.helger.com/ws/documentvalidationservice/201701/"To iSuccess
GetComAddAttributeOf hoXml "xmlns:soapenv""http://schemas.xmlsoap.org/soap/envelope/"To iSuccess
SendComUpdateChildContentTo hoXml "soapenv:Header"""GetComUpdateAttrAtOf hoXml "soapenv:Body|pep:validateRequestInput"True"VESID""?"To iSuccess
GetComUpdateAttrAtOf hoXml "soapenv:Body|pep:validateRequestInput"True"displayLocale""?"To iSuccess
SendComUpdateChildContentTo hoXml "soapenv:Body|pep:validateRequestInput|pep:XML""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://peppol.helger.com/wsdvs"To sEndpoint
Move"validate"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).GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|(success)"To sValidateResponseOutput_success
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|(interrupted)"To sValidateResponseOutput_interrupted
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|(mostSevereErrorLevel)"To sValidateResponseOutput_mostSevereErrorLevel
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|(success)"To sResult_success
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|(artifactType)"To sResult_artifactType
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|(artifactPath)"To sResult_artifactPath
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|*:Item|(errorLevel)"To sItem_errorLevel
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|*:Item|(errorID)"To sItem_errorID
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|*:Item|(errorFieldName)"To sItem_errorFieldName
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|*:Item|(errorLocation)"To sItem_errorLocation
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|*:Item|(errorText)"To sItem_errorText
GetComChilkatPathOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|*:Item|(test)"To sItem_test
GetComGetChildContentOf hoResponseXml "*:Body|*:validateResponseOutput|*:Result|*:Item|*:Exception"To sException
End_Procedure