Log inbound/outbound XML.
[shibboleth/cpp-xmltooling.git] / xmltooling / soap / impl / SOAPClient.cpp
index 23d9b8c..260736a 100644 (file)
@@ -46,16 +46,20 @@ void SOAPClient::reset()
     m_transport=NULL;
 }
 
-void SOAPClient::send(const Envelope& env, const char* peerName, const char* endpoint)
+void SOAPClient::send(const Envelope& env, const SOAPTransport::Address& addr)
 {
     // Prepare a transport object.
-    const char* pch = strchr(endpoint,':');
+    const char* pch = strchr(addr.m_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(peerName,endpoint));
+    string scheme(addr.m_endpoint, pch-addr.m_endpoint);
+    m_transport = XMLToolingConfig::getConfig().SOAPTransportManager.newPlugin(scheme.c_str(), addr);
     prepareTransport(*m_transport);
     
+    Category& log = Category::getInstance(XMLTOOLING_LOGCAT".SOAPClient");
+    if (log.isDebugEnabled())
+        log.debugStream() << "marshalled envelope: " << env << logging::eol;
+    
     // Serialize envelope.
     stringstream s;
     s << env;
@@ -83,6 +87,11 @@ Envelope* SOAPClient::receive()
     DOMDocument* doc = (m_validate ? XMLToolingConfig::getConfig().getValidatingParser()
         : XMLToolingConfig::getConfig().getParser()).parse(out); 
     XercesJanitor<DOMDocument> janitor(doc);
+
+    Category& log = Category::getInstance(XMLTOOLING_LOGCAT".SOAPClient");
+    if (log.isDebugEnabled())
+        log.debugStream() << "received XML: " << *(doc->getDocumentElement()) << logging::eol;
+    
     auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true));
     janitor.release();
     if (!m_validate)