razvan
09-28-2017, 10:43 AM
Hi,
I want to use VBA to create shipping labels with my express courier. He gave me the API documentation, but it come only with XML data examples, without integration examples.
I have tried a few times, but all I get as response is a generic fault XML.
The code I'm using is:
Sub Courier()
Dim XDoc As Object, root As Object
Set XDoc = CreateObject("MSXML2.DOMDocument")
XDoc.async = False: XDoc.validateOnParse = False
XDoc.Load (ThisWorkbook.Path & "test.xml")
Dim xmlhttp As New MSXML2.XMLHTTP60, myurl As String
myurl = "https://nou.dpdonline.ro/IT4EMWebServices/eshop/ShipmentServiceImpl?wsdl"
xmlhttp.Open "GET", myurl, False
xmlhttp.Send XDoc
Debug.Print xmlhttp.responseText
End Sub
where the test.xml has the following content:
<soapenv:Envelope> <soapenv:Header/>
<soapenv:Body>
<ship:createShipment>
<!--Optional:-->
<wsUserName>DEMO</wsUserName>
<!--Optional:-->
<wsPassword>EyNu4xJP8D</wsPassword>
<!--Optional:-->
<wsLang>EN</wsLang>
<!--Optional:-->
<applicationType>9</applicationType>
<!--Zero or more repetitions:-->
<shipmentList>
<shipmentId xsi:nil="true"/>
<shipmentReferenceNumber>EmagTEST</shipmentReferenceNumber>
<payerId>4000001</payerId>
<senderAddressId>40061104</senderAddressId>
<receiverName>Test ro</receiverName>
<receiverFirmName>DPD</receiverFirmName>
<receiverCountryCode>RO</receiverCountryCode>
<receiverZipCode>077135</receiverZipCode>
<receiverCity>Mogosoaia</receiverCity>
<receiverStreet>Buiacului</receiverStreet>
<receiverHouseNo>5</receiverHouseNo>
<receiverPhoneNo>0000000000</receiverPhoneNo>
<mainServiceCode>109</mainServiceCode>
<!--Optional:-->
<additionalServices>
<cod>
<amount>1</amount>
<currency>RON</currency>
<paymentType>Cash</paymentType>
<referenceNumber>1234</referenceNumber>
</cod>
<saturdayDelivery>False</saturdayDelivery>
</additionalServices>
<parcels>
<parcelReferenceNumber></parcelReferenceNumber>
<weight>1</weight>
<description>please call before</description>
</parcels>
</shipmentList>
<!--Optional:-->
<priceOption>WithPrice</priceOption>
</ship:createShipment>
</soapenv:Body>
</soapenv:Envelope>
It's ok to share the user/password, it's a test environment :)
What am I doing wrong?
How should I send the XML in order to get a valid response?
I'm so angry, this should be a very simple task...
Thank you so much!
I want to use VBA to create shipping labels with my express courier. He gave me the API documentation, but it come only with XML data examples, without integration examples.
I have tried a few times, but all I get as response is a generic fault XML.
The code I'm using is:
Sub Courier()
Dim XDoc As Object, root As Object
Set XDoc = CreateObject("MSXML2.DOMDocument")
XDoc.async = False: XDoc.validateOnParse = False
XDoc.Load (ThisWorkbook.Path & "test.xml")
Dim xmlhttp As New MSXML2.XMLHTTP60, myurl As String
myurl = "https://nou.dpdonline.ro/IT4EMWebServices/eshop/ShipmentServiceImpl?wsdl"
xmlhttp.Open "GET", myurl, False
xmlhttp.Send XDoc
Debug.Print xmlhttp.responseText
End Sub
where the test.xml has the following content:
<soapenv:Envelope> <soapenv:Header/>
<soapenv:Body>
<ship:createShipment>
<!--Optional:-->
<wsUserName>DEMO</wsUserName>
<!--Optional:-->
<wsPassword>EyNu4xJP8D</wsPassword>
<!--Optional:-->
<wsLang>EN</wsLang>
<!--Optional:-->
<applicationType>9</applicationType>
<!--Zero or more repetitions:-->
<shipmentList>
<shipmentId xsi:nil="true"/>
<shipmentReferenceNumber>EmagTEST</shipmentReferenceNumber>
<payerId>4000001</payerId>
<senderAddressId>40061104</senderAddressId>
<receiverName>Test ro</receiverName>
<receiverFirmName>DPD</receiverFirmName>
<receiverCountryCode>RO</receiverCountryCode>
<receiverZipCode>077135</receiverZipCode>
<receiverCity>Mogosoaia</receiverCity>
<receiverStreet>Buiacului</receiverStreet>
<receiverHouseNo>5</receiverHouseNo>
<receiverPhoneNo>0000000000</receiverPhoneNo>
<mainServiceCode>109</mainServiceCode>
<!--Optional:-->
<additionalServices>
<cod>
<amount>1</amount>
<currency>RON</currency>
<paymentType>Cash</paymentType>
<referenceNumber>1234</referenceNumber>
</cod>
<saturdayDelivery>False</saturdayDelivery>
</additionalServices>
<parcels>
<parcelReferenceNumber></parcelReferenceNumber>
<weight>1</weight>
<description>please call before</description>
</parcels>
</shipmentList>
<!--Optional:-->
<priceOption>WithPrice</priceOption>
</ship:createShipment>
</soapenv:Body>
</soapenv:Envelope>
It's ok to share the user/password, it's a test environment :)
What am I doing wrong?
How should I send the XML in order to get a valid response?
I'm so angry, this should be a very simple task...
Thank you so much!