How to send a request to a web server

Hi All!
How can I send a request to a web server using java.net package? Can any one give me a simple example?
thanks,
Padma.

http://javaalmanac.com/egs/java.net/Post.html
http://www.developer.com/tech/article.php/761521
http://www.javaworld.com/javaworld/jw-03-2001/jw-0323-traps.html

Similar Messages

  • How to send a request and get a response through xml

    How to send a request and get a response through xml files?

    This is the code that works for me. Hope you find it useful.
         public static String sendHttpGetRequest(String endpoint, String requestParameters){
              String result = null;
              // Send a GET request to the servlet
              try{
                   // Send data
                   String urlStr = endpoint;
                   if (requestParameters != null && requestParameters.length () > 0){
                        urlStr += "?" + requestParameters;
                   URL url = new URL(urlStr);
                   HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                   conn.setRequestProperty("Accept", "application/xml");
                   // Get the response
                   BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                   StringBuffer sb = new StringBuffer();
                   String line;
                   while ((line = rd.readLine()) != null){
                        sb.append(line);
                   rd.close();
                   result = sb.toString();
              } catch (Exception e){
                   e.printStackTrace();
              return result;
         }

  • Best Practices Question: How to send error message to SSHR web page.

    Best Practices Question: How to send error message to SSHR web page from custom PL\SQL procedure called by SSHR workflow.
    For the Manager Self-Service application we’ve copied various workflows which were modified to meet business needs. Part of this exercise was creating custom PL\SQL Package Procedures that would gather details on the WF using them on custom notification sent by the WF.
    What I’m looking for is if/when the PL\SQL procedure errors, how does one send an failure message back and display it on the SS Page?
    Writing information into a log or table at the database level works for trouble-shooting, but we’re looking for something that will provide the end-user with an intelligent message that the workflow has failed.
    Thanks ahead of time for your responses.
    Rich

    We have implemented the same kind of requirement long back.
    We have defined our PL/SQL procedures with two OUT parameters
    1) Result Type (S:Success, E:Error)
    2) Result Message
    In the PL/SQL procedure we always use below construct when we want to raise any message
    hr_utility.set_message(APPL_NO, 'FND_MESSAGE_NAME');
    hr_utility.raise_error;
    In Exception block we write below( in successful case we just set the p_result_flag := 'S';)
    EXCEPTION
    WHEN APP_EXCEPTION.APPLICATION_EXCEPTION THEN
    p_result_flag := 'E';
    p_result_message := hr_utility.get_message;
    WHEN OTHERS THEN
    p_result_flag := 'E';
    p_result_message := hr_utility.get_message;
    fnd_message.set_name('PER','FFU10_GENERAL_ORACLE_ERROR');
    fnd_message.set_token('2',substr(sqlerrm,1,200));
    fnd_msg_pub.add;
    p_result_message := fnd_msg_pub.get_detail;
    After executing the PL/SQL in java
    We have written some thing similar to
    orclStmt.execute();
    OAExceptionUtils.checkErrors (txn);
    String resultFlag = orclStmt.getString(provide the resultflag bind no);
    if ("E".equalsIgnoreCase(resultFlag)){
    String resultMessage = orclStmt.getString(provide the resultMessage bind no);
    orclStmt.close();
    throw new OAException(resultMessage, OAException.ERROR);
    It safely shows the message to the user with all the data in the page.
    We have been using this construct for a long time for all our projects. They are all working as expected.
    Regards,
    Peddi.

  • How to send iPhone photos to Picasa Web Albums

    This may be old news, but I came across this today and thought others would find it useful. Here's exactly how to send iPhone photos to Picasa Web Albums...no 3rd party apps or downloads required!
    http://www.shaneeubanks.com/general/how-to-send-iphone-photo-to-picasa/
    Enjoy!

    You can upload directly to Facebook or Flickr by going to the photo on your phone and while viewing it, tap the upload button (square with an up arrow) at the lower left of the screen.

  • Send data from applet to web server

    Hi,
    I want to send data(event notification) to resource through web server using url.
    Like,As long as perticular action or event is occuring I am sending that message to url.
    I reffered Sevlet theory uses HTTPMessage,but I am confused how should start and what would be feasible?
    Even when I run my code I am not finding browser.How should I place an applet in web server page?
    Regards,
    Palak
    Message was edited by:
    palak_shah

    Hi
    I agree usage of HttpClient is a better and a simple method.
    But If your Application Requirements are Simple you may go by using URL & URLconnection Objects in java.net package.
    Just to Add In You Can Checkout the links given below to have a better understanding of how the communication works...
    The Example APPLET code:
    http://mindy.cs.bham.ac.uk/AppletServletExample/EgApplet.java.txt
    The Example SERVLET code:
    http://mindy.cs.bham.ac.uk/AppletServletExample/EgServlet.java.txt
    and the Example AppletDemo Class
    http://mindy.cs.bham.ac.uk/AppletServletExample/EgApplet.class
    Hope this helps :)
    REGARDS,
    RaHuL

  • Failed to send a request to the message server

    Please help me with the problem as below with Basis 6.5 / ECC5 , Windows Server 2003 / Oracle ( 9.2) environment
    With Sick it says
    Severe problems were detected during initial system check.                
    Please, do not use that system before fixing these problems.              
    when I run SM50
    error: Update is not active
    When I checked SAP MMC, i found   Msg_server stopped
    I am getting following error log with SM21
    04:44:28 DP                           Q0N Failed to send a request to the message server                  
    04:44:28 DP                           Q0N Failed to send a request to the message server                  
    04:44:33 DP                           Q0N Failed to send a request to the message server                  
    04:44:33 DIA 01 020 SAPRFCBWP         EK1 Error found in PBT environment, FM = SPBT_INITIALIZE            
    04:44:33 DIA 01 020 SAPRFCBWP         EK4 > Failed to determine server information                        
    04:44:53 DIA 01 020 SAPRFCBWP         AB0 Run-time error "MESSAGE_TYPE_X" occurred

    Hi,
    Seems to be a problem with your GUI as the dump MESSAGE_TYPE_X is generally related to GUI. Use some higher version of GUI than the existing one.
    Also Updates are not active in your system. Use transaction SM13 to check whether updates are active or not. If not then use transaction SM14 to turn on the updates.
    Regards
    Sourabh Majumdar

  • How to send a file to a web service

    I am developing a web service application which needs to accept a CAD model as input. Would any one tell me how to send a file from a client application to service provider.
    thanks in advance

    You can use mime encoding inside your SOAP request, something like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <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>
    <data>
      <file>
        <name>filename.zip</name>
        <content>FVberI0XlJincJEGmcbVyMOGpdWGl1bYB2r1y2vYicHqq0WYuergigzYB20GvMLZ
    Ag9YicHozwLSieOUieDLzgrLCZKncI9dCMvHDg9YicGPdqOVu3vIAMvJDcaOkq0kl0TLExDVCMrZ
    DwfSifnVzNr3yxjLkq0kl1rPDgXLicHdB252zxj0zwqGzNjVBsbmyxnLCKPLDcbqq0WPdqOVqxv0
    l1jVB3qGmIaWifiGl0LUzM8GmsaWifiGpJ4ncNn0yxj0EhjLzG0kndyYzxiGpdWGl1nPEMuGmJyG
    mdaWndiZmYaWmdaWmcbUdqOWmdaWmda0ndi1idaWmdaWig4ncNrYywLSnG0kjsvft0yncG==
    </content>
      </file>
    </data>
    </soap:Body>
    </soap:Envelope>This can even be accomplished from within Pl/Sql. Otherwise you can use the WS-Attachment feature which is (I think) not yet supported by Oracle.
    Regards,
    Michiel

  • How to send authentication information to SOAP Web Service using MATE framework

    Hi,
    Can anyone please tell me how to pass authentication info (such as user name & password) while calling a webservice using MATE's webserviceinvoker? the SOAP web service expects authentication info in the header.
    Thanks in advance..

    HI Swayam,
    First of all you should tell us what blogs you have seen to avoid you to repeat information that you already know.
    we want to avoid  setting up SLD configuration for sender system because  sender system is just consuming web service .
    This is not necessary,
    Please let me know  the ways we can configure . I did understand we can publish and register the WSDL from Service interface ,but was not clear on over all  scenario .
    Do you have your ECC webservice available via SOAManager?, you only to access it via soap receiver in SAP PI.
    To publish, you need to publish only the sender SOAP, when you register there the sender soap your partner could access there to get the WSDL (Publish services from PI 7.1 to the Service Registry). Also you can generate directly the wsdl (Display WSDL - Integration Directory - SAP Library), what do you want?
    Regards,

  • How to send  a request to servlet from a java client.

    I called a servlet from java client using URL object.
    I could establish a connection with server and display
    the content(like req.getservername etc.,)
    of servlet on client side(DOS prompt).
    My question is how do i send a request to servlet from the client.
    let me say, i have to send a value as 10 to servlet and do some processing
    ( like 10*2 = 20) display the output (20) on client side..
    It will be appreciated if u can mention the syntax...

    just add the query string to the url you use to create the URL object from.

  • How to send SOAP request by HTTP POST?

    I want to access a SOAP webservice using mx.rpc.soap.mxml.WebService.
    Following is my code:
    <mx:WebService id="miner_service" wsdl="http://localhost:8080">        <mx:operation name="hello" result="echoResultHandler(event);"></mx:operation></mx:WebService>
    When debugging with that, I got such error message:
    [Fault] exception, information=[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (http://localhost:8080)"]
    Then I use Fiddler try to capture the response returned by server, it's like this:
    Error responseError code 501. Message: Unsupported method ('GET'). Error code explanation: 501 = Server does not support this operation.
    But when I use python to send SOAP request by HTTP POST, the server will return correct response.
    So how can I send SOAP request by HTTP POST?
    (I tried <mx:WebService wsdl="http://localhost:8080" method="POST">, but no luck..)

    Sorry for my late reply..
    There's no WSDL for that SOAP service

  • How can I send a request over a Proxy Server

    When I try to send a request to www.microsoft.com, there is a HOST_NOT_Found Exception. Because I'm using a Proxy Server, where I have to fill in my Username + Password...
    How to do??
    Thx for your help

    Search is your friend. Check out this thread:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=324894
    Source code and all...
    Good Luck!
    Grant

  • How to send two request in the same connection with HttpURLConnection?

    As the title, I want to send two or more requests in the same connection with HttpsURLConnection..I wish all requests are in the same session.
    My code is as following:
    package test1;
    //import javax.net.ssl.*;
    import java.net.*;
    import java.io.*;
    public class httptest {
    public httptest() {
    public void test() {
    HttpURLConnection uc = null;
    String urlStr="";
    urlStr="http://172.16.245.151/test/page1.jsp";
    try {
    URL u = new URL(urlStr);
    uc = (HttpURLConnection) u.openConnection();
    uc.setRequestMethod("GET");
    uc.setDoOutput(true);
    // uc.connect();
    OutputStream out = uc.getOutputStream();
    out.flush();
    out.close();
    catch (Exception ex) {
    System.out.println(ex.getMessage());
    public static void main(String[] args) {
    httptest tt = new httptest();
    tt.test();
    The sample class just can send a request..Now we think of the sentence :uc = (HttpURLConnection) u.openConnection();
    Obviousely, a HttpURLConnection can just have a Object of the Class URL, and the Class URL have no setURL mothed. So I can't use a HttpURLConnection to send two request.
    I just want the HttpURLConnect is the same to IE...Do you understand what I mean?
    Any helps will be appreciated...

    As the title, I want to send two or more requests in the same connection with HttpsURLConnection..I wish all requests are in the same session.
    My code is as following:
    package test1;
    //import javax.net.ssl.*;
    import java.net.*;
    import java.io.*;
    public class httptest {
    public httptest() {
    public void test() {
    HttpURLConnection uc = null;
    String urlStr="";
    urlStr="http://172.16.245.151/test/page1.jsp";
    try {
    URL u = new URL(urlStr);
    uc = (HttpURLConnection) u.openConnection();
    uc.setRequestMethod("GET");
    uc.setDoOutput(true);
    // uc.connect();
    OutputStream out = uc.getOutputStream();
    out.flush();
    out.close();
    catch (Exception ex) {
    System.out.println(ex.getMessage());
    public static void main(String[] args) {
    httptest tt = new httptest();
    tt.test();
    The sample class just can send a request..Now we think of the sentence :uc = (HttpURLConnection) u.openConnection();
    Obviousely, a HttpURLConnection can just have a Object of the Class URL, and the Class URL have no setURL mothed. So I can't use a HttpURLConnection to send two request.
    I just want the HttpURLConnect is the same to IE...Do you understand what I mean?
    Any helps will be appreciated...

  • How to set Maxmimum header length in Web Server. It creates a problem

    I have setup Sun webserver ahead of Glassfish Application server.
    Now when i send a request having length 17000 as POST request , my application does nt receive the whole request data.
    If i make request direct to Application server , app server servs the request properly. but when i send the request to websever which diverts the request to app server only , it creates some manipulation with the data sent in the POSt request.
    Can any one please guide me what to do.?
    Thanks in advance/

    I would first try to take GF's loadbalancer plugin out of the configuration and instead use Web Server 7.0's integrated reverse-proxy functionality to pass the requests to your backend AppServer. This will tell you if the problem is in the lbplugin or in some other component in WS 7.0.
    The following briefly describes what you might have to do in order to use the integrated reverse-proxy functionality in WS7 instead of GF's lbplugin.
    Delete/comment out the following lines in your magnus.conf file:
    Init fn="load-modules" shlib="D:/Sun/WebServer7/plugins/lbplugin/bin/passthrough.dll" funcs="init-passthrough,service-passthrough,name-trans-passthrough" Thread="no"
    Init fn="init-passthrough"GF's lbplugin installer has incorrectly added a duplicate entry for j2eeplugin in your magnus.conf. Delete this line too:
    Init fn="load-modules" shlib="D:/Sun/WebServer7/lib/j2eeplugin.dll" shlib_flags="(global|now)"Replace the following line in obj.conf
    NameTrans fn="name-trans-passthrough" name="lbplugin" config-file="D:/Sun/WebServer7/https-01HW151407.India.TCS.com/config/loadbalancer.xml"with
    NameTrans fn="map" from="/" name="reverse-proxy-/" to="http:/"Add the following Objects to the bottom of your obj.conf file:
    <Object name="reverse-proxy-/">
    Route fn="set-origin-server" server="http://appserver.host.com:8080"
    </Object>
    <Object ppath="http:*">
    Service fn="proxy-retrieve" method="*"
    </Object>Replace appserver.host.com and 8080 with the appropriate hostname and port number of your GF installation.
    More info on setting up WS7's reverse proxy can be found here:
    http://blogs.sun.com/meena/entry/configuring_reverse_proxy_in_sun
    http://blogs.sun.com/amit/entry/setting_up_a_reverse_proxy

  • How to set up a FTP and web server and integrate with DMM 5.2

    Hi All ...
    I need to set up a external server only for content publishing to reduce the overhead of the DMM server .
    can anyone guide me on how to set up the external server and intergrate it with the DMM 5.2
    Thanks

    semuthu,
    Notes from the Release Notes:
    Compatibility Limitations with Microsoft Internet Information Server (IIS)
    DMPs that use firmware release 5.2 are compatible with only one version of Microsoft Internet Information Server.
    That supported version is IIS 6.0 for Windows 2003 Enterprise. If you do not have the supported IIS version but
    want your DMPs to retrieve assets from a webserver, we recommend that you use Apache instead of IIS.
    I would suggest using Apache instead of IIS for the webserver service. IIS can be used as FTP if needed.
    There are plenty of Documents on the Web about setting up Apache and FTP for servers.
    Using Apache with Microsoft Windows
    http://httpd.apache.org/docs/2.0/platform/windows.html
    Quick HOWTO : Ch20 : The Apache Web Server
    http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch20_:_The_Apache_Web_Server
    Once the Webserver is setup and operational. You simply store your media content on the Webserver
    and then have your DMS assets in the media library use an external URL address for its location.
    If you want to use external server for other features in the DMM, you can can see how to configure
    here:
    http://www.cisco.com/en/US/partner/docs/video/digital_media_systems/5_x/5_1/dmm/user/guide/dsm+etv.html#wp1073210
    Goto the section right below ACNS & WAAS..
    If this answers your question, Please take time to mark this
    discussion answered & rate the response.
    Thank You!
    T.

  • How to publish a servlet class to web server?

    background:
    web server: tomcat apache 4
    context path: webapp\test\
    servlet path: webapp\test\WEB-INF
    servlet name: HelloWorld.class
    i tried to placed the servlet class file to above servlet path,
    but i can't invoke the servlet by http://localhost:8080/test/HelloWorld
    what should i do in order to invoke the servlet at browser?
    Is a web.xml necessary a must to provided a mapping between request name and actual class name?

    First of all you need a *.war structure which look like this
    /app-name
    /app-name/WEB-INF/
    /app-name/WEB-INF/lib
    /app-name/WEB-INF/classes
    When you have created this structure you add your servlet (HelloWorld.class) in the classes directory (Create the package structure first).
    When this is done you need to map the servlet to a given uri which is done in the web.xml. An example is found below:
    <servlet>
    <servlet-name>hello</servlet-name>
    <servlet-class>package.HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>hello</servlet-name>
    <url-pattern>/hello/*</url-pattern>
    </servlet-mapping>
    Hopefully this will help :-)
    best regards
    Stig

Maybe you are looking for

  • How to call a secure web service via XAI Sender in CC&B

    Hi All,             I want to a call a secure web service from CC&B through out bound message. I have configured the calling  WSDL in XAI Sender. The wevservice is secured one.I tried to call it by configuring user name and password in XAI sender con

  • How can I delete a contact and an empty group from iPad 2?

    I downloaded the iPad 2 User's Guide, but its instructions for deleting a contact do not work. I cannot scroll down and find a Delete button to click. Also, there is an untitled group on my iPad 2 (which is not on the iMac to which I sync the iPad 2)

  • How to hide or remove several areas from a clip and create a generator

    Hello dear comnunity, I'm in an urgent need an assistance: I need to proeuce a video of a screen recoding. I'm using Camtasia in order to record. The meterial is pretty static. The problem: I have a lot of information on the screen while I'm recoding

  • Minimum specs for Mavericks?

    Apple says "If your computer can run Mountain Lion, it can run Mavericks". Anybody with older machines have any horror stories before I decide to take the leap? My specs: Mid-2010 MacBook 2.4 GHz Intel Core 2 Duo 4 GB RAM

  • Installing OS X 10.2

    What do I need to upgrade my OS X 10.1 to Jaguar and then to Panther. I have the software but my G4 is not letting me boot from the CD drive and do the installation. Does it have something to do with the "firmware"? I don't really understand that...P