/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtsoap.h"
#include <QSet>
#include <QNetworkRequest>
#include <QNetworkReply>
/*! \page qtsoap-overview.html
\title Qt SOAP component
\tableofcontents
\target overview
\section1 Overview of the SOAP support in the QtSoap classes
QtSoapMessage provides an interface for creating, inspecting and
modifying SOAP messages. It has convenience functions for
generating method requests and inspecting method response
messages, and also functions that provide easy access to SOAP
Fault messages.
The QtSoapType class allows you to inspect SOAP messages with no
knowledge of XML or DOM. Header and body items are all derived
from QtSoapType, and through easy accessors and iterators, this
class and its derivatives make it easy to build arrays
(QtSoapArray), structs (QtSoapStruct) and simple types like
String, Integer and Boolean (QtSoapSimpleType).
Finally, QtSoapHttpTransport provides a convenient way to submit
SOAP messages to a host via the HTTP protocol.
\target classes
\section1 The SOAP classes
\table
\header \i Class \i Short description
\row \i \l QtSoapMessage
\i Represents a SOAP message
\row \i \l QtSoapQName
\i Represents qualified names (QNames)
\row \i \l QtSoapType
\i A superclass for all data constructs in a SOAP message.
\row \i \l QtSoapArray
\i Represents a SOAP array
\row \i \l QtSoapArrayIterator
\i Lets you iterate over all the values in a SOAP array
\row \i \l QtSoapStruct
\i Represents a SOAP struct
\row \i \l QtSoapStructIterator
\i Lets you iterate over all the values in a SOAP array
\row \i \l QtSoapSimpleType
\i Represents simple SOAP types such as String, Integer and Boolean.
\row \i \l QtSoapHttpTransport
\i Provides a method for transmitting SOAP messages to an
HTTP server and for getting the SOAP reply.
\endtable
\target partial
\section1 Status of the SOAP component
This is a partial implementation of the SOAP v1.1 protocol.
\list
\i Server side SOAP is not supported.
\i References to values (id and href attributes) are not supported.
\i Only arrays with less than 5 dimensions are supported.
\i Namespaces for types are not checked. Only the type names are used.
\i The encodingStyle attribute is ignored. The serialization and
encoding rules from section 5 in the SOAP v1.1 specification are
assumed regardless of the value of the encodingStyle attribute.
\i QtSoapType does not have accessors for attributes, which means
for example that actor, mustUnderstand and so on are not
accessible in headers.
\i The SOAP root attribute is not supported.
\endlist
*/
namespace {
QString localName(const QString &tagName)
{
int pos;
if ((pos = tagName.indexOf(':')))
return tagName.right(tagName.length() - pos - 1);
return tagName;
}
QString prefix(const QString &tagName)
{
int pos;
if ((pos = tagName.indexOf(':')))
return tagName.left(pos);
return tagName;
}
}
/*! \class QtSoapQName qtsoap.h
\brief The QtSoapQName class provides a wrapper for QNames (names with
namespaces).
This class is used extensively in QtSoap to define and identify
header and body elements, including method and argument names.
The QtSoapQName consists of a name and a URI. The URI is used as
the name's namespace, i.e. the name is qualified (hence 'Q'-Name)
by the URI. The name() and uri() functions return the QNames's
name and URI.
The QtSoapQName can be empty. It can also have just a name with no
URI. Special handling is often applied to a QtSoapQName that has
no URI. Typically, if a QName with no namespace is used in an
element in a SOAP document that already has a default namespace
defined, then that namespace will be applied to the QName.
\code
QtSoapMessage message;
message.setMethod(QtSoapQName("sendMessage", "http://messenging.example.com/"));
message.addMethodArgument(QtSoapSimpleType(QtSoapQName("a"), 15));
\endcode
*/
/*!
Constructs a QName. Sets the QName name to \a name and the URI to
\a uri.
*/
QtSoapQName::QtSoapQName(const QString &name, const QString &uri)
: n(name), nuri(uri)
{
}
/*!
Destructs the QtSoapQName.
*/
QtSoapQName::~QtSoapQName()
{
}
/*!
Returns QName's name.
*/
QString QtSoapQName::name() const
{
return n;
}
/*!
Returns the QName's URI.
*/
QString QtSoapQName::uri() const
{
return nuri;
}
/*!
Sets the QName's name to \a s, and sets the URI to an empty string.
*/
QtSoapQName &QtSoapQName::operator =(const QString &s)
{
n = s;
nuri = "";
return *this;
}
/*!
\fn bool operator==(const QtSoapQName &s1, const QtSoapQName &s2)
\relates QtSoapQName
If \a s2 has a non-empty URI, this function returns true if the
merge of the URI and the name of \a s1 is equal to that of \a s2;
otherwise it returns false.
If \a s2 has an empty URI, this function returns true if the name
of \a s1 is equal to the name of \a s2; otherwise it returns false.
The comparison is case-insensitive.
*/
bool operator ==(const QtSoapQName &s1, const QtSoapQName &s2)
{
if (s2.uri() == "")
return s1.name().toLower() == s2.name().toLower();
return s1.name().toLower() == s2.name().toLower()
&& s1.uri().toLower() == s2.uri().toLower();
}
/*!
\fn bool operator<(const QtSoapQName &s1, const QtSoapQName &s2)
\relates QtSoapQName
If \a s2 has a non-empty URI, this function returns true if the
merge of the URI and the name of \a s1 is lexically less than that
of \a s2; otherwise it returns false.
If \a s2 has an empty URI, this function returns true if the name
of \a s1 is lexically less than the name of \a s2; otherwise
it returns false.
The comparison is case-insensitive.
*/
bool operator <(