Seite 1 von 1

QtSoap 2.7

Verfasst: 17. Februar 2010 14:15
von efau87
Hi!

Ich beschaeftige mich SOAP und Qt, ich versuche zum Beispiel eine Liste von verschieden Items zu bekommen.

Leider bekomme ich
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org /soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<Faultcode xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instan ... /Faultcode>
<Faultstring xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">503 Service Unavailable</Faultstring>
<Faultcode xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instan ... /Faultcode>
<Faultstring xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">SOAP structure invalid</Faultstring>
<SOAP-ENV:Faultdetail xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<extra xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
root element "html"/"html" is not envelope</extra>
</SOAP-ENV:Faultdetail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
zurueck.

Hat jemand QtSoap verwendet? Arbeitet die lib ueberhaupt richtig?

Ingmar

Verfasst: 17. Februar 2010 15:48
von efau87
#ifndef EBAYREQUEST_H
#define EBAYREQUEST_H
#include<Qt>
#include <qtsoap.h>

class eBayRequest:public QObject
{
Q_OBJECT
public:
eBayRequest();
private:
QString error;
QtSoapHttpTransport http;
static const QString Host;
static const int Version;
static const QString AppId;
static const QString RequestEncoding;
static const QString Urn;
static const QString ResponseEncoding;
public slots:
void submitRequest();
void getResponse();

};

#endif // EBAYREQUEST_H
......

#include "ebay.h"


/*#ifdef TEST_ENVIRONMENT // sandbox appid
const QString eBayRequest::AppId = QString( "Nokiae548-91ff-45ee-a4d8-275fc7ab249" );
#else // production appid
*/
const QString eBayRequest::AppId = QString( "Nokia1f99-1b58-450d-8064-55c6ea744b2" );
//#endif

const QString eBayRequest::Host = QString( "open.api.ebay.com" );
const int eBayRequest::Version = 655;
const QString eBayRequest::RequestEncoding = QString( "SOAP" );
const QString eBayRequest::ResponseEncoding = QString( "SOAP" );
const QString eBayRequest::Urn = QString("urn:ebay:apis:eBLBaseComponents");
eBayRequest::eBayRequest()
{
// Connect signals to slots. Note the submitRequest() slots.
connect(&http;, SIGNAL(responseReady()), SLOT(getResponse()));

// Prepare to submit request.
http.setAction(Urn);
http.setHost(Host);
}

void eBayRequest::submitRequest()
{

// Generate request. Details about how to generate a proper
// request are available from http://open.api.ebay.com/.

QtSoapMessage request;

//Add url property to header. AppId and other...

http.header.addValue("Host",eBayRequest::Host);
QtSoapQName name;
QtSoapType *temp;

name = QtSoapQName("X-EBAY-API-VERSION", QString::number( eBayRequest::Version ));
temp = new QtSoapType(name,QtSoapType::AnyURI);
request.addHeaderItem(temp);
message->addHeaderItem(temp);
name = QtSoapQName("X-EBAY-API-APP-ID", eBayRequest::AppId);
type = new QtSoapType(name,QtSoapType::AnyURI);
request.addHeaderItem(type);

name = QtSoapQName("X-EBAY-API-SITE-ID", "0");
type = new QtSoapType(name,QtSoapType::QName);
request.addHeaderItem(type);


name = QtSoapQName("X-EBAY-API-REQUEST-ENCODING", eBayRequest::RequestEncoding );
type = new QtSoapType(name,QtSoapType::AnyURI);
request.addHeaderItem(type);

name = QtSoapQName("X-EBAY-API-RESPONSE-ENCODING", eBayRequest::ResponseEncoding);
type = new QtSoapType(name,QtSoapType::QName);
request.addHeaderItem(type);
*/
//Set method of ebay
request.setMethod(QtSoapQName("FindItems", "urn:ebay:apis:eBLBaseComponents"));
//Set arguments
request.addMethodArgument("QueryKeywords", "", "n900");
request.addMethodArgument("MaxEntries","","50");
printf(request.toXmlString().toAscii());
http.submitRequest(request, "/shopping?");
}

void eBayRequest::getResponse()
{
const QtSoapMessage &resp; = http.getResponse();
printf("\nOutput\n");
printf(resp.toXmlString().toAscii());
return;
}

Verfasst: 19. Februar 2010 12:36
von AuE
Wenn du den Code formatierst guck ich ihn mir gerne an aber so nicht ;-) Sorry aber is echt scheiße zu lesen!

Verfasst: 12. März 2010 12:31
von efau87
AuE, ich kann Dir das komplette Demo-Projekt senden. Habe es bis jetzt noch nicht geschaft. E-mail?
mfg Ingmar

Verfasst: 12. März 2010 13:03
von Exasperation
Was er meinte waren die Code-Tags... damit wird der Code hier automatisch formatiert angezeigt.

Verfasst: 12. März 2010 14:33
von efau87
Ich glaube so ist es besser ;)

Also mein Problem ist ich bekomme (eine Liste mit gesuchten Items) nicht das was ich will, bekomme nur eine errormessage "Transport failed".

Code: Alles auswählen

#include "ebaymain.h"

