I would need to pass request payload in XML format for a web service. Below is the code I tried.

How do I verify & view XML is constructed properly?

Is there a better Magento way to create an XML request since a big payload needs to be constructed?

Note: object manager being is used for testing purposes

    $xmlHeader = '<?xml version="1.0" encoding="UTF-8"?><OrderStatusQuery xmlns="http://some-schema"></OrderStatusQuery>';


    $http->setHeaders(['Content-Type: text/xml']);
    $responseBody = $http->request()->getBody();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.