Java library to send a payload over HTTP

Hi All,
I want to create a stand alone Java application which should be able to send a payload(XML doc) over HTTP to a server (an Integration Server). Are there any APIs which can create this HTTP request given a payload and send it to a specified URL over the network.
This doesn't need to be a SOAP message, just an HTTP request with a payload. And this should be asynchronous too, ie no response is required from the server. Can this be specified in the QoS?
Any thoughts?
Thanks,
Sandeep

Hi, your idea seems to be interesting. I guess you have a web site, and you want to feed the Http request to a specific URI under the web site. This is nothing new, since WSDL supports HTTP Binding, you can use HTTP Binding to send your HTTP requests to the web site. As to the java library, I thinks JAXWS can do the job. you may turn to WSDL specification for further details about HTTP Binding. I didn't write something like this, but I think it is practical. And if you work it out, it would be very kind of you to tell me how you do it in details by sending me an email: [email protected]
Best Regards:)
@smile@

Similar Messages

  • Need help : how to send 3 parameters over http using Java POST

    I am trying to sending some data to agency company over http using Java POST
    They need 3 parameters and some contents like below
    1. Cmd : cmd=_RequestInsertNewLead
    2 Live : False
    3 XMLData : 3C%3Fxml+version%3D%........
    I already have XML done ,but I don't know how to send these guy over http
    is that like
    this.out = new DataOutputStream(os);
    out.writeBytes("Cmd");
    out.writeBytes(" cmd=_RequestInsertNewLead");
    out.writeBytes(" Live ");
    out.writeBytes("False");
    anyone could give help :)

    First of all, are you getting any exception?
    You didn't put much logging information in your code.
    You can also try this.Instead of doing sos.println(".....") try to build the output string using string buffer.
    Like:
    StringBuffer sb = new StringBuffer();
    sb.append("Some output");
    sb.append("More output");
    sos.print(sb.toString());
    sos.flush();Let me know if this works.

  • Sending audio data over http problem

    Hi Guys,
    We are trying to create a little servlet in Tomcat, which is capable to send audio files over http to an embedded media player. The definition of the player looks like:
    <OBJECT ID="Mp" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" TYPE="application/x-oleobject" WIDTH="0" HEIGHT="0">
    <PARAM name="uiMode" value="none">
    <PARAM NAME="ShowControls" VALUE="0">
    <PARAM NAME="AutoStart" VALUE="1">
    <PARAM NAME="ShowPositionControls" VALUE="0">
    <PARAM NAME="ShowStatusBar" VALUE="0">
    <PARAM NAME="ShowDisplay" VALUE="0">
    </OBJECT>
    <script language="javascript">document.Mp.URL = "here comes the url of the servlet with item ID";</script>
    The servlet reads the audio file and writes its content to the response with the following http header settings:
    getResponse().setContentType("audio/x-wav");
    getResponse().setHeader("Content-Transfer-Encoding", "binary");
    getResponse().setHeader("Pragma", "Public");
    getResponse().setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
    getResponse().setHeader("Content-Disposition", "inline; filename=Media.wav");
    getResponse().setHeader("Content-Length", new Integer(MediaBytes.length).toString());
    getResponse().setHeader("Accept-Ranges", "bytes");
    So, everything works fine for wav files in Internet Explorer, but we are facing problems with Firefox, where it does not work. The embedded Media Player says that "Windows Media Player cannot play the file. One or more codecs required to play the file could not be found."
    But if we set the url to directly to the file on the server, everything works fine.
    We have analyzed the HTTP traffic in both situation, but we cannot understand how Internet Explorer/Firefox and Media Player works together:
    - how does Media Player know that the audio file is playable?
    - if the url points directly to the file, the HTTP headers does not contain any kind of information about the file type, only the extension is available; Media Player checks the file extenion in the url?
    - if the url points to the servlet, why Media Player in Firefox cannot determine the file type and throws error?
    Any help is greately appreciated!
    Thanks!
    Gabor

    If you haven't already, I would try breaking down the problem. First confirm you're getting serial data then confirm that netcat can send some data. Like this:
    xxd < /dev/tty.usbmodemfa121 | less
    nc -u 10.0.1.3 7000 <<< 'hello over there'

  • PrintWriter does not send correct text over HTTP

    Hello All,
    I need information to resolve a problem I am having with PrintWriter and sending text using HTTP.
    I am developing a client/server system. A client will be used to connect to a Tini (a Dallas Semiconductor designed embedded system). Currently, to understand HTTP operation, I wrote a server that resides on the tini that listens for a connection attempt and when one is made prints the HTTP message in Dallas' JavaKit application window. The resultant Tini display includes some hardcoded tini text (italics only in (b) and (c) below) along with that received from the client app (italic bold in (b) and (c) below).
    I have also written some test client side code (see (a) below) in Sun's Java Studio Creator that sends a couple of lines of text so that I could see what my client app would actually send. I tried a few different ways of creating a PrintWriter object as shown in the code at (a) below just to see if it was a character set problem.
    The problem is that I get two different results under the following conditions:
    [Condition 1]: Entering "HTTP://tini" in the browser and pressing Enter. See result (b) below. This is correct and shows what the browser sends to the tini. The tini outputs the text immediately after pressing Enter.
    [Condition 2]: Running my client code in the browser. See result (c) below. This is incorrect and sends just a bunch of "y"s with umlauts as the message. The tini immediately outputs text up to the "cnt=0" line and then can take up to a couple of minutes to complete the message.
    1. Can anyone tell me why the client sends those "�" instead of the strings I encoded for all character sets?
    2. Why does the client code takes so long to complete after the initial transmission?
    3. Can anyone provide me with links to information that explains this behavior? I searched Sun and the forum but found nothing.
    (a) Here is the current test client side code that sends a couple of strings to the tini:
        public String button3_action() {
            // TODO This should send the tini a request for its IP address
            String protocol = "HTTP";
            String host = "tini";
            try{
                 URL tiniURL = new URL("http://tini");
                 URLConnection tiniConnection = tiniURL.openConnection();
                 tiniConnection.setDoOutput(true);
         //     Comment out one then the other to see if there is a difference in result (there is not!)
         //        PrintWriter tiniout =  new PrintWriter(new OutputStreamWriter(tiniConnection.getOutputStream(), "UTF-16"));
         //        PrintWriter tiniout =  new PrintWriter(new OutputStreamWriter(tiniConnection.getOutputStream(), "UTF-8"));
         //        PrintWriter tiniout =  new PrintWriter(new OutputStreamWriter(tiniConnection.getOutputStream(), "ISO-8859-1"));
         //        PrintWriter tiniout =  new PrintWriter(tiniConnection.getOutputStream());
                 PrintWriter tiniout =  new PrintWriter(new OutputStreamWriter(tiniConnection.getOutputStream()));
                 tiniout.println("GET / HTTP / 1.1\r\n");
                 tiniout.flush();
                 tiniout.println("IPaddress?");
                 tiniout.flush();
                 tiniout.close();
            catch(MalformedURLException e){
                e.printStackTrace();
            catch(IOException e){
                e.printStackTrace();
            return null;
    (b) Result displayed in JavaKit from Condition 1:
    just starting
    Waiting for a connection attempt
    Start thread
    Thread's run() method entered!
    Try to create a new StringBuffer
    StringBuffer created
    Read the buffer in this loop cnt =0
    Read the buffer in this loop cnt =1
    Read the buffer in this loop cnt =394
    Read the buffer in this loop cnt =395
    Out of loop.
    Now print HTTP message.
    GET / HTTP/1.1
    Host: tini
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8 ,image/png,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    "v"is at position390
    "e"is at position391
    "is at position392
    ""is at position393 "
    "is at position394
    java.lang.StringIndexOutOfBoundsException: String index out of range: 395
    No other stack trace info available.
    (c) Result displayed in JavaKit from Condition 2:
    just starting
    Waiting for a connection attempt
    Start thread
    Thread's run() method entered!
    Try to create a new StringBuffer
    StringBuffer created
    Read the buffer in this loop cnt =0
    Read the buffer in this loop cnt =1
    Out of loop.
    Now print HTTP message.
    ���������������������������������������������������������������������������� �������������������������������������������������������������������������������� �������������������������������������������������������������������������������� �������������������������������������������������������������������������������� �������������������������������������������������������������������������������
    "�"is at position390
    "�"is at position391
    "�"is at position392
    "�"is at position393
    "�"is at position394
    java.lang.StringIndexOutOfBoundsException: String index out of range: 395
    No other stack trace info available

    This is to anyone that is having trouble sending data via a stream using a browser client. I found the answer after many different searches on the Sun site in a bug report: Bug ID: 4192018.
    The problem arises from the way the API actually uses outputstreams. It appears that you must add an InputStreamReader to actually flush the OutputStreamWriter buffer. After reading this bug report I added
    (tiniConnection.getOutputStream(), "ISO-8859-1"));
            OutputStreamWriter tiniout =  new OutputStreamWriter(tiniConnection.getOutputStream(), "ISO-8859-1");
            InputStreamReader tiniIn =  new InputStreamReader(tiniConnection.getInputStream(), "ISO-8859-1");
            tiniout.write("GET/HTTP/1.1\r\n");
            tiniout.flush();
            //This is necessary to actually send data.
            tiniIn.read();
            tiniout.write("IPaddress?");
            tiniout.flush();
            //This is necessary to actually send data.
            tiniIn.read();
            tiniout.close();
            catch (MalformedURLException e){
                e.printStackTrace();
            catch (IOException e){
                e.printStackTrace();
            }NOTE: The preliminary program still does not perform correctly but it does send data that is displayed in tini's JavaKit window. At least I can continue to verify how the browser sends data.
    I hope this helps someone.

  • Sending XML documents over HTTP

    Hello,
    I have read a number of similar questions, but they were all posted last year.
    I don't know if a solution was found...
    Here is my problem:
    I have an ASP page using the object XMLHTTP that sends an XML document to another application server using HTTPS, and gets an immediate response.
    Is there an equivalent in the Java world to this feature? I need to transcript my ASP page to JSP.
    I have seen things like HttpServlet, JAXM, SOAPConnection.... But I don't know what that means...
    Thanks for you help.
    Caillou_QC

    URL url = new URL("http://java.sun.com/etc/etc");
         URLConnection connection = url.openConnection();
         connection.setDoOutput(true);
         PrintWriter out = new PrintWriter(
    connection.getOutputStream());
         out.println("string to send");
         out.close();
         BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        connection.getInputStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null)
         System.out.println(inputLine);
         in.close();

  • Send xml file over https - urgent

    Helo everybody.
    I need to solve next problem:
    1. Build/Use a client program that can operate with the HTTPS protocol. There are no restrictions on the type of client program used, providing it can use this protocol and deal with transactions synchronously.
    2. Build/Use a program that can build a valid request XML document and attach it via a POST parameter to a HTTPS request.
    POST /<URL_TO_SUBMISSION_SITE> HTTP/1.0
    Example
    User-Agent: HTTPTool/1.0
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 9999999
    <XML_DOCUMENT> &#1048773;Post Payload
    or
    POST /<URL_TO_SUBMISSION_SITE> HTTP/1.0
    User-Agent: HTTPTool/1.0
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 9999999
    xml=<XML_DOCUMENT>
    3. Ensure the program can retrieve the HTTPS response and parse the returned XML payload.
    4. Ensure the program can correctly interpret the inquiry response information within the XML return.
    Please help me in point 2. I don't know how to attach xml document to https request.
    I'm trying something like this :
    System.setProperty("java.protocol.handler.pkgs",
         "com.sun.net.ssl.internal.www.protocol");
         try {
    url = new URL("https://" + path);
    } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    URLConnection con = null;
    try {
    con = url.openConnection();
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setAllowUserInteraction(true);
    con.setRequestProperty("Content-type", "application/x-www-form-urlencoded;charset=Cp1250");
    con.setRequestProperty("Content-Length","9999999");
    } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    but without success. Please help

    Just saw a link, may be this will help you : http://resellers.tucows.com/documentation/xmlhttpspost.pdf

  • Error using Sender SOAP adapter over HTTPS

    Hi experts,
    Few weeks ago, i developed an interface as follows: SOAP <-> XI <-> RFC.
    I tested the functionality using Altova and everything went well, with HTTP.
    However, when i use HTTPS it fails throwing these error messages (pop ups):
    <i>"HTTP error: could not post file"......
    "Error sending the soap data"</i>
    I have reviewed the SSL certificates installation and everything seems to be ok, but currently i am stuck and do not know how to fix this.
    I have also change the ID comm channel from HTTP to HTTPS with client aut.
    Is there any special service i have to activate? (XI services and SPIGATE are already done)
    Could you please assist?
    Thanks in advance and best regards,
    David

    David,
    have a look @ these threads...u may get some help!!!
    Sender Soap with HTTPS
    https Soap Adapter
    Regards
    Biplab

  • Acknowledgement sent over http on 'secure' channel

    Hi,
    I have configured a 'secure' eMS 2.0 channel with a https url of my partner: https://partner/eindpunt
    When I use this channel for outbound messages it works ok, the message is sent over https.
    When I use this channel for inbound messages it sends an ack over http, so http://partner/eindpunt
    I suspect this is because we use a proxy that does SSL handling, it receives messages over https and sends these over http to B2B.
    Well, we tested without the proxy, so inbound messages arrive over https directly to B2B, same result: ack is sent over http...
    Is there a switch to turn on https for the ack?
    I use SOA Suite 11.1.1.4.0
    Groeten,
    HJH
    Edited by: HJHorst on Apr 15, 2011 4:02 AM

    When you create an inbound ebMS agreement, you have to create a ebMS channel under Remote Trading Partner configuration and select that channel while creating the agreement (in Remote TP channel drop-down list). This channel will be used to post the acknowledgement back to trading partner. You may specify HTTP/HTTPS URL, whatever you want, in that channels configuration.
    Regards,
    Anuj

  • Post XML over HTTPS

    We are trying to do the following. Can anyone help by providing any pointers as how to do it.
    1. A java client will be posting XML over http(s) to the Tomcat server.
    2. The Tomcat server has to do the following:
    - Validate the user credentails and verify that it is an valid user on IDM
    - Do some DB operations and return back a response XML
    We are trying to do this by having the Java client post XML over http to a jsp hosted on the Tomcat server
    How do i retrieve the XML data from the HTTP post (from the HTTP body) ?
    Thanks

    try the below example to read data over https,
    import java.net.*;
    import java.io.*;
    import javax.net.ssl.*;
    public class SSLSocketClient {
    public static void main(String[] args) throws Exception {
         String url="https://secure.com";
              try {
                   SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
                SSLSocket socket = (SSLSocket)factory.createSocket(url, 443);
                socket.startHandshake();
                /* read response */
                BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                String inputLine;
                while ((inputLine = in.readLine()) != null)
                    System.out.println(inputLine);
                in.close();
                socket.close();
            } catch (Exception e) {
                e.printStackTrace();
    }

  • Server to Rich Client sending XML over Http

    I need to send XML data from a Servlet to a rich client over http.
    Currently I am using HttpURLConnection and SaxTransformerFactory to do this.
    Is it better to use SOAP or XML-RPC in this scenario?
    Are there any good online tutorials comparing SOAP, XML-RPC and AXP-Java Net API?
    What are the factors that I need to consider for choosing between these alternatives?
    Please advice. Thanks in advance.

    XML-RPC and SOAP use XML as a way to communicate, but they are used to invoke certain function calls in an application independend manner, not to be used to send XML data. So I'd say it depends on:
    a) what do you do with the XML data?
    b) will you be expanding the application?
    c) how difficult is it to rework the current implementation?

  • Accessing Java webservice (XML over http) via WCF or HTTP adapter with content-type and authorization HTTP headers with POST method

    Hi Team,
    I need to access Java web service which is simple service and accepts and returns XML over HTTP. No credentials are needed to access the service. We need to pass following two HTTP headers (Content-Type and Authorization) along with XML request message:
    <GetStatus> message is being constructed in the orchestration and URI is constant to access.
    Which adapter shall I use to get the response back? I tried using WCF-WSHttp with Security Mode = Transport, and different options of client credential types but every time, error returned stating:
    System.Net.WebException:
    The HTTP request is unauthorized with client authentication scheme 'Basic'. The
    authentication header received from the server was 'Basic realm='.
    Authentication failed for principal Basic. Message payload is of type:
    String 
    In Fiddler, request looks line following
    POST <https://URL/GetServiceReopnse HTTP/1.1
    Content-Type: application/xml
    Authorization: Basic cmVmU3RhdHN2Y19kgeRfsdfs=
    Host: <Server name>
    <GetStatus XMLNS="http://server.com/.....">
    <OrgId>232323</OrgId>
    <HubId>3232342323</HubId>
    </GetStatus>
    MMK-007

    First, you should not use the HTTP Adapter because it's been deprecated and replaced by WCF.
    Start with the WCF-Custom Adapter and select the customBinding.
    You should start with the textMessageEncoder and httpTransport and go from there.

  • Updating payload with the remote java library

    Hello,
    Please Help.
    Does someone know how to update the payload using the remote java library?
    I tried this way...
    code:
    IWorklistContext ctx = client.authenticateUser(user, password);
    Task t = client.acquireTask(ctx,taskId);
    t.setPayload(payload);
    client.updateTask(ctx,t);
    client.customTaskOperation(ctx, taskId, action);
    Thanx

    Hi Veronica,
    we've encountered the same problem. It is possible to update the payload, but the data doesn't come back (when using the remote lib). We've created a TAR for this, but so far there's no solution yet. But, we did manage to create a workaround for it. It's not the cleanest solution, but for now it works.
    What we do is, we create an XSD for the payload, and send it along with the usertask as usual. Only, our JSP saves the document in the Comments field. In the BPEL we can then extract the document using ora:parseEscapedXML to transform it from comments to our own userpayload.
    Hth,
    Mike van Alst

  • AS2 over HTTP Send port question.

    I have an application that builds and  sends flat and EDI files to FTP, FILE, SqlAdapter send ports and now they want AS2 over an HTTP port, I understand the AS2 settings (using party resolution, etc.) what I don't get is how/what exactly is receiving
    the message on the other side... They don't have a web service nor a page, I created a site to test but what do I do? Send an edi file to a url????
    Bico Bielich

    From your question I understand, you have been asked to send message through AS2. Do they also going to receive message through AS2 from their party? Is your question is about how to receive the message through AS2 which you also want to send over AS2?
    You can configure
    BTSHTTPReceive.dll to receive messages over HTTP and configure the Receive location with AS2 EDI pipeline component to receive messages over AS2 into BizTalk which can be subscribed by your send port filter or Orchestration ( if you have any process
    to be applied before sending the message over AS2 send).
    Check the Tutorial-3 part of AS2 which illustrate an example which receives an AS2 message through BTSHTTPReceive.dll. 
    Tutorial 3: AS2 Tutorial
    And following references shall help you configure the BTSHTTPReceive.dll:
    How to Configure IIS for an HTTP Receive Location
    Configuring BTSHTTPReceive.dll to work on IIS 7 
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Webdynpro ABAP called from IView JAVA works over http but doesn't over http

    Hello gurus, like I said in the subject, we have integrated inside our JAVA portal a WebDynpro ABAP and it's working good over http protocol (http://<servername>:<http_port>/irj/portal), but when you browse the portal over https protocol (https://<servername>:<https_port>/irj/portal), everything works fine exept the WebDynpro ABAP, is like if the javascript components didn't be loaded completly, because the buttons doesn't make anything, and only half of the table that is supossed to be loaded is showed.
    Do you know what kind of configuration I'm missing?
    Thanks and best regards

    You have to note here that for webdynpro ABAP applications, the http/https request is actually served by the backend server.
    So, while accessing your webdynpro ABAP application, the request will be like:
    https://<mybackendserver>:<backendport>/bc/sap/.....
    While creating a system object in your portal (System landscape), you will need to adjust the protocol to https and also set the appropriate https port of the backend server. Also, HTTPS/SSL communication should be enabled on your backend server.
    Please check the definition of your system object.
    You can find more information by turning on a HTTP trace and checking how the request is routed to the backend server upon accessing the WD4A application.
    Thanks,
    Shanti

  • Securing Parameters send over Http (Reports 9i)

    What the proposed solution to secure parameters send over http.
    Let's take the example of a report which take a user parameter called 'secret_id'; I'd like to send over http a request dynamically construct from a servlet (or a jsp) which should look like:
    http://myserver:8888/reports/rwservlet?report=test.jsp+destype=cache+server=r90srv+desformat=pdf+secret_id=25568+userid=too/foo@pdde
    And of course I'd like to send userid and secret_id in a secure way.
    Is using SSL enough ?
    Is there some encryption mechanism available (think there was some thing in reports 3) ?
    Can we use hidden parameters ? And how would it be done ?
    Many thanks for any Hint / idea / recommendation.

    Well... got the same question ?
    Needs a solution for making a servlet, with hidden parameters and session identifiers to build the query string - how is this possible ???
    Anyone knows ? - it would be a big help.
    PS: seen the TextPDS, but neds an example with database connection.

Maybe you are looking for