How to make HTTP GET request socket?

I want to use socket make HTTP GET, but I always got the error 501 return.

Result:



501 method not implemented

Method not implemented


to / index.html unsupported.



Apache/2.0.52 (CentOS) Server at li43-231.members.linode.com Port 80

Code:

streamConnection =
(StreamConnection) Connector.Open (getURL (3) + APN_STR, Connector.READ_WRITE);
           
create DataOuputStream on the top of the socket connection
outputStream = streamConnection.openOutputStream ();
dataOutputStream = new DataOutputStream (outputStream);
           
Send the HTTP request
dataOutputStream.writeChars ("GET/index.html http/2.0\n");
dataOutputStream.writeChars ("host: badev.liveblockauctions.com\n");
dataOutputStream.writeChars("User-Agent:BlackBerry/3.2.1\n");
dataOutputStream.writeChars("Content-Language:en-US\n\n");

dataOutputStream.flush ();
           
create DataInputStream on top of the socket connection
inputStream = streamConnection.openInputStream ();
dataInputStream = new DataInputStream (inputStream);
           
retrieve the content of the requested server Web page
int inputChar;
int size = 0;
StringBuffer results = new StringBuffer();
While ((inputChar = dataInputStream.read ())! = - 1) {}
size ++;
Results.Append ((Char) inputChar);
}

JDE 4.6 and blackberry "BOLD".

Any suggestion?

Thank you very much!

Tags: BlackBerry Developers

