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

Web and WebWorks Development

Reply
Highlighted
Developer
Posts: 207
Registered: ‎07-31-2009
My Device: Not Specified

Get request not working !!!

I need to consume the following web method running on my IIS written in .Net.
 
[WebMethod]
        public string ConcatWithSpace(string one)
        {
            return one + " " + one;
        } 
 
This is the class that contains the get request.I am using the Blackberry plugin for Eclipse.All i am gettig when i use the following code is the web page of the url . I am not able to invoke the method.
 
I dint know how to add the name of the method as parameter. So i have added the method along with the URL's name.  
 
final class HttpConnectionScreen extends MainScreen
{
    private RichTextField _content;
    private EncodedImage image;
    public HttpConnectionScreen()
    { 
            HttpConnection hc = null;
            DataInputStream in = null;
            DataOutputStream out= null;

            try {
           String url= "http://server/WebService1/Service1.asmx?op=ConcatWithSpace";
         
            hc = (HttpConnection)Connector.open(url);
            hc.setRequestMethod(HttpConnection.GET);
            
            out=hc.openDataOutputStream();
 
// I am passing the value for the parameter of the web method as given below. Not sure if this is the right way. But i guess it is going //across. 
  
         out.write("asdf".getBytes());
                        
            out.flush();
            
           
            // System.out.println("Connection is opened with server");
            
                  
            
            
            String resp= hc.getResponseMessage();
            int response = hc.getResponseCode();
            
            int length = (int)hc.getLength();
        
    //System.out.println("Response recieved from server "+response);
 
           byte[] data = null;
 
            if (length != -1) 
            {
              //  System.out.println("known length:"+length);
                data = new byte[length];
                in = new DataInputStream(hc.openInputStream());
                int len = (int)hc.getLength();
                if (len > 0) {
                     int actual = 0;
                     int bytesread = 0 ;
                    
                     while ((bytesread != len) && (actual != -1)) {
                        actual = in.read(data, bytesread, len - bytesread);
                        bytesread += actual;
                     }
                }     
                 String readdata= new String (data);
      // Placed a break point here and saw the data output using the watch window. It had the content of the page of the URl specified above.
 
      //    Dialog.alert(readdata);
             int i =0;
                 
                 //    in.readFully(data);
                
             
            }
 
 
Could some one please help me out and tell me how to invoke the method. And how i should add the name of the method as parameter. 
------------------------------------------------------------------------------------------------------------------------
Click the Kudos! badge on left side of the message , if you are happy with a solution given by a user. When you do so, you are saying thanks to its author.
Mark a reply as a solution , if you think your question has been answered.
To mark a message as a solution: Click "Accept as solution" icon on the reply.