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
BlackBerry Development Advisor
jomurray
Posts: 133
Registered: ‎09-06-2010
My Device: Z30

Re: How to pass username and password into Soap?

It might be a good idea if you were to read one of the many tutorials on the web about how SOAP works and how WSDL is used to describe such web services.

 

So summarise what I said in my pervious post try replacing:

 

m_soap.submitRequest(request, "http://webcond.lbc.bo/WSSYSASIN/WS_SYSASIN.asmx");

 by

 

m_soap.submitRequest(request, "http://webcond.lbc.bo/WSSYSASIN/WS_SYSASIN.asmx?wsdl");

 

---------------------------------------
Please refrain from posting new questions in solved threads.
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Found a bug? Report it here
Follow me on Twitter @jcmrim
Please use plain text.
Developer
shahumang8
Posts: 664
Registered: ‎08-09-2010
My Device: Not Specified

Re: How to pass username and password into Soap?

Same SOAP-ENV:VersionMismatch error fetch.

 

I hope once again please check my code and let me know which place i do wrong??

Please use plain text.
BlackBerry Development Advisor
jomurray
Posts: 133
Registered: ‎09-06-2010
My Device: Z30

Re: How to pass username and password into Soap?

I see that this code is actually the soapxml sample application that's in GitHub here: https://github.com/blackberry/Cascades-Samples/tree/master/soapxml/src/qtsoap which uses a port of QtSoap.

 

The author of this sample is identified in GitHub. What I suggest you do is have a conversation with the application's author regarding the issue that you're having with it. That way the author will also get feedback on his sample and correct it if neccessary.

---------------------------------------
Please refrain from posting new questions in solved threads.
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Found a bug? Report it here
Follow me on Twitter @jcmrim
Please use plain text.
Developer
shahumang8
Posts: 664
Registered: ‎08-09-2010
My Device: Not Specified

Re: How to pass username and password into Soap?

Hi Jomurray,

 

          Can you talk with author??or possible then contct with your member about this problem???

 

          I have some urgency so i need your help.

Please use plain text.
BlackBerry Development Advisor
jomurray
Posts: 133
Registered: ‎09-06-2010
My Device: Z30

Re: How to pass username and password into Soap?

Well, I took a look at the original sample code and it works just fine so I guessed, just as I had mentioned before, that what you're seeing is a function of the *different* web service that you're trying to connect to.

 

As I noted before you should always examine the web service using a tool like SoapUI. I've done this for you, and you can see the expected format of the SOAP 1.1 xml that the server expects. The Qt Soap implementation in this sample is a 3rd party Soap 1.1 implementation that you can find here: https://github.com/commontk/QtSOAP

 

 

foo.png

 

This shows that there are three parameters that you need to sendin this SOAP request:

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header>
      <tem:AuthHeader>
         <!--Optional:-->
         <tem:Username>?</tem:Username>
         <!--Optional:-->
         <tem:Password>?</tem:Password>
      </tem:AuthHeader>
   </soapenv:Header>
   <soapenv:Body>
      <tem:RecuperarTalleres/>
   </soapenv:Body>
</soapenv:Envelope>

 These are Username and Password in the SOAP header in addition to the

 

"<tem:RecuperarTalleres/>"

 

field in the SOAP Body.

 

Knowing the WSDL and format of the request as well as reviewing the Qt Soap documentation on adding structures you can add them to your "requestWeatherServiceInformation()" routine as follows:

 

void WeatherService::requestWeatherInformation() {
	if (m_active)
		return;

	m_active = true;
	emit activeChanged();

	m_succeeded = false;

	m_soap.setAction("http://tempuri.org/RecuperarTextos");
	m_soap.setHost("webcond.lbc.bo");

	QtSoapMessage request;

	QtSoapStruct *soap_struct = new QtSoapStruct(QtSoapQName("AuthHeader", "http://tempuri.org/"));
	soap_struct->insert(new QtSoapSimpleType(QtSoapQName("Username"), "user"));
	soap_struct->insert(new QtSoapSimpleType(QtSoapQName("Password"), "guest"));
	request.addHeaderItem(soap_struct);


	request.setMethod(QtSoapQName("RecuperarTextos"));

	// Submit the method request to the web service.
	m_soap.submitRequest(request, "/WSSYSASIN/WS_SYSASIN.asmx");
}

 

This adds the values of "user" and "guest" for the "Username" and "Password" parameters -- you'll need to provide ones that actually work since the response from the SOAP server is "El servidor no puede procesar la solicitud. ---> Usuario no autorizado ---> Contactese con el administrador de seguridad".

 

You need to allocate QtSoapStruct on the heap rather than the stack to prevent it being destroyed after existing the requestWeatherInfirmation() method. QtSoap seems to do a corresponding "delete" itself.

 

Again, the take home message from this is that it's important to understand the nature of the web service you're connecting to and the WSDL..

 

 

---------------------------------------
Please refrain from posting new questions in solved threads.
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Found a bug? Report it here
Follow me on Twitter @jcmrim
Please use plain text.
Developer
simon_hain
Posts: 16,216
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to pass username and password into Soap?

i hope shahumang8 will find the "like" button for this kind of engagement!
----------------------------------------------------------
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
Please use plain text.
Developer
shahumang8
Posts: 664
Registered: ‎08-09-2010
My Device: Not Specified

Re: How to pass username and password into Soap?

Yes Simon I got like button :smileyhappy:.

Thanks jomurray.
Please use plain text.
Developer
shahumang8
Posts: 664
Registered: ‎08-09-2010
My Device: Not Specified

Re: How to pass username and password into Soap?

[ Edited ]

Hi Jomurray,

 

        Now working fine but still one problem.

 

        I got reponse into html because now i add one parameter into body <tipoTexto>AL</tipoTexto>

 

       FYI :- 

 

              I pass like this as per my understanding but still i got html reponse

 

              