Similar Questions

  • HTTP Get Request does not work

    I have this kind of url

    http://etangsoft.gicp.net:9001/sites/all/modules/station/AddRating.php?uuid=870262332&author=Alfa%20...
    

    Request to the server will be inserted in the database a matching record.

    my code:

    HttpConnection conn = (HttpConnection)Connector.open(url);
      if(conn.getResponseCode == 200){
          result = "true";
      }
    

    I was wrong, she?  Please give some code examples.

    Thank you

    There are many many posts similar to this on this forum.

    Connectivity on the BlackBerry is not simple.  You have to work at home.  If you need to do research to figure out how to do it.

    There are tutorials and videos on this site and many other forum posts for you to watch.

    I suspect that this thread will give you a good taste as well as links to other locations for you to review:

    http://supportforums.BlackBerry.com/T5/Java-development/connecting-your-BlackBerry-http-and-socket-c...

  • How to make http post in the Webcenter Portal Application?

    Hi all

    We have a requirement in which we must train to an external URL.

    We have created a Taskflow bounded with page fragment. Added a button on the page fragment and had to form POST to an external URL the button click. Expected features, the URL of the external site will open in the same tab.

    But we can not directly use html form tag in the page jspx because it cannot have two form elements.

    Example code snippet that we use:

    " < form id ="meetingPost"action =" http://XYZ/reg.aspx "

    method = "POST" >

    < input type = "hidden" name = "userId" value = "12345" / >

    < / make >


    We have tried to do this programmatically as below. But it does not work.

    JSPX code:

    <? XML version = "1.0" encoding = "UTF - 8"? >

    " < = xmlns:jsp jsp:root ' http://Java.Sun.com/JSP/page "version ="2.1" "

              xmlns:f=" http://Java.Sun.com/JSF/core "

              xmlns:h=" http://Java.Sun.com/JSF/HTML "

    ' xmlns:af = ' http://xmlns.Oracle.com/ADF/faces/rich "> "

    < jsp:directive.page contentType = text/html"; Charset = UTF - 8 "/ >

    < f: view >

    < af:document id = "d1" >

    < af:form id = "f1" >

    < af:region value = "#{bindings." TestTF1.regionModel}"id ="r1"/ >

    < / af:form >

    < / af:document >

    < / f: view >

    < / jsp:root >

    JSFF code:

    <? XML version = "1.0" encoding = "UTF - 8"? >

    " < = xmlns:jsp jsp:root ' http://Java.Sun.com/JSP/page "version ="2.1" "

    ' xmlns:af = ' http://xmlns.Oracle.com/ADF/faces/rich "" "

              xmlns:f=" http://Java.Sun.com/JSF/core ">

    < af:resource type = "javascript" >

    function postToURL (url) {}

    var form = createElement ('form');

    form.setAttribute ("method", "POST");

    form.setAttribute ("action", url);

    Form._submit_function = form.submit;

    form.appendChild (document.createElement ("input", {type: "hidden", name: "userId", value: "12345"}));

    document.body.appendChild (form);

    Form._submit_function ();

    }

    < / af:resource >

    < af:panelGroupLayout id = "pgl1" layout = "horizontal" >

    < af:commandButton text = "Submit" id = "cb1".

    actionListener = "#{pageFlowScope.SampleBean.postToCvent}" > < / af:commandButton >

    < / af:panelGroupLayout >

    < / jsp:root >

    Managed Bean Code:

    {} public void postToCvent (ActionEvent actionEvent)
    FacesContext fctx = FacesContext.getCurrentInstance ();
    String url = " " http://XYZ/reg.aspx ";
    ExtendedRenderKitService service = Service.getRenderKitService (fctx, ExtendedRenderKitService.class);
    StringBuffer script = new StringBuffer();
    script. Append ("postToURL('");
    script. Append (URL);
    script. Append("')"); "
    service.addScript (fctx, script.toString ());

    }

    Thank you

    Bharat

    Abhijit salvation,

    sendRedirect don't GET, POST.

    in any case I solved the problem by substituting the attribute action for af:form using java script and adds input fields on the fly and able to reach the POST form to an external URL.

    JavaScript (test.js file):

    function postToCvent (event) {}

    If (event! = null) {}

    Get the source Customer attribute

    var url = event.getSource () .getProperty ('url');

    var userId = event.getSource () .getProperty ("userId");

    Get the form by Id element, it will be af:form Id

    var form = AdfPage.PAGE.findComponentByAbsoluteId ("mform");

    If (form! = null) {}

    formId var = form.getClientId ();

    document.getElementById (formId) .setAttribute ("method", "POST");

    document.getElementById (formId) .setAttribute ("action", url);

    Create and add the input field to your

    var hiddenField1 = document.createElement ("input");

    hiddenField1.setAttribute ("type", "hidden");

    hiddenField1.setAttribute ("name", "userId");

    hiddenField1.setAttribute ("value", username);

    document.getElementById (formId) .appendChild (hiddenField1);

    SubmitForm

    document.getElementById (formId) .submit ();

    }

    }

    JSFF code:


    http://XYZ/reg.aspx"/ >

    JSPX code:


    source="/resources/test.js"/ >

    Thank you

    Bharat

  • How to make a background request

    Hello friends,

    I want to apply who have no User Interface and run in the background. Please tell me how we can make an application background.

    Thank you & best regards

    Dinesh

    As we said, it is not currently possible.

    If it turns out to be possible, I'm pretty sure that it will not support WebWorks or AIR directly. It will take the native SDK. It's just a guess... you know nothing about it.

  • How to make the SOAP request with the complex data types?

    Hi all

    I want to apply soap like that, how I can do this,


            string
            string


            dateTime
            dateTime

    string

    Thanks in advance.

    Any help?

  • How to make this Xquery request in XMLQuery

    Hello world
    If I have these tables
    create books (books, varchar2 (64), XML_DOCUMENT XMLType);
    Create table review (FILENAME, varchar2 (64), XML_DOCUMENT XMLType);

    and populated by
    INSERT INTO (books, XML_DOCUMENT) VALUES ('books', xmltype ('))
    < library >
    < Book category = "COOKING" >
    < title lang = "fr" > < /title > Italian newspaper
    < author > Giada De Laurentiis < / author >
    < year > 2005 < / year >
    < price > 30.00 < / price >
    < / book >
    < Book category = "COOKING" >
    < title lang = "fr" > < /title > Italian newspaper
    < author > Norah < / author >
    < year > 2005 < / year >
    < price > 30.00 < / price >
    < / book >
    < Book category = "COOKING" >
    < title lang = "fr" > < /title > Italian newspaper
    Rama < author > < / author >
    < year > 2005 < / year >
    < price > 30.00 < / price >
    < / book >
    < Book category = "COOKING" >
    < title lang = "fr" > < /title > Italian newspaper
    < author > love < / author >
    < year > 2005 < / year >
    < price > 30.00 < / price >
    < / book >
    < Book category = "COOKING" >
    < title lang = "fr" > < /title > Italian newspaper
    < author > Dedo < / author >
    < year > 2005 < / year >
    < price > 30.00 < / price >
    ((< / book > '));

    INSERT INTO test (FILENAME, XML_DOCUMENT) VALUES ('Journal', xmltype ('))
    < test >
    Italian newspapers < title > < /title >
    < author > Giada De Laurentiis < / author >
    < year > 2005 < / year >
    < price > 30.00 < / price >
    < / review >
    ') );

    and I want this xquery in XMLTYPE level
    for $a in doc ("F:\movie\books.xml") / / title,.
    $b in //review doc ("F:\movie\review.xml")
    where $a = $b / title
    return < result > {$a, $b/author} < / result >

    Just answer me quickly I have a problem with this

    Hi Nina,

    can you please explain a bit what you expect the output of your XQuery?
    Do you want the library books for which there is a review, or just books where the title is the same with a book that was reviewed?

    The two cases above do not produce the same result...

    To answer your question, in order to execute the request of Michael in your environment, all you have to do is drop the subquery clauses weighted (i.e. everything that precedes him ' select * from xmltable "part) and also to replace the column names and the table in the clause of passage with what is appropriate.
    In your case, "xmltype (cursor (select * books))" should be replaced by "xmltype (cursor (select XML_DOCUMENT from books))" and "xmltype (cursor (select * review)) should be replaced by" xmltype (cursor (select review XML_DOCUMENT)) ".»

    If you want the books to the library for which a review is, then you need to replace your query with
    {code}
    Select * from xmltable (' for $i in $rv / / review)
    for $j in $bk / / book [title = $i / title and author = $i / author]
    return the result of the element {$j/title/text (), ', ', $j/author/text ()}
    "passing xmltype (cursor (select * from books)) as"bk ",
    XmlType (cursor (select * from revision)) as "rv")
    {code}

    Best regards

    Philippe

  • Query HTTP Get Datasocket returns error 42

    Hello

    I currently use the 'DataSocket Read' function to make the HTTP request.

    My request is actually to make a HTTP Get request from a particular Web site.

    For example:

    http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_JXxQP6rxl.fBFGgCdNjoDMACQA--&stre...

    This request fails and the error return code is "Error 42".

    However, I have no problem making an HTTP request to other sites.

    For example:

    http://www.Google.com.SG/search?hl=en&q=datasocket+read+error+42&btnG=search&meta=&AQ=f&OQ=

    Can I know what is the reason for this failure happen?

    Thank you

    How to say

    Hi how to say,

    I've handled a request for assistance and came across this thread when I was looking for information, do not know if you still need help because it has been a while, but here are the VI, you can use.

    The problem of Datasocket was born because the page you are trying to read is actually a Web Service that returns information in XML format. You need to add [text] at the end of the URL for you Datasocket return information in the form of unformatted text. Please see this KB for more information: recovery of a file via FTP or HTTP using DataSocket unformatted text

    After that, it is the string manipulations to take the information from latitude and longitude based on information in the returned text.

    I hope this helps.

    Best regards
    Boon Chen

    Applications OR the ASEAN engineer

  • HTTP GET method with the body of the message

    Hi all

    I work with an API using HTTP to make calls to a server. I met an API call in the documetnation that uses the HTTP GET method with a message body. It seems that this is not supported by LV14 because I do not see an entry of message body for the LabVIEWHTTPClient.lvlib:GET.vi function. The POST methods and COULD appear to be banned for this API call, I a not found 405. I could be stuck with the help of GET.

    Certainly, this isn't recommended GET method - but it is not explicitly forbidden in the HTTP/1.1 specification. Is there a work around to submit an HTTP GET request to content? I have to use HTTP external DLL to achieve?

    All entries would be great.

    Thank you

    Richard

    Seems to be a problem on the server side?  Maybe I misunderstood what you were trying to get?

  • How to apply http with the string parameter in the development of BB10 using WebWorks.

    Hi all

    I'm developing an application BB10 Webworks setting, I want to make an http request by adding a string parameter. What type of http request, I'll use. any help of code base.

    Thank you all

    Use the JavaScript XmlHttpRequest object to make a GET request to a remote URL.

    https://github.com/BlackBerry/WebWorks-community-samples/BLOB/master/kitchenSink/js/browser/XHR.js

    Here is an example:

    var url = "http://www.yourwebsite.com/index.asp?foo=bar"
    var xhr = new XMLHttpRequest();
    
    xhr.open('GET', url, true);
    
    xhr.onreadystatechange = function(e) {
        if (xhr.readyState === 4) {
            if (xhr.status === 200 || xhr.status === 0)  {
                console.log(xhr.responseText);
            }
            else {
                console.log("Error (" + xhr.status + "): " + xhr.statusText);
            }
        }
    };
    
    xhr.send(null);
    
  • Make a JSON request refresh data every minute!

    Hello

    How to make an API request the update automatically on a page-a term? (every minute or so)

    Here essentially power SEND dynamic data via JSON to PhoneGap apps that I build of edge animate projects.

    Thus, for example, the JSON could contain information that generates a new symbol or starts a symbol playing, etc.. Or updated an animation with wind speed from a weather API.

    Thanks in advance! It would be so cool!

    If you put it in composition.ready, then it will repeat until you stop it. I won't say that you can not put it somewhere else because it depends on what you need, but it's easier to understand the scope of your duties, if they are attached to the scene, especially those you want to call on various elements within the composition.

    If you add it to an event click, do not forget to clearInterval() otherwise you will have multiple functions, tail, for example

    {sym.$('element').on ('click', Function ()}

    clearInterval (myInterval);

    setInterval myInterval =(function () {doSomething}; 60000);

    });


    Well put setInterval() on a timeline in a loop, you would get to be several events lining up, or you'll end up to the range of compensation (and cancel the event) before its arrival in fact. But, if you want to use a loop mount, you wouldn't need setInterval() and setTimeout() in any case, you could just raise the event every time that the timeline reached the trigger.

  • Query HTTP GET returning always with '? ' at the beginning

    Hi all

    I did experiment with the display of HTML content in a BrowserField (5.0) two different ways:

    1. With the help of browserField.requestContent (url);
    2. Retrieve the HTML of "url" using a HTTP GET request and then displaying the HTML retrieved with:
    browserField.displayContent(response, http://localhost);
    

    I would use the method #2 because I want to be able to cache the HTML source in a persistent storage. However, for some reason when I use the #2 method, the HTML returned by the HTTP response contains a '? ' at the very beginning of the response/html:

    ? Founded in 2008, ...
    

    I concluded that the problem is not with my .html page.  The question mark seems to be introduced during the HTTP request/response.  However, when I use the same method #2 to a different URL, say from google.com, the source is returned without an exclamation mark.

    Any ideas?

    I'll just be brief here, because I think you might be capable of that worked for yourself and therefore save me time...

    I suspect that you have a BOM - Byte Order mark, which is used by some Web sites, search wikipedia for more information.

    Anyway, you really want to convert html get UTF - 8 and then give the string to the browser field, because it is not converted into UTF - 8 correctly.  So I suspect that you can only receive input html in the form of bytes, including the Board of Directors and pass directly through to the BrowserField.

    See this thread for more information:

    http://supportforums.BlackBerry.com/T5/Java-development/displaying-UTF-8-string-problem-in-browserFi...

  • I usually get hyperlinks have advertising, the "moms make money at home? How can one, I get rid of this browser bug?

    I usually get hyperlinks have advertising, the "moms make money at home? How can one, I get rid of this browser bug?
    I downloaded, install and scan with Malwarebytes Anti-Malware laptop several times and it of better, but is still hyper-lier words, with the announcement that the link
    Any suggestions?

    Do a check with some malware malware, analysis of programs on the Windows computer.

    Please scan with all programs, because each program detects a different malicious program.

    Make sure that you update each program to get the latest version of their databases before scanning.

    Alternatively, you can write a check for an infection rootkit TDSSKiller.

    See also:

  • When I export my bookmarks to an html file, I get a file json instead. How to make a html file that I can import into safari?

    When I export my bookmarks as an html file, I get a file json instead. How to make a html file that I can import into Safari?

    Use bookmarks > organize bookmarks > import and backup > export HTML and make sure that you give the file an extension of .html file.

    See also:

  • How to make the darker text and how to get rid of the ads on my toolbar

    original title: GI 82 and my text is too light, how to make it darker also how can I get rid of the ads on my toolbar

    Just do my text coming or in your darkest records

    Hello

    1 are you referring to the ads in the Internet Explorer toolbar?

    2. are you referring to the policies of the Internet Explorer icons?

    Method 1: You can change the theme of the operating system Windows 7 high contrast themes that will make the text and the darkest record.

    Follow the steps below to change the high contrast theme.

    1. open Personalization by clicking the Start button, then Control Panel. In the search box, type personalization, and then click customization.

    2. under Basic and high contrast themes, click Windows 7 Basic or one of the high contrast themes.

    Method 2: In order to disable ads in Internet Explorer disable all modules and check if this is useful.

    No add-on, run Internet Explorer mode.

    a. Click Start, point to programs, point to Accessories and system tools

    b. click Internet Explorer (No Add-ons).

    If this resolves the problem, follow these steps to isolate the browser add-on that is causing the problem:

    a. click Tools and then click Internet Options.

    b. click on the tab programs, then click on Manage Add-ons.

    c. click an add-on in the name list and then click on disable.

    d. Repeat step c until you identify the add-on that is causing the problem.

    If this solves the problem, this could be caused by an adware installed as add-on. See the link below for more information.

    http://Windows.Microsoft.com/en-us/Windows/help/Internet-Explorer/slow-five-tips-to-boost-performance

  • After launching the recovery cd, request activation and product key is unfortunate. So how / where can I get the product key

    product key for windows vista

    After launching the recovery cd, request activation and product key is unfortunate. So how / where can I get the product key

    See if this helps:-

    http://support.Microsoft.com/kb/823570

    If she please vote as helpful.

    Thank you.

Maybe you are looking for