Sending xml over http

I have a WLS 6.0 servlet that receives XML transactions via a post method.
          Code snippet as follows:
          public void doPost(HttpServletRequest req, HttpServletResponse res)
          throws ServletException, IOException
          int txContentLength = req.getContentLength();
          //get entire input xml stream and store in a stringbuffer
          InputStream inp = req.getInputStream();
          BufferedReader br = new BufferedReader(new InputStreamReader(inp));
          byte[] ba = new byte[txContentLength];
          System.out.println("Reading...");
          int bytesRead = inp.read(ba);
          System.out.println("bytesRead= " + bytesRead);
          while(bytesRead < txContentLength) {
          int moreRead = inp.read(ba, bytesRead, (ba.length - bytesRead));
          if(moreRead == -1)
          break;
          bytesRead += moreRead;
          System.out.println("finished reading buffer...");
          StringBuffer sb = new StringBuffer(new String(ba));
          I have a java client on my PC that takes an XML file as input and sends the
          information to the servlet without any problems.
          The problem is a client that is connecting to our network via a T1
          connection. When they send transactions, about 1 out of every 4
          transactions makes it past the "Reading..." statement above. The other
          transactions appear to 'hang' when it hits the inp.read(ba) line above.
          From all indications, that servlet's execute thread appears 'hung' as if the
          inp.read() is waiting forever.
          I've tried using readLine() on the InputStream() and my local client program
          is unaffected - it works OK. The remote client is having problems using
          either method. The only difference I've noted with the remote client is
          that they are using HTTP 1.0 and I'm using HTTP 1.1. Initially, their
          mime-type was null but they've changed it to text/xml and no luck. I've
          even sent them my client code that is working and they are still having
          problems...
          Another strange anomoly is that req.getContentLength() is returning a valid
          number on the transactions that fail. For example, I had some debug code
          that showed the content length and it was always something like 4012 or
          3500, etc. Not -1 as I would expect...
          Has anyone run into this problem with receiving XML transactions?
          Thanks
          Rob Mason
          

Thanks for the suggestion - I went back and added a check on the
          contentLength to make sure it had a valid number before trying to call any
          'read' methods... still no luck.
          I did go in and put a try/catch around the read() logic below. The
          exception thrown is an InterruptedIOException. The docs say that this is
          thrown 'to indicate that an input or output transfer has been terminated
          because the thread performing it was terminated.'
          This would seem to indicate that WLS is having the problem - not the client?
          Via the console, under the Configuration section, my HTTP section has the
          following values:
          POST timeout secs: 10
          Max POST time: 10
          Max POST size: -1
          Is there anything else I can try on the server level?
          Thanks
          Rob Mason
          "Xiang Rao" <[email protected]> wrote in message
          news:[email protected]...
          >
          > T1 shouldn't be the problem. We even use dialup to upload file via HTTP
          POST. HTTP
          > 1.0 shouldn't be problem. If you think this is the only difference, you
          can ask
          > other developers to change it to HTTP 1.1 when they request your servlet.
          >
          > The hang at read(ba) most likely means no request data are sent to your
          servlet
          > even if you think there should be some data. In your code, you are better
          to add
          > a block to check if the content_length is GREATER THAN 0 (-1 or 0), if
          not, you
          > shouldn't open any inputstream and shouldn't call any read method. If the
          content_length
          > is 0, your character buffer will have length 0 and I really don't know
          what you
          > can put into such buffer. It is not necessary to set a buffer with the
          length
          > of expected Content_Length. Since you use BufferedReader, you can create a
          buffere
          > with large enough size (see 1K, 8K, 16K, etc)and the return value of read
          will
          > give you the exact length you get for each read call, then append result
          to your
          > Stringbuffer. On the other hand, it is better for you to handle
          IOException in
          > your servlet.
          >
          > Ask the other side developers to send you their client code and compare
          their
          > code with your test code word by word. Check how they compute the
          Content_Length
          > and how they send Content_Length field to you. If this field is not
          explicitly
          > set, I think you should get -1 or 0, even there are request data out. Also
          you
          > should check how the data are sent out to make sure they really send you
          request
          > data.
          >
          >
          >
          >
          > "Rob Mason" <[email protected]> wrote:
          > >I have a WLS 6.0 servlet that receives XML transactions via a post
          method.
          > >Code snippet as follows:
          > >
          > > public void doPost(HttpServletRequest req, HttpServletResponse res)
          > > throws ServletException, IOException
          > > {
          > > int txContentLength = req.getContentLength();
          > >
          > > //get entire input xml stream and store in a stringbuffer
          > > InputStream inp = req.getInputStream();
          > > BufferedReader br = new BufferedReader(new InputStreamReader(inp));
          > >
          > > byte[] ba = new byte[txContentLength];
          > > System.out.println("Reading...");
          > > int bytesRead = inp.read(ba);
          > > System.out.println("bytesRead= " + bytesRead);
          > > while(bytesRead < txContentLength) {
          > > int moreRead = inp.read(ba, bytesRead, (ba.length - bytesRead));
          > > if(moreRead == -1)
          > > break;
          > > bytesRead += moreRead;
          > > }
          > >
          > > System.out.println("finished reading buffer...");
          > > StringBuffer sb = new StringBuffer(new String(ba));
          > >}
          > >
          > >
          > >I have a java client on my PC that takes an XML file as input and sends
          > >the
          > >information to the servlet without any problems.
          > >The problem is a client that is connecting to our network via a T1
          > >connection. When they send transactions, about 1 out of every 4
          > >transactions makes it past the "Reading..." statement above. The other
          > >transactions appear to 'hang' when it hits the inp.read(ba) line above.
          > >From all indications, that servlet's execute thread appears 'hung' as
          > >if the
          > >inp.read() is waiting forever.
          > >
          > >I've tried using readLine() on the InputStream() and my local client
          > >program
          > >is unaffected - it works OK. The remote client is having problems using
          > >either method. The only difference I've noted with the remote client
          > >is
          > >that they are using HTTP 1.0 and I'm using HTTP 1.1. Initially, their
          > >mime-type was null but they've changed it to text/xml and no luck. I've
          > >even sent them my client code that is working and they are still having
          > >problems...
          > >
          > >Another strange anomoly is that req.getContentLength() is returning a
          > >valid
          > >number on the transactions that fail. For example, I had some debug
          > >code
          > >that showed the content length and it was always something like 4012
          > >or
          > >3500, etc. Not -1 as I would expect...
          > >
          > >Has anyone run into this problem with receiving XML transactions?
          > >
          > >Thanks
          > >Rob Mason
          > >
          > >
          > >
          >
          

Similar Messages

  • Can we send  XML  over HTTPS ?

    Can we send XML over HTTPS ?

    malcolmmc wrote:
    meacod wrote:
    rabbits?
    Rabbits
    http://www.rabbitmq.com/
    They wrote
    +RabbitMQ is designed from the ground up to interoperate with other messaging systems: it is the leading implementation of AMQP, the open standard for business messaging, and, through adapters, supports XMPP, SMTP, STOMP and HTTP for lightweight web messaging.+
    They mentioned only HTTP ....Does HTTPS implied here ?

  • 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?

  • Query regarding sending XML over HTTP Post request

    Hello,
    I am trying to send XML data from a server to client via HTTP Post request
    And vice versa � receive the data by a client
    Assume that the xml data looks something like
    <?xml+version="1.0"?>
    So my post query will look like
    http://<IP Address>:<port>/
    POST /MessageReceiver.jsp HTTP/1.0
    Host: www.SomeHost.net
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 38
    %3C%3Fxml%2Bversion%3D%221.0%22%3F%3E+
    This information will be received by the client and converted back to xml data.
    My query is - is there some library/open-source stuff that
    does the process of transcoding the entity's non-ASCII characters
    at the server side
    and decoding the URL back to human-readable form at the client side?
    i.e. I need a simple mechanism to convert
    <?xml+version="1.0"?>
    to
    %3C%3Fxml%2Bversion%3D%221.0%22%3F%3E+
    at the server side, while sending data
    and do the opposite at the client side to get the xml back.
    Also could some one confirm if JTidy is a right tool to check if the xml is well-formed?
    Or is there any other standard tool that checks for well-formed properties of xml?
    regards,
    Deepak.

    java.net.URLEncoder / URLDecoder?
    Also could some one confirm if JTidy is a right tool to check if the xml is well-formed?No, it's for parsing HTML. An XML parser is checking for well-formedness in any case.

  • XML over HTTP using BPEL (not using SOAP)... is this possible?

    Hi there.
    We're trying to expose a BPEL process which will be exclusively triggered from a HTTP POST. The Client Partner Link in the BPEL process models Oracle's Transparent PunchOut standard. This standard is strict XML-over-HTTP, SOAP is not involved.
    However, I am getting issues when I POST the XML to BPEL. It is telling me that it requires a SOAPAction in the header. Again, the design dictates that this is raw XML over HTTP, so we are not to use any SOAP specific header values nor any kind of SOAP wrapper.
    I deployed the sample 'HTTPPostService' process which was delivered with BPEL. I am seeing the same error when I try to POST XML to this process as well. I get a response (in a SOAP wrapper) saying that it wants a SOAPAction in the header. The WSDL used to create this sample process clearly does not bind to SOAP, (there are no mentions of the SOAPAction in the operation, etc) so I do not understand.
    So, my question is: Is is possible to POST raw XML to a BPEL process? Or does BPEL require all processes to follow the SOAP 'protocol' ?
    Thanks for any help.
    Message was edited by:
    [email protected]

    I am also trying to do the same stuff. If i deploy the sample application HttpGetService, will i be able to send the request from browser the way we send typical http get request?
    here is the url which i want to use to invoke Http get BPEL
    http://cybage1:9700/httpbinding/default/HTTPGetService?ssn=10&id=20
    but i am getting following exception
    500 Internal Server Error
    java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
         at java.util.ArrayList.RangeCheck(ArrayList.java:507)
         at java.util.ArrayList.get(ArrayList.java:324)
         at com.collaxa.cube.ws.http.HttpBindingServlet.call(HttpBindingServlet.java:113)
         at com.collaxa.cube.ws.http.HttpBindingServlet.doGet(HttpBindingServlet.java:97)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:810)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:798)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:278)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:120)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)

  • Designing services for xml over http client requests

    Hi
    I am new to WebServices and Weblogic Integration. I have been using it for only over a month. I have a very basic design issue.
    We have to provide a service that
    1. accepts xml over http requests
    2. Returns a request ack
    3. Process Form a response -This activity consumes time so it will be made asynchronous
    4. Send the response as xml over http
    5. Wait for response ack
    6. Get another type of request from client, the processign of which depends on the result of the previous request .. and so on..
    The problem here is that Webservices accepts only SOAP messages but our client will send raw xml messages. Also we need to remember the condition of the previous state.
    I dont know if my assumption that SOAP is used is right.
    Please tell me how to design a raw xml based system without using SOAP messages.
    Thanks
    nithya

    I don't see nothing wrong with your code, there must be something else happening.
    You sure you are not being some proxy server?? but even then you are making a post request so it shouldn't be happening.
    MeTitus

  • XML over HTTP out of the EJB container

    I need to communicate with a legacy system via XML over HTTP from the EJB layer. I created a custom solution for this on a previous assignment using Castor for the marshaling etc. and standard JDK classes for the opening the HTTP connection, posting etc. I am thinking of implementing a similar solution in the using the DAO pattern. Are there any new open-source implementations for such XML/HTTP connectivity (non-SOAP)? Surely there is somethign out there!
    Thanks,
    -Chris

    In general, it is bad design to make network calls from the EJB layer, just as it is against the spec to do things such as create threads, write to the file system, etc.
    I know this doesn't answer your question but it is something to consider.

  • Post XML over HTTPS in a loop

    HI,
    I have a requirement to post XMLs over HTTPS. I also am supposed to retrieve the response XML, interpret it and do some processing based on the response status in the response XML. This has to be done for each XML.
    Currently I am establishing a new HTTPsURLConnection for each XML, wrting the XML to output stream, retrieving the response from input stream and then releasing the connection using disconnect() method.
    Is this the recommended approach or should I be creating just one connection for posting all the XMLs? Also, does java use some kind of connection pooling while creating HTTPURLConnection?
    I am frequently getting "SocketTimeoutException Exception --> connect timed out" while processing large number of XMLs. Is this exception due to large number of connections that I am creating?
    This program is running as a stand alone program on unix box.
    Regards,
    Jacob

    Is this the recommended approachYes.
    or should I be creating just one connection for posting all the XMLs?No.
    Also, does java use some kind of connection pooling while creating HTTPURLConnection? Yes.
    I am frequently getting "SocketTimeoutException Exception --> connect timed out" while processing large number of XMLs. Is this exception due to large number of connections that I am creating?Could be, especially if you're doing them in parallel.

  • Send XML by HTTP from ext. System to XI and process

    Hi XI Experts,
    I want to configure a typical XI Scenario. Send XML by HTTP to XI. I know the URL, to send data to my XI test machine.
    I'm struggling with the HTTP Parameters and the necessary Configuration in the Integration Directory. In the URL I have to provide for our XI 3.0 machine
    service
    namespace
    interface
    Namespace and interface is clear to me, but not the "Service". I know, that the "Service" could be an SLD Business System. In my scenario I don't want to configure all potential senders (e.g. customers) as a business system.
    I want to have a "partner" in the Directory. There are partner services and services without a partner. Does someone can provide me the configuration steps. At minimum so that I receive the XI message in the integration engine.
    Routing and mapping I will configure. But at the moment I really don't know how to configure the "Service", if I want to use a "Partner" as sender, and not a business system.
    Thanks in advance
    Klaus
    P.S. My configuration scenario is a purchase order from a customer (in XML), which I want to transfer to an R/3 Backend to create a sales order.

    Hi Klaus,
    Check this SAP help-
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/64db4daf9f30b4e10000000a11466f/frameset.htm
    In the Service , either you can have Business System created in the SLD or you can create your Own Business Service in the Directory. So create the service and go continue further.
    For creating a Party services
    This blog may give some hints-/people/sravya.talanki2/blog/2005/08/17/outbound-idocs--work-around-using-party
    Regards,
    Moorthy

  • 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();
    }

  • Using Business Service that supports XML over HTTP in OSB

    Hi,
    I needed to integrate my system with another legacy system that supports communication only through XML over HTTP. I am just trying to understand much about this XML over HTTP. I think in OSB, this is possible only possible through REST interfaces.
    Is there any other way and what about HTTP bindings in WSDLs? can you please let me know if you have any insights.
    I have gone through the urls about REST interfaces given in these forums. But just wanted to confirm the following scenaiors possible in OSB.
    - Client will connect to SOAP based proxy service which will in turn call REST based business service.
    - Client will connect to REST base proxy service which will in turn call SOAP based business service.
    Following point is not clear from the URLs i went through so just wanted to confirm the following too:
    - Client will connect to REST base proxy service which will in turn call SOAP based business service. And is it possible to add anything in soap header before calling soap based business service..
    Thanks & Regards
    Siva

    Hi Siva,
    XML over HTTP is a general use case and OSB supports it very well. REST is a special case and should be used when required. To know more about REST you may refer -
    http://www.infoq.com/articles/rest-introduction
    Now coming to OSB, SOAP and simple XML are two different cases. If you are creating XML type service then it is not binded to a WSDL/XSD but SOAP based service should always be binded with a WSDL. You may add/modify transport headers in OSB.
    Evaluate your requirements and then decide what exactly you need to use. Few links which may be of your use -
    http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/configuringandusingservices.html#wp1150438
    http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/configuringandusingservices.html#wp1154255
    http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/configuringandusingservices.html#wp1141071
    section "Configuring Business Services using the HTTP Transport" here - http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/httppollertransport/transports.html#wp1083292
    http://blogs.oracle.com/jeffdavies/2009/06/restful_services_with_oracle_s_1.html
    http://blogs.oracle.com/jamesbayer/2008/07/using_rest_with_oracle_service.html
    Regards,
    Anuj

  • Basic Question: plain XML over HTTP

    I would be getting messages in plain XML over HTTP. What should I use to receive those messages. Server is not SOAP based, so client cannot be SOAP based. Should I use JAX-RPC, but when I looked at the documentation, it is giving info regarding SOAP and plain xml over http. Can anyone help me?
    Thanks

    From my understanding, you would be getting a plain xml string by connecting to a server over http.
    You can is DOM or SAX apis to parse this xml input stream.
    For eg: if you are using DOM apis, then you can pass the input stream of the HttpURLConnection as follow...
         DocumentBuilderFactory buildFactory = DocumentBuilderFactory.newInstance();
         buildFactory.setIgnoringElementContentWhitespace(false);
         buildFactory.setValidating(false);
         DocumentBuilder docBuilder = buildFactory.newDocumentBuilder();
         URL url=new URL("http://someserver.com/abc.jsp");
         HttpURLConnection conn= (HttpURLConnection)url.openConnection();
         InputStream in= conn.getInputStream();
         Document doc = docBuilder.parse(in);
         ..Hope this helps...

  • Client call using   XML over Http using HttpClient

    Using HTTPClient while calling HTTPPost method to generate request for external system using XML over http using below code
    client.getState().setCredentials(new AuthScope(ipAddress,portNumber),new UsernamePasswordCredentials(username, password));
         PostMethod method = new PostMethod(url);
         String str = accDoc.toString();
    method.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(str.getBytes())));
    method.setDoAuthentication( true );                
    int result = client.executeMethod(method);
    server system getting 2 request. first request without basic authentcation details and second request with full auhentication details.
    So unnecessary eatra call without authentication details is going during calling the client program using above code.
    Please let me know which part of the above code is generationg extra call.
    Thanks in advance for your help

    I don't see nothing wrong with your code, there must be something else happening.
    You sure you are not being some proxy server?? but even then you are making a post request so it shouldn't be happening.
    MeTitus

  • Any good XML over HTTP examples?

    Hi,
    Does anyone know of a good example of using a XML over HTTP web service? Especially one that would be easily graspable by someone who's new to web services (read: me)?
    Is there a way to generate stub classes from a WSDL? I tried to do it in NetBeans but it didn't work, maybe NetBeans expects SOAP web services?
    Thanks

    Hi,
    This use case seems to be best handled using a RESTful Web Service. Check the Restlet project for a supporting framework:
    http://www.restlet.org/documentation/1.0/tutorial
    Best regards,
    Jerome
    http://www.restlet.org

  • 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.

Maybe you are looking for