JugglingOctopus
JugglingOctopus

Reputation: 1

How to decode protected response from HTTP_Request2 in PHP

I am trying to post a SOAP Request to an Oracle Database using PHP with the HTTP_Request2 package. It is looking like I am getting a response, but it is not the response I am expecting.

The code I have for making the request is below:

$request = new HTTP_Request2();
        $request->setUrl($wsdl);
        $request->setMethod(HTTP_Request2::METHOD_POST);
        $request->setConfig(array(
          'follow_redirects' => TRUE
        ));
        $request->setHeader(array(
          'Content-Type' => 'text/xml'
        ));
        $request->setAuth('interface', 'Welcome2',);
        $request->setBody('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/cdm/foundation/parties/customerAccountService/applicationModule/types/" xmlns:typ1="http://xmlns.oracle.com/adf/svc/types/"> <soapenv:Header/> <soapenv:Body> <typ:findCustomerAccount> <typ:findCriteria> <typ1:fetchStart>0</typ1:fetchStart> <typ1:fetchSize>1</typ1:fetchSize> <typ1:filter> <typ1:group> <typ1:item> <typ1:attribute>AccountNumber</typ1:attribute> <typ1:operator>STARTSWITH</typ1:operator> <typ1:value>UAT</typ1:value> </typ1:item> </typ1:group> </typ1:filter> </typ:findCriteria> <typ:findControl> <typ1:retrieveAllTranslations>false</typ1:retrieveAllTranslations> </typ:findControl> </typ:findCustomerAccount> </soapenv:Body> </soapenv:Envelope>');
        try {
          $response = $request->send();
          if ($response->getStatus() == 200) {
            echo $response->getBody();
          }
          else {
            echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
            $response->getReasonPhrase();
          }
        }
        catch(HTTP_Request2_Exception $e) {
          echo 'Error: ' . $e->getMessage();
        }

If I simply use the getBody method on my response, I receive the following output: Output image here

If I switch the echo into a var_dump to get a better look at what's in the object, it gets a little more useful before breaking down: Var_Dump results

Upvotes: 0

Views: 159

Answers (0)

Related Questions