$headerXml .= '<wsse:UsernameToken wsu:Id="UsernameToken-9" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'; $headerXml .= '<wsse:Username>' . $soapUsername . '</wsse:Username>'; $headerXml .= '<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . $soapPassword . '</wsse:Password>'; $headerXml .= '</wsse:UsernameToken>'; $headerXml .= '</wsse:Security>'; $headerbody = new SoapVar($headerXml, XSD_ANYXML, null, null, null); // 3. Create Soap Header. $ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'; //Namespace of the WS. $header = new SOAPHeader($ns, 'Security', $headerbody, true); // 4. Make new instance of the PHP Soap client $soap_client = new SoapClient($soapWdslUrl, array("trace" => 1, "exception" => 0)); // 5. Set the Headers of soap client. $soap_client->__setSoapHeaders($header); // 6. Do the setTransaction soap call to PayU $soapCallResult = $soap_client->doTransaction($soapDataArray); // 7. Decode the Soap Call Result $returnData = json_decode(json_encode($soapCallResult), true); $decodedXmlData = json_decode(json_encode((array) simplexml_load_string($returnData)), true); print "<pre>"; var_dump($decodedXmlData); print "</pre>"; } catch (Exception $e) { var_dump($e); } //------------------------------------------------------------------- //------------------------------------------------------------------- //------- //------- Checking response //------- //-------------------------------------------------------------------