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

Java Development

Reply
New Contributor
Posts: 6
Registered: ‎04-16-2012
My Device: 9930
My Carrier: Blackberry

web service parameter passing issue

Hello everyone,

 

I am making demo of consuming the web service in blackberry using Ksoap jar.

 

my web service has following structure

 

 <soapenv:Body>
      <ser:authorize>
         <!--Optional:-->
         <arg0>
            <!--Optional:-->
            <pwd></pwd>
            <!--Optional:-->
            <uName></uName>
         </arg0>
      </ser:authorize>
   </soapenv:Body>

 

the two fields username and password resides in one class called authRequest.

 

and i m passing these parameters as follow..


            SoapObject request = new SoapObject(NAMESPACE,  METHOD_NAME);
            request.addProperty("pwd", password);
            request.addProperty("uName",userName);
            

i got the following erroe when i saw it in logger...

           

 

any suggestions will be appreciated.

thanks in advance..

 

 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: web service parameter passing issue

this means that you get a http error, and ksoap2 cannot handle these by default, you will have to add it.
we did so by overriding the connection handling in SocketConnectionEnhanced and checking the http response code, throwing an exception if it was not 200.
----------------------------------------------------------
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
Highlighted
Developer
Posts: 151
Registered: ‎01-20-2010
My Device: Blackberry Bold
My Carrier: Telefonica

Re: web service parameter passing issue

i know that you are using ksoap, but you maybe this info can help you.

 

http://technology.amis.nl/2011/06/29/how-to-call-a-call-a-webservice-directly-from-java-without-webs...

 

pd: sorry for my english. 

 

Good luck.

New Contributor
Posts: 6
Registered: ‎04-16-2012
My Device: 9930
My Carrier: Blackberry

Re: web service parameter passing issue

hii all,

 

basically my question is in my web method the agruement  itlsef is a class and having two fields inside it.

 

like the following

 

public class AuthRequest {

    private String uName;
    private String pwd;

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getuName() {
        return uName;
    }

    public void setuName(String uName) {
        this.uName = uName;
    }   
}

 

now my web service method this class as an arguement

 

like the following

public AuthResponse authorize(AuthRequest request) {

}

 

so i can not pass the arguement properly in my request how can i do it??

 

following is my code for calling the web service...

 

SoapObject request = new SoapObject(NAMESPACE,  METHOD_NAME);
            long user=Long.parseLong(userName);


            // Add the input required by web service
            request.addProperty("pwd", password);
            request.addProperty("uName",new Long(user));
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            //envelope.setOutputSoapObject(request);
            
            envelope.bodyOut=request;
            envelope.dotNet = false;
            envelope.encodingStyle = SoapSerializationEnvelope.ENC;
            
            EventLogger.logEvent(Guid.eventLogId,"####### Make WS Call..".getBytes());
            // Make the soap call.
            ht.call(SOAP_ACTION, envelope);

 

 

so my question is how to pass the parameters when parameter is itself a class and how can i set its fields??

 

please review my first post where i can pass the value of username and password...

 

please do needfull.

 

New Contributor
Posts: 6
Registered: ‎04-16-2012
My Device: 9930
My Carrier: Blackberry

Re: web service parameter passing issue

hii simon,

 

may  be you can help me out for this...

 

basically my question is in my web method the agruement  itlsef is a class and having two fields inside it.

 

like the following

 

public class AuthRequest {

    private String uName;
    private String pwd;

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getuName() {
        return uName;
    }

    public void setuName(String uName) {
        this.uName = uName;
    }   
}

 

now my web service method this class as an arguement

 

like the following

public AuthResponse authorize(AuthRequest request) {

}

 

so i can not pass the arguement properly in my request how can i do it??

 

following is my code for calling the web service...

 

SoapObject request = new SoapObject(NAMESPACE,  METHOD_NAME);
            long user=Long.parseLong(userName);


            // Add the input required by web service
            request.addProperty("pwd", password);
            request.addProperty("uName",new Long(user));
            
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            //envelope.setOutputSoapObject(request);
            
            envelope.bodyOut=request;
            envelope.dotNet = false;
            envelope.encodingStyle = SoapSerializationEnvelope.ENC;
            
            EventLogger.logEvent(Guid.eventLogId,"####### Make WS Call..".getBytes());
            // Make the soap call.
            ht.call(SOAP_ACTION, envelope);

 

 

so my question is how to pass the parameters when parameter is itself a class and how can i set its fields??

 

please review my first post where i can pass the value of username and password...

 

please do needfull.

Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: web service parameter passing issue

To pass complex parameter as part of Ksoap request , please read the following link

 

http://www.codeproject.com/Articles/29305/Consuming-NET-Web-Services-via-the-kSOAP-library

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: web service parameter passing issue

You can also refer to the post below

 

http://supportforums.blackberry.com/t5/Java-Development/KSOAP2-Complex-type-containing-complex-type-...

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.