Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / soap / impl / SOAPClient.cpp
index fb0ff52..b3f7c6d 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  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.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
  */
 
 /**
@@ -23,6 +27,7 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "logging.h"
+#include "soap/HTTPSOAPTransport.h"
 #include "soap/SOAP.h"
 #include "soap/SOAPClient.h"
 #include "util/XMLHelper.h"
@@ -36,6 +41,24 @@ using namespace xmltooling;
 using namespace xercesc;
 using namespace std;
 
+SOAPTransport::SOAPTransport()
+{
+}
+
+SOAPTransport::~SOAPTransport()
+{
+}
+
+bool SOAPTransport::setProviderOption(const char* provider, const char* option, const char* value)
+{
+    return false;
+}
+
+bool SOAPTransport::setCacheTag(string* cacheTag)
+{
+    return false;
+}
+
 void SOAPTransport::send(istream* in)
 {
     if (!in)
@@ -43,21 +66,48 @@ void SOAPTransport::send(istream* in)
     return send(*in);
 }
 
+long SOAPTransport::getStatusCode() const
+{
+    return 0;
+}
+
+HTTPSOAPTransport::HTTPSOAPTransport()
+{
+}
+
+HTTPSOAPTransport::~HTTPSOAPTransport()
+{
+}
+
+bool HTTPSOAPTransport::followRedirects(bool follow, unsigned int maxRedirs)
+{
+    return false;
+}
+
+SOAPClient::SOAPClient(bool validate) : m_validate(validate), m_transport(nullptr)
+{
+}
+
 SOAPClient::~SOAPClient()
 {
     delete m_transport;
 }
 
+void SOAPClient::setValidating(bool validate)
+{
+    m_validate = validate;
+}
+
 void SOAPClient::reset()
 {
     delete m_transport;
-    m_transport=NULL;
+    m_transport=nullptr;
 }
 
 void SOAPClient::send(const Envelope& env, const SOAPTransport::Address& addr)
 {
     // Prepare a transport object.
-    const char* pch = strchr(addr.m_endpoint,':');
+    const char* pch = addr.m_endpoint ? strchr(addr.m_endpoint,':') : nullptr;
     if (!pch)
         throw IOException("SOAP endpoint was not a URL.");
     string scheme(addr.m_endpoint, pch-addr.m_endpoint);
@@ -84,7 +134,7 @@ Envelope* SOAPClient::receive()
     // If we can get the stream, then the call is still active.
     istream& out = m_transport->receive();
     if (!out)
-        return NULL;    // nothing yet
+        return nullptr;    // nothing yet
     
     // Check content type.
     string s = m_transport->getContentType();
@@ -109,8 +159,8 @@ Envelope* SOAPClient::receive()
     
     auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true));
     janitor.release();
-    if (!m_validate)
-        SchemaValidators.validate(xmlObject.get());
+
+    SchemaValidators.validate(xmlObject.get());
 
     Envelope* env = dynamic_cast<Envelope*>(xmlObject.get());
     if (!env)
@@ -128,10 +178,14 @@ Envelope* SOAPClient::receive()
     return env;
 }
 
+void SOAPClient::prepareTransport(SOAPTransport& transport)
+{
+}
+
 bool SOAPClient::handleFault(const Fault& fault)
 {
-    const xmltooling::QName* code = (fault.getFaultcode() ? fault.getFaultcode()->getCode() : NULL);
-    auto_ptr_char str((fault.getFaultstring() ? fault.getFaultstring()->getString() : NULL));
+    const xmltooling::QName* code = (fault.getFaultcode() ? fault.getFaultcode()->getCode() : nullptr);
+    auto_ptr_char str((fault.getFaultstring() ? fault.getFaultstring()->getString() : nullptr));
     Category::getInstance(XMLTOOLING_LOGCAT".SOAPClient").error(
         "SOAP client detected a Fault: (%s) (%s)",
         (code ? code->toString().c_str() : "no code"),