Plain HTTP sending Post Requests and Multipart Uploads

Hi,
I have a scenaio where I need to send an normal POST request
to the server. This request needs to have not the XML payload but
the same data in the form of a POST request.
Is there a way to transform the data out of the XML format into
the plain POST format prior to sending it?
Also, another scenario requires an file upload via HTTP (like a
file submitted by a web-form). Is this possible with PI and how?
Thanks for any pointers
Best regrads

Hi,
If you do not send any payload in the http request you are going to get a http error.
For your second requirement, There is no any problem, You can use any existent tool, or maybe develop you own program.
Http client.
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417600)ID1536482550DB10501227175138097442End?blog=/pub/wlg/15296
Regards
Ivan

Similar Messages

  • Unable to send POST request to BSP

    Hello,
    we have the following scenario. We are sending AJAX requests via JQuery to a BSP Page. Now the handling of GET requests works fine, however when we send POST requests we get the following error (translation by myself)
    Message Number E NR 751 can not be processed in plugin mode.
    Programm SAPLSNR3
    Include LSNR3F01
    Line 188
    Anyone know why that is?
    Thanks in advance

    Hi Stefan,
    The BSP page is accessing some number ranges object and an error is raised from number ranges system
    The error is
    For object &1 &2, number range interval &3 does not exist &4
    try passing the parameters that are being passed in POST directly with BSP and debug the problem.
    Regards,
    Ravi

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

  • Plain HTTP sender adapter - Extract XML from request

    Hi all,
    I face a blocking issue in one of my B2B process.
    A marketplace must send Purchase orders to my customer with synchronous HTTPs requests.
    When messages arrive, we can see the following payload in incoming message (SXMB_MONI)
    %24xmldata=+%3C%3Fxmlversion%3D%221.0%22encoding%3D%22UTF-8%22%3F%3E%0D%0A-%3CMessage%3E%0D%0A-%3CHeader%3E%0D%0A%3CFrom%3EPA%3C%2FFrom%3E%0D%0A+%3CTo%3E83092SAC01%3C%2FTo%3E%0D%0A+%3CDocType%3ETAEPa-xCBL30PO%3C%2FDocType%3E%0D%0A++%3CDocID%3EP-20050502T125611-TATG310-
    %0D%0A++%3C%2FMessage%3E&submit=Soumission
    WebServer of B2B partners don't put XML data in HTTP body but as HTML form in .
    Is there a way in Plain http adapter to interpret such a request ?
    How can we decode hexadecimal sequence ?
    Thanks to help us.
    Jean-Charles

    Hi Jean-Charles !
    Unfortunately, I don't know any other option (based on XI; maybe you can develop some kind of external translator between your system and  XI's http adapter). The first link (although it is based on a escenario in the oposite direction) speaks about using java proxy instead of the http adapter.
    Here are some links:
    /people/thorsten.nordholmsbirk/blog/2006/08/06/use-a-java-proxy-instead-of-a-jca-adapter
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a068cf2f-0401-0010-2aa9-f5ae4b2096f9
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f272165e-0401-0010-b4a1-e7eb8903501d
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/30572c6a-d311-2a10-99ab-f646ec3b5b12
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d06315a6-e66e-2910-039c-ba8bbbd23702
    https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=java+proxy&adv=false&sortby=cm_rnd_rankvalue&start=21#
    Regards,
    Matias
    ps: please award points if helpful.

  • Plain Http Sender adapter - user details

    Hi experts,
    I am working with plain HTTP Adapters, a Java client is sending a HTTP request to XI server......the following url is used
    http://server:post//sap/xi/adapter_plain?namespace=<namespace>&interface=<Interface>...................
    &sap-user=<user>&sap-password=<password>
    Now, I understand that, the logon credential needed to reach XI Server is being passed as url parameters and this seems to work.
    Is there any other way to pass this information apart from the URL?  Does anyone has any sample java code that posts HTTP request to XI/PI and the logon details is sent via code or some mechanism apart from the URL.
    Thank you.
    Sabbir

    Maybe this page helps you:
    http://www.kennethballard.com/Projects/HttpClient/readme-java.html
    "Call setUserInfo() if a username and password are required to access the given URL."
    httpConfig.setUserInfo(user, password);
    Regards
    Stefan

  • Weblogic POST requests and foreign characters

    We have Ajax post requests that work correctly in the Tomcat/Eclpse development environment. When moving them to the Weblogic environmnent, the POST requests no longer correctly send the data.
    A request object is created with a URL. The foreign character string is encoded using the Javascript encodeURIComponent.
    The request is sent to the servlet.
    When the servletbase class starts the parameter is printed and shows ????.
    On the Tomcat environment the servletbase (which extends HttpServlet) class shows the parameter as what looks like a UTF-8 string.

    Have you tried seeing what ServletRequest.getCharacterEncoding() returns on both Tomcat / WebLogic?
    http://download.oracle.com/docs/cd/E17410_01/javaee/6/api/javax/servlet/ServletRequest.html#getCharacterEncoding()

  • Concurrent processing of POST requests and automatic flushing of the servlet response buffer in WLS6.1.

              Hi all,
              I encountered the following 2 servlet problems in WLS 6.0/ 6.1:
              1. Processing concurrent POST requests
              WLS seems to disallow concurrent executions of any servlet's doPost servlet method.
              When two clients attempt to send a request to a servlet using POST, the socond
              one
              is blocked until the first customer is served. In essence, the servlet ends up
              operating in
              1-user mode. I just learned from Jervis Liu that the problem is solved in WLS6.0
              if you disable http-keepalive.
              For WLS 6.1 a partial workaround is to make the servlet work in a single-thread
              mode (by implementing the javax.servlet.SingleThreadModel interface). In this
              case,
              WLS dispatches concurrent requests to different instances of the servlet.
              This doesn't completely eliminate the problem - still only one customer can be
              connected at a time. The improvement is that once the first customer is disconnects,
              the second can be served even if the doPost method for the first has not finished
              yet.
              2. Flushing the response buffer in WLS 6.1
              The servlet response buffer is not flushed automatically until doPost ends, unless
              you
              explicitly call response.flushBuffer(). Closing the output stream doesn't flush
              the
              buffer as per the documentation.
              I see that other people are experiencing the same problems.
              Has anyone found any solutions/workarounds or at least an explanation.
              Any input would be highly appreciated.
              Thanks in advance.
              Samuel Kounev
              

    Thanks for replying. Here my answers:
              > Did you mark your doPost as synchronized?
              No.
              > Also, try testing w/ native i/o vs not ... is there a difference?
              With native I/O turned off I get a little lower performance, but the
              difference is not too big.
              Best,
              Samuel Kounev
              > Peace,
              >
              > --
              > Cameron Purdy
              > Tangosol Inc.
              > << Tangosol Server: How Weblogic applications are customized >>
              > << Download now from http://www.tangosol.com/download.jsp >>
              >
              > "Samuel Kounev" <[email protected]> wrote in message
              > news:[email protected]...
              > >
              > > Hi all,
              > >
              > > I encountered the following 2 servlet problems in WLS 6.0/ 6.1:
              > >
              > > 1. Processing concurrent POST requests
              > >
              > > WLS seems to disallow concurrent executions of any servlet's doPost
              > servlet method.
              > >
              > > When two clients attempt to send a request to a servlet using POST, the
              > socond
              > > one
              > > is blocked until the first customer is served. In essence, the servlet
              > ends up
              > > operating in
              > > 1-user mode. I just learned from Jervis Liu that the problem is solved in
              > WLS6.0
              > >
              > > if you disable http-keepalive.
              > >
              > > For WLS 6.1 a partial workaround is to make the servlet work in a
              > single-thread
              > >
              > > mode (by implementing the javax.servlet.SingleThreadModel interface). In
              > this
              > > case,
              > > WLS dispatches concurrent requests to different instances of the servlet.
              > > This doesn't completely eliminate the problem - still only one customer
              > can be
              > >
              > > connected at a time. The improvement is that once the first customer is
              > disconnects,
              > > the second can be served even if the doPost method for the first has not
              > finished
              > > yet.
              > >
              > > 2. Flushing the response buffer in WLS 6.1
              > > The servlet response buffer is not flushed automatically until doPost
              > ends, unless
              > > you
              > > explicitly call response.flushBuffer(). Closing the output stream doesn't
              > flush
              > > the
              > > buffer as per the documentation.
              > >
              > > I see that other people are experiencing the same problems.
              > >
              > > Has anyone found any solutions/workarounds or at least an explanation.
              > > Any input would be highly appreciated.
              > >
              > > Thanks in advance.
              > >
              > > Samuel Kounev
              =====================================================
              Samuel D. Kounev
              Darmstadt University of Technology
              Department of Computer Science
              DVS1 - Databases & Distributed Systems Group
              Tel: +49 (6151) 16-6231
              Fax: +49 (6151) 16-6229
              E-mail: mailto:[email protected]
              http://www.dvs1.informatik.tu-darmstadt.de
              http://skounev.cjb.net
              =====================================================
              [att1.html]
              

  • ABAP need to connect to Webserivice and send a Request and get a response

    Hi All,
    i have a interfaace in SAP HCM, where i need to get data from given tables and convert it into XML and send it to Web service  as a #request, and then latter i need to get a response , where it is sucess or not ,
    I need to know exactly how to create a class in SE80 and what is the prerequiste for that , anyone , thankin g you
    Sridhar

    it as been sloved

  • I can't video chat, I send the request, and te video just load and load, never turns on. How can I fix this?

    Hi,
    I start to use iChat, Ican chat normally, but when I tried to make an video call with my friend, it doesn't work.
    I send the invite, and than my webcam turns on and a window is open, when i see my face, and start loading and i can't connect with my friend, it load eternally and never works, when i try, the results are always the same. I have an MacBook Pro...How can I fix this?

    HI,
    iChat uses different internet ports to do different tasks.
    If you have the Mac Firewall On then this should allow the ports the app is Using on an Incoming basis.
    These same ports also need to be allowed in your router.
    If the device has it use UPnP if you can.
    This allows the app to state which ports it wants to use and also for multiple devices to use the same ports.
    (It is needed for iChat Screen Sharing that involves a random port that cannot be opened in other methods)
    Can you also open the Connection Doctor (Video Menu of iChat) and say what it says on each tab ?
    7:57 PM      Sunday; March 24, 2013
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • How can i upload file using ajax post request and jsp

    Hi
    this is my code files
    addPhoto.jsp
    <html>
    <head>
    <title>Add Photo</title>
    <script>
    var optionNo = 0;
    var i=1;
    var val=0;
    var file = 0;
    var exten = new Array(".jpg",".jpeg",".gif");
    function addValues()
         for(var i=0;i<5;i++)
              optionNo += 1;
              oNewOption = new Option();
              oNewOption.text = optionNo;
              oNewOption.value = optionNo;
              addSelect.add(oNewOption);
    function addBoxes()
         var str = "";
         var j=0;
         val = document.getElementById('addSelect').value;
         for(j=1; j<= val; j++)
              str = str + '<font size=3>file:' + j + '</font>';
              str = str + '<input type="file" id=filepath'+ j +' name=file'+ j + ' onchange="uploadFile(hidden'+ j + '.value)"><div id="result'+ j +'"></div>
              str = str + '<input type="hidden" name="hidden' + j + '" value=' + j +'>';
         document.getElementById('addPhoto').innerHTML = str;
    function uploadFile(value)
    var str = "filepath" + value;
    file = value;
    var param = document.getElementById(str).value;
    var parameter = "filepath=" + param;
    alert(parameter.length);
    if(checkValidity(param))
    var url = "uploadFile.jsp";
    if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    req.open("POST", url, true);
    req.setRequestHeader("Content-type", "multipart/form-data");
    //req.setRequestHeader("Content-length", parameter.length);
    req.setRequestHeader("Connection", "close");
    req.onreadystatechange = callback;
    req.send(null);
         else
              document.getElementById("result" + file).innerHTML = "upload .jpeg,.jpg,.gif Files Only";
    function callback() {
    if (req.readyState == 4) {
    updatepage(req.responseText);
    function updatepage(str){
         document.getElementById("result" + file).innerHTML = str;
    function checkValidity(str)
         var i=0;
         var j=0;
         var str1 = str.substring(str.lastIndexOf("."),str.length);
         alert(str1);
         for(i=0;i<exten.length;i++)
         if(str1.search(exten) != -1)
              j++;
              break;
         if(j>0)
              return true;
         else
              return false;
    </script>
    </head>
    <body onload="addValues()">
    <h5>Add Photo(s)</h5>
    <select id="addSelect" name="addSelect" onchange="addBoxes()">
    <option id="select" selected>Select</option>
    </select>
    <div id="addPhoto"></div>
    </body>
    </html>
    uploadFile.jsp
    <%@page import="java.io.*"%>
    <%
    /*try
    String contentType = request.getContentType();
         System.out.println(request.getMethod());
         System.out.println("Content type is :: " +contentType); 
         if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
              DataInputStream in = new DataInputStream(request.getInputStream());
              DataInputStream in1 = in;
              int formDataLength = request.getContentLength();
    System.out.println(formDataLength);
              byte dataBytes[] = new byte[formDataLength];
              int byteRead = 0;
              int totalBytesRead = 0;
              while (totalBytesRead < formDataLength)
                   byteRead = in1.read(dataBytes, totalBytesRead, formDataLength);
                   totalBytesRead += byteRead;
              out.println("<br>totalBytesRead : " + totalBytesRead + " : formDataLength = " + formDataLength);
         } catch(Exception e) {
              e.printStackTrace();
         try
         String filePath = request.getParameter("filepath");
         System.out.println(filePath);
         File f= new File(filePath);
         String path = f.getName();
         String contentType = request.getContentType();
         System.out.println(contentType);
         //InputStream in = new FileInputStream(filePath);
         DataInputStream in = new DataInputStream(request.getInputStream());
         int formDataLength = request.getContentLength();
         System.out.println(formDataLength);
    byte[] buf = new byte[1024];
    OutputStream out1 = new FileOutputStream("c:/docs/" + path);
    int len;
    while ((len = in.read(buf)) > 0) {
    out1.write(buf, 0, len);
    in.close();
    out1.close();
         out.write("File Uploaded SucssesFully");
    catch(Exception e)
         e.printStackTrace();
         out.write("error while Writing File");
    %>
    the above code in request.getContentType() i am getting 0. I am not passing the content length. for the same application with out using Ajax i am
    getting the size of file... it is very very urgent for me.. pls help me out on this...
    Any one having the code on this pls mail me the code...
    my mail id ... [email protected]
    Regards
    Ashok Kumar

    Sure, you can upload a file, using a form input element of type file. You pick this up with a servlet, though you need a special request wrapper to sort out the multi-part request you get back that way (there's a suitable package on jakarta.apache.org/commons)
    The servlet decrypts the file and can pass the results to a JSP for display.
    Don't try to do the complicated stuff in a JSP, it all gets incredibly messy, and that's not what JSPs are for.

  • Stranger sending contact requests and very suspicous

    Hi ,I am recieving contact request from a stranger, this person at first posted a picture with someone in armed force uniform and I blocked it. Now he is continuing sending contacts and acting as if he is a different person with different names and images. I am asking for privacy, security, and safety please. This has to stop.

    Bump! really need to fix this.

  • HTTP - GET, POST, PUT and DELETE

    Which of these are implemented and supported by Flex 4 and which from AiR 2 ?
    Are there any libraries or other workarounds for non supported ones?

    I've spent many hours on this and here is the deal as I understand it.
    1) HttpService and HttpMultiService claim to support PUT and DELETE in the docs, but that only applies via a server proxy even in AIR
    2) flash.net.URLRequest supports PUT and DELETE from AIR without a proxy, but not in the browser. I understand FlashPlayer works through the browsers network connection, so cannot support PUT and DELETE when the browser doesn't
    3) as3httpclientlib has been working fine for me for development in AIR on MacOS with HTTPS Basic Authentication, but failing with an encryption issue in my iPad app. I haven't solved this, and am switching to URLRequest. There was a showstopping limitation (bug FP-6) in FlashPlayer that prevented as3httpclientlib from reliably doing large uploads. The limitation has been addressed in recent versions of AIR and Flashplayer, but as3httpclientlib hasn't been updated to take advantage of it
    4) Checkout as3awss3lib - it does PUT and DELETE with URLRequest
    Cheers,
    Gary
    blog.buzzware.com.au

  • Plain http payload xml format

    Hi,
    Can anyone point me to any documentation/example on the xml layout for the payload. I am using the plain http send to XI and I need to know how to put the data into the right xml format. Thanks..

    Hi Shilton,
    As said already you can get the payload from the "src" of the test tab. But you have to be careful while creating it as a payload. Usually we create the payload as string. And also the XML needs the " compulsorily. for example in <?xml version=<b>"</b>1.0<b>"</b>.
    while creating the string be careful and use '\' character before these quotes.
    something like this.
    var payload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:input_mt xmlns:ns0=\"http://com.somenamespace\">
       <val>000000000000001135</val>
    </ns0:input_mt>";
    hope this helps.
    regards
    venkat

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

  • HTTP POST Request with XML file in

    Hi @ all,
    I would like to send an HTTP Request with an XML File in the body to an SAP System
    I have the target URL and the a XML File.
    Now the question is. Is it possible to use something like the HTTP_POST FuBa to send an url post request with an xml file?
    If yes can anybody give me a hint?
    I have a php script which exactly do this coding. But to integrate it all in one system it is necessary to transform it into ABAP and call it there.
    // compose url and request and call send function
    function test($productID, $categoryID) {
         // create url
         $PIhost = "XXX.wdf.sap.corp";
         $PIport = "50080";
         $PIurl = "/sap/xi/adapter_plain";
         $PIurl .= "?sap-client=800";
         $PIurl .= "&service=XXX";
         $PIurl .= "&namespace=XXX";
         $PIurl .= "&interface=Frontend_Interface";
         $PIurl .= "&qos=EO";
         $PIurl .= "&sap-user=XXX";
         $PIurl .= "&sap-password=XXX";
         // create xml
         $request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
         $request .="<n1:FrontendInbound_MessageType xmlns:n1=\"http://crmpiebay.com\">\n";
         $request .= "\t<FrontendInbound>\n";
         $request .= "\t\t<ProductName/>\n";
         $request .= "\t\t<ProductCategory>".$categoryID."</ProductCategory>\n";
         $request .= "\t\t<ProductID>".$productID."</ProductID>\n";
         $request .= "\t\t<MessageID/>\n";
         $request .= "\t</FrontendInbound>\n";
         $request .= "</n1:FrontendInbound_MessageType>";
         // send http request
         postToHost($PIhost, $PIport, $PIurl, $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]."/".$_SERVER["PHP_SELF"], $request);
    // send post request to PI server
    function postToHost($host, $port, $path, $referer, $data_to_send) {
      $fp = fsockopen($host, $port);
      if($fp) {
           $res="";
           fputs($fp, "POST $path HTTP/1.1\r\n");
           fputs($fp, "Host: $host\r\n");
           fputs($fp, "Referer: $referer\r\n");
           fputs($fp, "Content-type: text/plain\r\n");
           fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
           fputs($fp, "Connection: close\r\n\r\n");
           fputs($fp, $data_to_send);
           while(!feof($fp)) {
               $res .= fgets($fp, 128);
           fclose($fp);
           return $res;
    Would be great if anybody could give me a hint how to solve such a HTTP Post request with XML body data.
    Thanks in advance.
    Chris
    Edited by: Christian Kuehne on Feb 26, 2009 4:32 PM

    hi friend could you please share your solution regarding this query if u got it already?

Maybe you are looking for