Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
nuelbruno
Posts: 31
Registered: ‎05-18-2014
My Device: z10

calling two webservice at the sametime

Hi all,

 

I need to call two webservice using soap at the same time.. below is the code i am using .. but i am not getting the proper responce from the both webservice.. only one responce i am getting ..Please check the code and suggest me a better way to achieve this.

 

QML webservice call
====================

// i am calling this below webservice onclick of button pmowebservice.getNumOfDaysBetween(adsenceCodeValue.selectedValue,startDatePass, endDatePass, Qt.employeeIDset, Qt.userName, Qt.passWord); pmowebservice.getleaveBalanceForEach(adsenceCodeValue.selectedValue,startDatePass, Qt.employeeIDset, Qt.userName, Qt.passWord);

 Here is the web service call

 

void PMOwebservice::getleaveBalanceForEach(const QString &absenceCode, const QString &startDate,
        const QString &empid, const QString &username, const QString &password)
{
    currentWS = "getLeaveBalanceForEach";

    m_Username = username;
    m_Password = password;

    //getNumOfDaysBetween(absenceCode, startDate, "", empid, username, password);

    QString message;

       message =
               "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org\">";

       message = message + "<soapenv:Header/><soapenv:Body>";
       message = message + "<tem:PYLLeaveWSGetLeaveBalanceRequest>";
       message = message + "<tem:_HRMAbsenceCodeId>"+absenceCode+"</tem:_HRMAbsenceCodeId><tem:_emplID>" + empid
               + "</tem:_emplID>";
       message = message + "<tem:_startDate>" + startDate + "</tem:_startDate>";
       message = message + "</tem:PYLLeaveWSGetLeaveBalanceRequest>";
       message = message + "</soapenv:Body></soapenv:Envelope>";

    QString action = "http://tempuri.org/PYLLeaveWS/getLeaveBalance";
    QString host = "pmo-avm-ax.cloudapp.net";
    QString prefix = "/MicrosoftDynamicsAXAif50/pylleavews.svc";

    callSVC(action, host, prefix, message, false);
}

// second web service call
void PMOwebservice::getNumOfDaysBetween(const QString &absenceCode, const QString &startDate,
        const QString &endDate, const QString &empid, const QString &username, const QString &password)
{
    currentWS = "getNumOfDaysBetween";

    m_Username = username;
    m_Password = password;

    QString message;

       message =
               "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org\">";

       message = message + "<soapenv:Header/><soapenv:Body>";
       message = message + "<tem:PYLLeaveWSGetNoOfDaysRequest>";
       message = message + "<tem:_HRMAbsenceCodeId>"+absenceCode+"</tem:_HRMAbsenceCodeId><tem:_emplID>" + empid
               + "</tem:_emplID>";
       message = message + "<tem:_endDate>"+endDate+"</tem:_endDate><tem:_startDate>" + startDate + "</tem:_startDate>";
       message = message + "</tem:PYLLeaveWSGetNoOfDaysRequest>";
       message = message + "</soapenv:Body></soapenv:Envelope>";

    QString action = "http://tempuri.org/PYLLeaveWS/getNoOfDays";
    QString host = "pmo-avm-ax.cloudapp.net";
    QString prefix = "/MicrosoftDynamicsAXAif50/pylleavews.svc";

    callSVC(action, host, prefix, message, false);
}
void PMOwebservice::callSVC(const QString &action, const QString &host, const QString &prefix,
        const QString &request, const bool &isSecure)
{

   

    if (m_active)
        return;

    m_active = true;
    emit activeChanged();

    m_succeeded = false;

    m_soap.setAction(action);
    m_soap.setHost(host, isSecure);
    
    QtSoapMessage data;

    QString username_d = m_Username;

    QString password_d = m_Password;

    m_soap.submitRequest(data, prefix, request, true, username_d, password_d);

}

void PMOwebservice::onServiceResponse()
{
    
    const QtSoapMessage& response = m_soap.getResponse();

    

    qDebug() << "soap response: " << response.toXmlString(0) << "<br>"; // only one webservice responce i am getting( the last web service responce) .. how to get reponce of two web service
} 

 Thanks in advance..................

 

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: calling two webservice at the sametime

you probably need two different instances of the service to be able to call them at once.

why is it not sufficient to call them one after another? would be a lot easier to implement.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
nuelbruno
Posts: 31
Registered: ‎05-18-2014
My Device: z10

Re: calling two webservice at the sametime

Hi thanks for the reply...

 

i am calling this 

 

pmowebservice.getleaveBalanceForEach(adsenceCodeValue.selectedValue,startDatePass, Qt.employeeIDset, Qt.userName, Qt.passWord);

 

and after getting responce from this.. i am calling the below line

pmowebservice.getleaveBalanceForEach(adsenceCodeValue.selectedValue,startDatePass, Qt.employeeIDset, Qt.userName, Qt.passWord);

But it is not going into  this function

void PMOwebservice::onServiceResponse()

 

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: calling two webservice at the sametime

can you call both services independently without issues?
check all your signal connections and disconnections.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
nuelbruno
Posts: 31
Registered: ‎05-18-2014
My Device: z10

Re: calling two webservice at the sametime

i can call independently without issues
Developer
nuelbruno
Posts: 31
Registered: ‎05-18-2014
My Device: z10

Re: calling two webservice at the sametime

You have mentioned this "you probably need two different instances of the service to be able to call them at once."

Could u plz show one example on how to do.. i am new to blackberry development