You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2004/08/02 13:06:57 UTC

cvs commit: xml-security/c/src/utils XSECSOAPRequestorSimple.cpp

blautenb    2004/08/02 04:06:57

  Modified:    c/src/utils XSECSOAPRequestorSimple.cpp
  Log:
  Implement checking of SOAP faults
  
  Revision  Changes    Path
  1.3       +49 -1     xml-security/c/src/utils/XSECSOAPRequestorSimple.cpp
  
  Index: XSECSOAPRequestorSimple.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/utils/XSECSOAPRequestorSimple.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSECSOAPRequestorSimple.cpp	9 Jun 2004 04:07:01 -0000	1.2
  +++ XSECSOAPRequestorSimple.cpp	2 Aug 2004 11:06:56 -0000	1.3
  @@ -207,6 +207,54 @@
   		throw XSECException(XSECException::HTTPURIInputStreamError,
   							"Could not find message within SOAP body");
   
  +	/* See if this is a soap fault */
  +	if (strEquals(e->getLocalName(), "Fault")) {
  +
  +		// Something has gone wrong somewhere!
  +		safeBuffer sb;
  +		sb.sbTranscodeIn("SOAP Fault : ");
  +
  +		// Find the fault code
  +
  +		e = findFirstElementChild(e);
  +		while (e != NULL && !strEquals(e->getLocalName(), "Code"))
  +			e = findNextElementChild(e);
  +		
  +		if (e != NULL) {
  +			DOMNode * c = findFirstElementChild(e);
  +			while (c != NULL && !strEquals(c->getLocalName(), "Value"))
  +				c = findNextElementChild(c);
  +			if (c != NULL) {
  +				DOMNode * t = findFirstChildOfType(c, DOMNode::TEXT_NODE);
  +				if (t != NULL) {
  +					sb.sbXMLChCat(t->getNodeValue());
  +					sb.sbXMLChCat(" : ");
  +				}
  +			}
  +		}
  +
  +		// Find the reason
  +		while (e != NULL && !strEquals(e->getLocalName(), "Reason"))
  +			e = findNextElementChild(e);
  +
  +		if (e != NULL) {
  +			DOMNode * t = findFirstChildOfType(e, DOMNode::TEXT_NODE);
  +			if (t != NULL) {
  +				sb.sbXMLChCat(t->getNodeValue());
  +			}
  +
  +		}
  +
  +		retDoc->release();
  +
  +		char * msg = XMLString::transcode(sb.rawXMLChBuffer());
  +		ArrayJanitor<char> j_msg(msg);
  +
  +		throw XSECException(XSECException::HTTPURIInputStreamError,
  +							msg);
  +	}
  +
  +
   	retDoc->appendChild(retDoc->importNode(e, true));
   
   	return retDoc;