0

XML Code:

 <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
      <a:Action s:mustUnderstand="1">http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault</a:Action>
      <a:RelatesTo>urn:uuid:9C35A55C-A5B4-AC89-AF95-B287E727332E</a:RelatesTo>
      <ActivityId CorrelationId="427735e4-59b8-4176-a2b7-49f91b965d11" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000</ActivityId>
      <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
          <u:Timestamp u:Id="_0">
              <u:Created>2017-05-08T07:34:29.504Z</u:Created>
              <u:Expires>2017-05-08T07:39:29.504Z</u:Expires>
          </u:Timestamp>
      </o:Security>
  </s:Header>
  <s:Body>
      <s:Fault>
          <s:Code>
              <s:Value>s:Sender</s:Value>
              <s:Subcode>
                  <s:Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</s:Value>
              </s:Subcode>
          </s:Code>
          <s:Reason>
              <s:Text xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity. The InnerException message was 'There was an error deserializing the object of type Microsoft.Xrm.Sdk.Entity. The value 'mehul' cannot be parsed as the type 'Boolean'.'.  Please see InnerException for more details.</s:Text>
          </s:Reason>
      </s:Fault>
  </s:Body>

Here how to get s:Fault values using DOMXPath i am try to use below code but i am not getting please help me any one

   $dom = new \DOMDocument();
    $dom->loadXML($crmResponse);
    $domxpath = new \DOMXPath($dom);
    $domxpath->registerNamespace('u',"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
    $domxpath->registerNamespace('a',"http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher");

    //$nodeList = $domxpath->query("//*[local-name()='RetrieveResult']/b:Attributes/b:KeyValuePairOfstringanyType[c:key='new_currentapplicationstatus']/c:value/b:Value/text()");
    $nodeList = $domxpath->query("//*[local-name()='RetrieveResult']/o:Security[u:Id='_0']");
    $nodeErr = $domxpath->query("//*[local-name()='RetrieveResult']/s:Fault/s:Value/text()");

    var_dump($nodeErr);exit;

here how to get using DOMXPath query PHP attribute values

1 Answer 1

1

Here we are using DOMDocument for retrieving output.

Try this code snippet here

<?php
ini_set('display_errors', 1);
$string=' <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
      <a:Action s:mustUnderstand="1">http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault</a:Action>
      <a:RelatesTo>urn:uuid:9C35A55C-A5B4-AC89-AF95-B287E727332E</a:RelatesTo>
      <ActivityId CorrelationId="427735e4-59b8-4176-a2b7-49f91b965d11" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000</ActivityId>
      <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
          <u:Timestamp u:Id="_0">
              <u:Created>2017-05-08T07:34:29.504Z</u:Created>
              <u:Expires>2017-05-08T07:39:29.504Z</u:Expires>
          </u:Timestamp>
      </o:Security>
  </s:Header>
  <s:Body>
      <s:Fault>
          <s:Code>
              <s:Value>s:Sender</s:Value>
              <s:Subcode>
                  <s:Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</s:Value>
              </s:Subcode>
          </s:Code>
          <s:Reason>
              <s:Text xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity. The InnerException message was \'There was an error deserializing the object of type Microsoft.Xrm.Sdk.Entity. The value \'mehul\' cannot be parsed as the type \'Boolean\'.\'.  Please see InnerException for more details.</s:Text>
          </s:Reason>
      </s:Fault>
  </s:Body>
  </s:Envelope>';
$domDocument= new DOMDocument();
$domDocument->loadXML($string);
foreach($domDocument->getElementsByTagNameNS("http://www.w3.org/2003/05/soap-envelope", "Value") as $value)
{
    echo $value->textContent;
    echo PHP_EOL;
}

Output:

s:Sender a:DeserializationFailed

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much...your valuable response

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.