require 'chilkat'
xml = Chilkat::CkXml.new()
xml.put_Tag("soapenv:Envelope")
xml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/")
xml.AddAttribute("xmlns:dpd","http://dpdservices.dpd.com.pl/")
xml.UpdateChildContent("soapenv:Header","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:parcels|dpd:reference","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:parcels|dpd:weight","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:parcels|dpd:sizeX","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:parcels|dpd:sizeY","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:parcels|dpd:sizeZ","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:parcels|dpd:content","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:parcels|dpd:customerData1","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:parcels|dpd:customerData2","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:parcels|dpd:customerData3","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:payerType","RECEIVER")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:receiver|dpd:address","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:receiver|dpd:city","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:receiver|dpd:company","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:receiver|dpd:countryCode","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:receiver|dpd:email","string")
xml.UpdateChildContentInt("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:receiver|dpd:fid",1042)
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:receiver|dpd:name","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:receiver|dpd:phone","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:receiver|dpd:postalCode","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:ref1","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:ref2","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:ref3","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:reference","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:sender|dpd:address","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:sender|dpd:city","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:sender|dpd:company","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:sender|dpd:countryCode","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:sender|dpd:email","string")
xml.UpdateChildContentInt("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:sender|dpd:fid",1042)
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:sender|dpd:name","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:sender|dpd:phone","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:sender|dpd:postalCode","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:carryIn","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:cod|dpd:amount","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:cod|dpd:currency","PLN")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:cud","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:declaredValue|dpd:amount","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:declaredValue|dpd:currency","PLN")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:dedicatedDelivery","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:documentsInternational","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:dox","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:dpdExpress","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:dpdPickup|dpd:pudo","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:duty|dpd:amount","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:duty|dpd:currency","PLN")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:guarantee|dpd:type","TIME0930")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:guarantee|dpd:value","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:inPers","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:pallet","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:privPers","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:rod","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:selfCol|dpd:receiver","PRIV")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:tires","")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:services|dpd:tiresExport","")
xml.UpdateChildContentInt("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:openUMLFeV3|dpd:packages|dpd:thirdPartyFID",1042)
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:pkgNumsGenerationPolicyV1","STOP_ON_FIRST_ERROR")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:langCode","string")
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:authDataV1|dpd:login","string")
xml.UpdateChildContentInt("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:authDataV1|dpd:masterFid",1042)
xml.UpdateChildContent("soapenv:Body|dpd:generatePackagesNumbersV4|dpd:authDataV1|dpd:password","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.
xml.put_EmitXmlDecl(false)
soapRequestBody = xml.getXml()
endpoint = "https://dpdservicesdemo.dpd.com.pl/DPDPackageObjServicesService/DPDPackageObjServices"
soapAction = ""# For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
contentType = "text/xml"
http = Chilkat::CkHttp.new()
http.ClearHeaders()
http.SetRequestHeader("Content-Type",contentType)
http.SetRequestHeader("SOAPAction",soapAction)
# resp is a CkHttpResponse
resp = http.PostXml(endpoint,soapRequestBody,"utf-8")
if (http.get_LastMethodSuccess() == false)
print http.lastErrorText() + "\n";
print"Failed to send SOAP request." + "\n";
exitend# Get the XML response body.
responseXml = Chilkat::CkXml.new()
resp.GetBodyXml(responseXml)
statusCode = resp.get_StatusCode()
print"response status code: " + statusCode.to_s() + "\n";
# If the status code does not indicate succcess, then show the response XML,
# which probably contains error information.if (statusCode != 200)
print responseXml.getXml() + "\n";
exitendprint responseXml.getXml() + "\n";
# 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).
Status = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Status")
SessionId = responseXml.GetChildIntValue("*:Body|*:generatePackagesNumbersV4Response|*:return|*:SessionId")
BeginTime = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:BeginTime")
EndTime = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:EndTime")
Status = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Status")
PackageId = responseXml.GetChildIntValue("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:PackageId")
Reference = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Reference")
ErrorId = responseXml.GetChildIntValue("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:ValidationDetails|*:ValidationInfo|*:ErrorId")
ErrorCode = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:ValidationDetails|*:ValidationInfo|*:ErrorCode")
FieldNames = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:ValidationDetails|*:ValidationInfo|*:FieldNames")
Info = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:ValidationDetails|*:ValidationInfo|*:Info")
Status = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Parcels|*:Parcel|*:Status")
ParcelId = responseXml.GetChildIntValue("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Parcels|*:Parcel|*:ParcelId")
Reference = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Parcels|*:Parcel|*:Reference")
Waybill = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Parcels|*:Parcel|*:Waybill")
ErrorId = responseXml.GetChildIntValue("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Parcels|*:Parcel|*:ValidationDetails|*:ValidationInfo|*:ErrorId")
ErrorCode = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Parcels|*:Parcel|*:ValidationDetails|*:ValidationInfo|*:ErrorCode")
FieldNames = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Parcels|*:Parcel|*:ValidationDetails|*:ValidationInfo|*:FieldNames")
Info = responseXml.getChildContent("*:Body|*:generatePackagesNumbersV4Response|*:return|*:Packages|*:Package|*:Parcels|*:Parcel|*:ValidationDetails|*:ValidationInfo|*:Info")