ich habe auf meinem Rechner XAMPP installiert und dort ein php soap Servescript liegen. Der php-Client funktioniert ohne probleme.
Allerings bekomme ich den QtSoap-Client nicht zu laufen.
Der Service soll einfach 2 Zahlen addieren und als für den Client habe ich das Population beispielt aus den QtSoap beispielen verwendet.
Ich bekomme aber immer folgende fehlermeldung wenn der Client eine Antwort bekommt:
"Unknown error" "QtSoapMessage::OtherType"
Vielleicht kann mir ja jemand von euch weiterhelfen?
Gruß,
Sebastian
TestClient.cpp
Code: Alles auswählen
#include <QtGui/QApplication>
#include "TestClient.h"
TestClient::TestClient(QObject *parent)
: QObject(parent), http(this)
{
// Connect the HTTP transport's responseReady() signal.
connect(&http, SIGNAL(responseReady()), this, SLOT(getResponse()));
// Construct a method request message.
QtSoapMessage request;
// Set the method and add one argument.
request.setMethod("addiere", "urn:xmethodsTestServer");
request.addMethodArgument("sum1", "", "10");
request.addMethodArgument("sum2", "", "30");
qDebug()<<"Request"<<request.toXmlString();
// Submit the request the the web service.
http.setHost("localhost");
http.setAction("urn:xmethodsTestServer#addiere");
http.submitRequest(request, "/soap/server");
}
void TestClient::getResponse()
{
// Get a reference to the response message.
const QtSoapMessage &message = http.getResponse();
// Check if the response is a SOAP Fault message
if (message.isFault()) {
qDebug("Error: %s", message.faultString().value().toString().toLatin1().constData());
}
else {
// Get the return value, and print the result.
const QtSoapType &response = message.returnValue();
}
qApp->quit();
}
Code: Alles auswählen
#include <qtsoap.h>
class TestClient : public QObject
{
Q_OBJECT
public:
TestClient(QObject *parent = 0);
private slots:
void getResponse();
private:
QtSoapHttpTransport http;
};
Code: Alles auswählen
#include <QtGui/QApplication>
#include "TestClient.h"
int main(int argc, char **argv)
{
QApplication app(argc, argv, false);
TestClient pop(0);
return app.exec();
}
Das ist ein beispiel aus:
http://www.tutorials.de/php-tutorials/1 ... -soap.html
server.php
Code: Alles auswählen
<?php
function addiere($sum1, $sum2) {
return $sum1 + $sum2;
}
$server = new SoapServer("testserver.wsdl",
array('uri' => "localhost",
'soap_version' => SOAP_1_1)); //{uri} müsst ihr ersetzen mit den pfad
$server->addFunction('addiere'); //Funktion zum Server hinzufügen
$server->handle(); //Hier wird die Abfrage abgearbeitet
?>
testserver.wsdl
Code: Alles auswählen
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='TestServer'
xmlns:tns=' [url]http://localhost/soap/testserver.wsdl[/url] '
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='addiereAnfrage'>
<part name='sum1' type='xsd:float'/>
<part name='sum2' type='xsd:float'/>
</message>
<message name='addiereAntwort'>
<part name='Result' type='xsd:float'/>
</message>
<portType name='TestServerPortType'>
<operation name='addiere'>
<input message='tns:addiereAnfrage'/>
<output message='tns:addiereAntwort'/>
</operation>
</portType>
<binding name='TestServerBinding' type='tns:TestServerPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='addiere'>
<soap:operation soapAction='urn:xmethodsTestServer#addiere'/>
<input>
<soap:body use='encoded' namespace='urn:xmethodsTestServer'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethodsTestServer'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='TestServerService'>
<port name='TestServerPort' binding='TestServerBinding'>
<soap:address location='http://localhost/soap/server.php'/>
</port>
</service>
</definitions>