2 * Copyright 2001-2006 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * Implements SOAP 1.1 messaging over a transport.
24 #include "exceptions.h"
25 #include "soap/SOAP.h"
26 #include "soap/SOAPClient.h"
27 #include "util/XMLHelper.h"
28 #include "validation/ValidatorSuite.h"
\r
32 using namespace soap11;
33 using namespace xmltooling;
36 SOAPClient::~SOAPClient()
41 void SOAPClient::reset()
47 void SOAPClient::send(const Envelope* env, const KeyInfoSource& peer, const char* endpoint)
49 // Prepare a transport object.
50 const char* pch = strchr(endpoint,':');
52 throw IOException("SOAP endpoint was not a URL.");
53 string scheme(endpoint, pch-endpoint);
54 m_transport = XMLToolingConfig::getConfig().SOAPTransportManager.newPlugin(scheme.c_str(), make_pair(&peer,endpoint));
55 prepareTransport(*m_transport);
57 // Serialize envelope.
59 XMLHelper::serialize(env->marshall(), s);
65 Envelope* SOAPClient::receive()
68 throw IOException("No call is active.");
70 // If we can get the stream, then the call is still active.
71 istream& out = m_transport->receive();
73 return NULL; // nothing yet
75 // Parse and bind the document into an XMLObject.
76 DOMDocument* doc = (m_validate ? XMLToolingConfig::getConfig().getValidatingParser()
77 : XMLToolingConfig::getConfig().getParser()).parse(out);
78 XercesJanitor<DOMDocument> janitor(doc);
79 auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true));
82 SchemaValidators.validate(xmlObject.get());
\r
84 Envelope* env = dynamic_cast<Envelope*>(xmlObject.get());
86 throw IOException("Response was not a SOAP 1.1 Envelope.");