X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fsoap%2Fimpl%2FSOAPClient.cpp;h=23d9b8ca039606686ba4b4d723120afe5f5fb71c;hb=64dcaec957e9befd960779498d7fe35bbb62141a;hp=d785b63abcd62430899890b1ce1decfed37dcd11;hpb=1f87cef41f9948492e13d3d9dc1495652606c441;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/soap/impl/SOAPClient.cpp b/xmltooling/soap/impl/SOAPClient.cpp index d785b63..23d9b8c 100644 --- a/xmltooling/soap/impl/SOAPClient.cpp +++ b/xmltooling/soap/impl/SOAPClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * Copyright 2001-2007 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,22 +22,22 @@ #include "internal.h" #include "exceptions.h" +#include "logging.h" #include "soap/SOAP.h" #include "soap/SOAPClient.h" #include "util/XMLHelper.h" #include "validation/ValidatorSuite.h" #include -#include using namespace soap11; +using namespace xmltooling::logging; using namespace xmltooling; -using namespace log4cpp; using namespace std; SOAPClient::~SOAPClient() { - reset(); + delete m_transport; } void SOAPClient::reset() @@ -46,19 +46,19 @@ void SOAPClient::reset() m_transport=NULL; } -void SOAPClient::send(const Envelope* env, const KeyInfoSource& peer, const char* endpoint) +void SOAPClient::send(const Envelope& env, const char* peerName, const char* endpoint) { // Prepare a transport object. const char* pch = strchr(endpoint,':'); if (!pch) throw IOException("SOAP endpoint was not a URL."); string scheme(endpoint, pch-endpoint); - m_transport = XMLToolingConfig::getConfig().SOAPTransportManager.newPlugin(scheme.c_str(), make_pair(&peer,endpoint)); + m_transport = XMLToolingConfig::getConfig().SOAPTransportManager.newPlugin(scheme.c_str(), make_pair(peerName,endpoint)); prepareTransport(*m_transport); // Serialize envelope. stringstream s; - s << *env; + s << env; // Send to peer. m_transport->send(s); @@ -74,6 +74,11 @@ Envelope* SOAPClient::receive() if (!out) return NULL; // nothing yet + // Check content type. + string s = m_transport->getContentType(); + if (s.find("text/xml") == string::npos) + throw IOException("Incorrect content type ($1) for SOAP response.", params(1,s.c_str() ? s.c_str() : "none")); + // Parse and bind the document into an XMLObject. DOMDocument* doc = (m_validate ? XMLToolingConfig::getConfig().getValidatingParser() : XMLToolingConfig::getConfig().getParser()).parse(out);