QtSoapMessage request;

		QtSoapStruct *soap_struct = new QtSoapStruct(QtSoapQName("AuthHeader", "http://tempuri.org/"));
		soap_struct->insert(new QtSoapSimpleType(QtSoapQName("Username"), "UMOVIL1"));
		soap_struct->insert(new QtSoapSimpleType(QtSoapQName("Password"), "Mensaje1"));
		request.addHeaderItem(soap_struct);
		QtSoapStruct *soap_bodystruct = new QtSoapStruct(QtSoapQName("RecuperarTextos", "http://tempuri.org/"));
		soap_bodystruct->insert(new QtSoapSimpleType(QtSoapQName("tipoTexto"), "AL"));
		request.addBodyItem(soap_bodystruct);
		request.setMethod(QtSoapQName("RecuperarTextos"));

		// Submit the method request to the web service.
		m_soap.submitRequest(request, "/WSSYSASIN/WS_SYSASIN.asmx");

  

   Now reponse get into html so may i know how to get reponse in text???

 

    Please check which place i do mistake??

 

Please use plain text.
BlackBerry Development Advisor
jomurray
Posts: 133
Registered: ‎09-06-2010
My Device: Z30

Re: How to pass username and password into Soap?

Well, I suspect that you're actually asking the wrong person the wrong question :-).

 

"What do you mean?" -- I hear you say.

 

OK, let's take BlackBerry 10 completely out of the process and use a tool like SoapUI (did you download that as I suggested? It's a really useful tool for exactly this sort f thing).

 

Ok, I've done that for you -- here's a screenshot from SoapUI making the same request that you've done in your code and popluated with the same values:

 

 

Screen Shot 2013-10-16 at 22.18.12.png

 

We get a good response (200) from the remote server, which is comforting, with a payload ot type "text/xml" as we'd expect from a SOAP service. If we look at the response as XML we see the following:

 

Screen Shot 2013-10-16 at 22.18.30.png

 

This is good, it's a correct SOAP response with a payload containing a response to the original request. Here it is in a bit more detail:

 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <RecuperarTextosResponse xmlns="http://tempuri.org/">
         <RecuperarTextosResult>["\u003cp style=\"text-align: center; margin: 0px\"\u003e\u003cspan style=\"font-size: 18pt; font-weight: bold; text-decoration: underline\"\u003eAVISO LEGAL\u003c/span\u003e\u003c/p\u003e\u003cbr /\u003e\r\n\u003cp class=\"MsoNormal\" style=\"text-align: justify; margin: 0cm 0cm 0pt\"\u003e\u003cb\u003e\u003cspan lang=\"ES\" style=\"color: #002060; mso-ansi-language: es\"\u003e\u003cfont size=\"3\"\u003e\u003cfont face=\"Calibri\"\u003eLa Boliviana Ciacruz de Seguros y Reaseguros S.A., deja claramente establ\u003c/font\u003e\u003c/font\u003e\u003c/span\u003e\u003c/b\u003e\u003cb\u003e\u003cspan lang=\"ES\" style=\"color: #002060; mso-ansi-language: es\"\u003e\u003cfont size=\"3\"\u003e\u003cfont face=\"Calibri\"\u003eecido que el alcance de este servicio de aviso de accidente, creado como aplicación para smartphones para nuestros asegurados, es simplemente un aviso no formal que debe necesariamente ser formalizado a través del llenado  del formulario impreso de Denuncia de Accidente o Robo y la documentación requerida para la atención del mismo. Las condiciones previamente expuestas son de  pleno conocimiento del asegurado, quien acepta de manera voluntaria e irrevocable las mismas, presionando a tal efecto  el  botón “Acepto”.\u003c/font\u003e\u003c/font\u003e\u003c/span\u003e\u003c/b\u003e\u003cb\u003e\u003cspan lang=\"ES\" style=\"color: #002060; mso-ansi-language: es\"\u003e\u003cfont size=\"3\"\u003e\u003cfont face=\"Calibri\"\u003e\r\n\u003co:p\u003e\u003c/o:p\u003e\u003c/font\u003e\u003c/font\u003e\u003c/span\u003e\u003c/b\u003e\u003c/p\u003e"]</RecuperarTextosResult>
      </RecuperarTextosResponse>
   </soap:Body>
</soap:Envelope>

 The response payload for the request we've made as sent by the SOAP server has a lot of escaping in there like:

 

... \u003cp style=\"text-align: center; margin: 0px\"\u003e ...

 If we unescape these (\u003c and \u003e are escaped unicode characters) we see that the fragment above becomes:

 

<p style="text-align: center; margin: 0px">

 

So, the SOAP server side is sending HTML in the payload. I think you've noticed this!

 

The point I'm trying to make is that the fact that the server side is sending you HTML is nothing to do with any error in your code per se, nor BlackBerry 10, nor the QtSoap implementation that you're using. It's a function of how the server is responding to your specific request ... you need to understand that interface with the SOAP server and perhaps even have a conversation with the developers of that service.

---------------------------------------
Please refrain from posting new questions in solved threads.
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Found a bug? Report it here
Follow me on Twitter @jcmrim
Please use plain text.
BlackBerry Development Advisor
jomurray
Posts: 133
Registered: ‎09-06-2010
My Device: Z30

Re: How to pass username and password into Soap?

If you think that this discussion has solved your problem or led to a solution to your problem please feel free to mark this as solved since it will help others who have the same or similar questions in the future rather than leaving the thread open-ended with no closure.

---------------------------------------
Please refrain from posting new questions in solved threads.
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Found a bug? Report it here
Follow me on Twitter @jcmrim
Please use plain text.