//TODO:
QString Host = "open.api.ebay.com";
QString Urn = "urn:ebay:apis:eBLBaseComponents";
//QString AppId = "Nokiae548-91ff-45ee-a4d8-275fc7ab249"; //ID Sandbox
QString AppId = "Nokia1f99-1b58-450d-8064-55c6ea744b2"; // ID for Production
QString CallName = "FindItems";
QString RequestEncoding = "SOAP12";
int requestid;
ebaymain::ebaymain()
{
    // Connect signals to slots. Note the submitRequest() slots.
    connect(&http, SIGNAL(responseReady()), SLOT(getResponce()));
    // Prepare to submit request.
    http.setAction(ebaymain::Urn);

    QUrl *url = new QUrl("open.api.ebay.com");
    qDebug() << url->toString();
    http.setHost(url->toString(), QHttp::ConnectionModeHttps, 1408);

    /*set host, header with Http, but i need QtSoap solution
    http_main.setHost(Host, 80);
    http_header.setValue(APP_ID, AppId);
    http_header.setValue(CALL_NAME, CallName);
    http_header.setValue(REQUEST_ENCODING, RequestEncoding);
    http_header.setValue(API_VERSION, "657");
    http_header.setValue("SOAPAction", Urn);
    http_header.setValue("HOST", Host);

    connect(&http_main, SIGNAL(requestFinished(int, bool)), this,SLOT(readResponse(int, bool)));
    connect(&http_main, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
            SLOT(readResponseHeader(const QHttpResponseHeader &)));
    http_header.setContentType("text/xml;charset=utf-8");
    */
}
void ebaymain::submitRequest()
{
    //Prepare request for sending to web-service
    QtSoapMessage request;

    //Fill header and set the header on QtSoapr
    QtSoapQName name;
    QtSoapType *type;

    name = QtSoapQName("HOST");
    type = new QtSoapSimpleType(name, Host);
    request.addHeaderItem(type);

    name = QtSoapQName(APP_ID);
    type = new QtSoapSimpleType(name, AppId);
    request.addHeaderItem(type);

    name = QtSoapQName(CALL_NAME);
    type = new QtSoapSimpleType(name, CallName);
    request.addHeaderItem(type);

    name = QtSoapQName(REQUEST_ENCODING);
    type = new QtSoapSimpleType(name, RequestEncoding);
    request.addHeaderItem(type);

    name = QtSoapQName(API_VERSION);
    //TODO: Change version string
    type = new QtSoapSimpleType(name, "657");
    request.addHeaderItem(type);


    request.setMethod(QtSoapQName("FindItems", Urn));

    request.addMethodArgument("QueryKeywords","", "n900");

    request.addMethodArgument("SellerID","","FavSellerGreen");

    qDebug() << request.toXmlString();

    /* Only for QHttp

    http_header.setRequest("POST", "/shopping?", 1, 0);

    QString b = request.toXmlString();

    QByteArray a = b.toUtf8().constData();

    requestid = http_main.request(http_header, a);

    */

    http.submitRequest(request, "/shopping?");
}

/* Method, Signal slots for QHttp
void ebaymain::readResponseHeader(const QHttpResponseHeader &resp)
{
    if (resp.statusCode() != 200 && resp.statusCode() != 100) {
        response.setFaultCode(QtSoapMessage::Client);
        response.setFaultString(QString::number(resp.statusCode()) + ' ' + resp.reasonPhrase());
    }
}

void ebaymain::readResponse(int id, bool error)
{
    if (id != requestid)
        return;

    if (error) {
        response.setFaultCode(QtSoapMessage::Client);
        response.setFaultString("Transport failed: " + http_main.errorString());
    }
    else {
        response.setContent( http_main.readAll());
    }

    emit responseReady();
}

*/
void ebaymain::getResponce()
{
    const QtSoapMessage &resp = http.getResponse();;
    qDebug() << resp.toXmlString();
    qDebug() << resp.faultCode();
    qDebug() << resp.faultDetail().toString();
    qDebug() << resp.faultString().toString();
}
Und hier die .h.

Code: Alles auswählen

#include "qtsoap.h"
#include <QString>
#include <QDebug>
#include <QObject>
#include <QHttp>

#ifndef EBAYMAIN_H
#define EBAYMAIN_H

#define APP_ID "X-EBAY-API-APP-ID"
#define CALL_NAME "X-EBAY-API-CALL-NAME"
#define API_VERSION "X-EBAY-API-VERSION"
#define REQUEST_ENCODING "X-EBAY-API-REQUEST-ENCODING"


class ebaymain : public QObject
{
    Q_OBJECT
public:
    ebaymain();
public slots:
    void getResponce();
    void submitRequest();
    /* slots and signals for QHttp
    void readResponse(int id, bool error);
    void readResponseHeader(const QHttpResponseHeader &resp);

    signals:
            void responseReady();
    */
private:
    QString Urn;
    QString Host;
    int Version;
    QString AppId;
    QString RequestEncoding;
    QString ResponseEncoding;
    QtSoapHttpTransport http;
  /* only for QHttp
    QHttp http_main;
    QHttpRequestHeader http_header;
    QtSoapMessage response;
    */
};

#endif // EBAYMAIN_H

Any ideas?[/code]

Verfasst: 16. März 2010 18:29
von AuE
Jau.... ich sehe einmal das da steht
503 Service Unavailable
und dann noch das
SOAP-ENV:VersionMismatch

Code: Alles auswählen

<Faultcode xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">SOAP-ENV:Client</Faultcode> 
<Faultstring xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">503 Service Unavailable</Faultstring> 
<Faultcode xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">SOAP-ENV:VersionMismatch</Faultcode> 
<Faultstring xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">SOAP structure invalid</Faultstring> 
<SOAP-ENV:Faultdetail xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
<extra xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">

Habe leider imho wenig Zeit....sry. Ich versuche es mal zu reproduzieren.... aber irgendwo hier hatte ich schon mal meinen standard soap code gepostet.

Verfasst: 20. März 2010 11:07
von efau87
AuE hat geschrieben: Habe leider imho wenig Zeit....sry. Ich versuche es mal zu reproduzieren.... aber irgendwo hier hatte ich schon mal meinen standard soap code gepostet.
In welchen Thread befindet er sich?
Ist es der standard code von qtsoap (google, population)?