Пример #1
0
//----------------------------------------------------------------------------
const QtSoapType & ctkSimpleSoapClient::submitSoapRequest(const QString& methodName,
                                                   const QList<QtSoapType*>& soapTypes )
{
  Q_D(ctkSimpleSoapClient);

  /*QString action="\"";
  //action.append(methodName);
  action.append("\"");
  d->Http.setAction(action);*/
  QString action = "http://dicom.nema.org/PS3.19/IHostService/" + methodName;

  d->Http.setAction(action);

  CTK_SOAP_LOG( << "Submitting action " << action
                << " method " << methodName
                << " to path " << d->Path );

  QtSoapMessage request;
  //request.setMethod(QtSoapQName(methodName,"http://wg23.dicom.nema.org/"));
  request.setMethod(QtSoapQName(methodName,"http://dicom.nema.org/PS3.19" + d->Path ));
  if(!soapTypes.isEmpty())
    {
    for (QList<QtSoapType*>::ConstIterator it = soapTypes.begin();
         it < soapTypes.constEnd(); it++)
      {
      request.addMethodArgument(*it);
      CTK_SOAP_LOG( << "  Argument type added " << (*it)->typeName() << ". "
                    << " Argument name is " << (*it)->name().name() );
      }
    }
  CTK_SOAP_LOG_LOWLEVEL( << "Submitting request " << methodName);
  CTK_SOAP_LOG_LOWLEVEL( << request.toXmlString());

  d->Http.submitRequest(request, d->Path);;

  CTK_SOAP_LOG_LOWLEVEL( << "Submitted request " << methodName);

  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

  d->BlockingLoop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);

  QApplication::restoreOverrideCursor();

  //qDebug() << "Reply error: " << reply->errorString();
  //qDebug() << reply->readAll();
  const QtSoapMessage& response = d->Http.getResponse();

  CTK_SOAP_LOG( << "Got Response." );

  if (response.isFault())
    {
    qCritical() << "ctkSimpleSoapClient: server error (response.IsFault())";
    CTK_SOAP_LOG_LOWLEVEL( << response.faultString().toString().toLatin1().constData() << endl );
    CTK_SOAP_LOG_LOWLEVEL( << response.toXmlString() );
    return response.returnValue();
    //    throw ctkRuntimeException("ctkSimpleSoapClient: server error (response.IsFault())");
    }
Пример #2
0
void ctkSoapConnectionRunnable::readClient(QTcpSocket& socket)
{
  //qDebug() << socket->readAll();
  while (socket.canReadLine()) {
    QString line = socket.readLine();
    qDebug() << line;
    if (line.trimmed().isEmpty())
    {
      // Read the http body, which contains the soap message
      QByteArray body = socket.readAll();
      qDebug() << body;

      if (body.trimmed().isEmpty())
      {
        qDebug() << "Message body empty";
        return;
      }

      QtSoapMessage msg;
      if (!msg.setContent(body))
      {
        qDebug() << "QtSoap import failed:" << msg.errorString();
        return;
      }

      QtSoapMessage reply;
      emit incomingSoapMessage(msg, &reply);

      if (reply.isFault())
      {
        qDebug() << "QtSoap reply faulty";
        return;
      }

      qDebug() << "SOAP reply:";

      QString soapContent = reply.toXmlString();

      QByteArray block;
      block.append("HTTP/1.1 200 OK\n");
      block.append("Content-Type: text/xml;charset=utf-8\n");
      block.append("Content-Length: ").append(QString::number(soapContent.size())).append("\n");
      block.append("\n");

      block.append(soapContent);

      qDebug() << block;

      socket.write(block);

    }
  }
}
void TimeSpiderSettingsDialog::requestLogin( )
{
	QtSoapMessage request;
	request.setMethod( "request-login", SERVICE_NAMESPACE );
	request.addMethodArgument( "email", "", email->text( ) );
	request.addMethodArgument( "uid", "", getMacAddress( ) );
    
	QString xml = request.toXmlString( );
	qDebug( ) << "Sending SOAP request: " << xml;

	m_soap.setHost( serviceHost->text( ), serviceUseSSL->isChecked( ), servicePort->value( ) );
	m_soap.submitRequest( request, servicePath->text( ) );

	QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
}
void TimeSpiderSettingsDialog::getResponse( const QtSoapMessage &message )
{
	QApplication::restoreOverrideCursor( );
    
	QString xml = message.toXmlString( );
	qDebug( ) << "Got request login SOAP response: " << xml;
	if( message.isFault( ) ) {
		(void)QMessageBox::warning( this, QString( APPLICATION_NAME ),
			tr( "The service returned an error message: %1")
			.arg( message.faultString( ).value( ).toString( ) ),
			QMessageBox::Ok );
		return;
	}
	
	(void)QMessageBox::information( this, QString( APPLICATION_NAME ),
		tr( "You should receive a registration email. Enter the token into the corresponding field in the settings dialog." ),
		QMessageBox::Ok );
}