Jump to content

mohib_ayubi

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by mohib_ayubi

  1. Ok finally after spent hours, i got that! I had to modify according to tag names as below, in the most parent i had to used soap-env instead of SOAP. $dom = new DOMDocument; $dom->preserveWhiteSpace = false; $dom->loadXML($response->Data); $dom->formatOutput = true; $XMLContent = $dom->saveXML(); $xml = simplexml_load_String($XMLContent, null, null, 'soap-env', true); if(!$xml) trigger_error("Encoding Error!", E_USER_ERROR); $Results = $xml->children('soap-env',true); foreach($Results->children('soap-env',true) as $fault){ if(strcmp($fault->getName(),'Fault') == 0){ trigger_error("Error occurred request/response processing!", E_USER_ERROR); } } foreach($Results->children('wsse',true) as $nodes){ if(strcmp($nodes->getName(),'Security') == 0){ foreach($nodes->children('wsse',true) as $securityNodes){ if(strcmp($securityNodes->getName(),'BinarySecurityToken') == 0){ $tokenParsed = (string)$securityNodes; } } } }
  2. Tried following way i used to do also, but it also wont work. $dom = new DOMDocument; $dom->preserveWhiteSpace = false; $dom->loadXML($response->Data); $dom->formatOutput = true; $XMLContent = $dom->saveXML(); $xml = simplexml_load_String($XMLContent, null, null, 'soap-env', true); if(!$xml) trigger_error("Encoding Error!", E_USER_ERROR); $Results = $xml->children('SOAP',true); foreach($Results->children('SOAP',true) as $fault){ if(strcmp($fault->getName(),'Fault') == 0){ trigger_error("Error occurred request/response processing!", E_USER_ERROR); } } foreach($Results->children('soap-env',true) as $nodes){ var_dump($nodes->getName()); }
  3. Tried following but still it through empty error $xml = simplexml_load_String("$XMLContent", null, null, 'SOAP', true); if(!$xml) trigger_error("Encoding Error!", E_USER_ERROR); $Results = $xml->children('SOAP',true); foreach($Results->children('SOAP',true) as $fault){ if(strcmp($fault->getName(),'Fault') == 0){ trigger_error("Error occurred request/response processing!", E_USER_ERROR); } }
  4. Dear Experts, I need your help in the following: I am experiencing an error while parsing my XML response in PHP I have a below XML response, when i call from CURL request <soap-env:Header> <eb:MessageHeader xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" eb:version="1.0" soap-env:mustUnderstand="1"> <eb:From> <eb:PartyId eb:type="URI">Sabre_API</eb:PartyId> </eb:From> <eb:To> <eb:PartyId eb:type="URI">Agency</eb:PartyId> </eb:To> <eb:ConversationId>2021.01.DevStudio</eb:ConversationId> <eb:Service eb:type="sabreXML">Session</eb:Service> <eb:Action>TokenCreateRS</eb:Action> <eb:MessageData> <eb:MessageId>1913771794839350290</eb:MessageId> <eb:Timestamp>2023-02-23T22:04:43</eb:Timestamp> </eb:MessageData> </eb:MessageHeader> <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"> <wsse:BinarySecurityToken valueType="String" EncodingType="wsse:Base64Binary">T1RLAQLASo74A7olKG7QnepeFqs19UHX+0Cds9QiDZoYfu677xC3Vkr9a+OcQhutjPL4atVMAADQRtHIXdehGg/0OVuPdia/0cM233jFDvyJJHgJHC3o8gV2ssS63b4Y0lgCG59SiG4tmEcqAXcYAMlnq+wJ4TfsOIDFwYdP+D0peSEFBM/m3EyOUqc4idJ+vO4S7xENCeQ7UX4YVKjVLJs788omPDbSIRNo85KQ5QxRprldV0jucJpAtbNfs1DrMHFqNIPyg0CpVpgXILkFx0azkcAuvmbHMHLqqO13WJEOhsG0KDBhBhRn8CwoCgD9foXL24W6yGu8Ecm0Fzvb/MuAjuYm9s48yg**</wsse:BinarySecurityToken> </wsse:Security> </soap-env:Header> <soap-env:Body> <sws:TokenCreateRS xmlns:sws="http://webservices.sabre.com" Version="1.0.0"> <sws:Success/> </sws:TokenCreateRS> </soap-env:Body> </soap-env:Envelope> To parse the above XML i have initially tried with the simplexml_load_String but it gives an empty response. Then i tried DOM method by using following code, here considering $response->Data is the above XML. $dom = new DOMDocument; $dom->preserveWhiteSpace = false; $dom->loadXML($response->Data); $dom->formatOutput = true; $XMLContent = $dom->saveXML(); It gives me following output again: <!--?xml version="1.0" encoding="UTF-8"?--> <soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:header> <eb:messageheader xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" eb:version="1.0" soap-env:mustunderstand="1"> <eb:from> <eb:partyid eb:type="URI">Sabre_API</eb:partyid> </eb:from> <eb:to> <eb:partyid eb:type="URI">Agency</eb:partyid> </eb:to> <eb:conversationid>2021.01.DevStudio</eb:conversationid> <eb:service eb:type="sabreXML">Session</eb:service> <eb:action>TokenCreateRS</eb:action> <eb:messagedata> <eb:messageid>1002038859236010450</eb:messageid> <eb:timestamp>2023-02-23T23:52:03</eb:timestamp> </eb:messagedata> </eb:messageheader> <wsse:security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"> <wsse:binarysecuritytoken valuetype="String" encodingtype="wsse:Base64Binary">T1RLAQJZqih4+TYQmYCcdj42lcej5nckNWdo6WNb8edNl3xNtxAkqmu2YKjKki1OKQ7B3HK3AADQCGiRWrlzFPM0KB4foAOsSF+I+5eXE32uQ23LLd+hOduY2BCJYqPw7CvwCJ/LfNjy3P+QyvClvu6ysctC3a0GjmixDPDqCIckcXPb+XDFyYhR5G5QzQjch/Eax25koLnNvfN8rlvjNq+ENJmaV17wP43GLo1pzd19d9HGMn1VgjrJiVGWAb1ezyeiFNAd1VuBD2lAmdlo4jvZJzAS/fklZvwNFbKME64YpaFRptoLz0FKmz47y1TVYFtV6TZxbKirP3PDms0aGlItbJ4apPSB2Q**</wsse:binarysecuritytoken> </wsse:security> </soap-env:header> <soap-env:body> <sws:tokencreaters xmlns:sws="http://webservices.sabre.com" version="1.0.0"> <sws:success> </sws:success></sws:tokencreaters> </soap-env:body> </soap-env:envelope> So i plan to get data from NODE like below But instead of giving me a node values it start giving me and error. I just want to get the data in the node wsse:binarysecuritytoken Did anyone experience some thing like this? Can you please help me in that?? Tried also following, but got not helpful still $domDocument = new DOMDocument(); $domDocument->loadXML($XMLContent); $carriers=array(); $results=$domDocument->getElementsByTagName("wsse:Security"); foreach($results as $result) { foreach($result->childNodes as $node) { if($node instanceof DOMElement) { array_push($carriers, $node->textContent); } } } var_dump($carriers); Please Help
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.