How to send XML using UTL_HTTP
I am trying to workout how to send XML data to a webserver using UTL_HTTP but am not getting any reply
I need to submit the following XML document to a server "http://api.fastsms.co.uk/api/xmlapi.php" Their instructions are "The XML Document should be posted unencoded, with a UTF-8 character set as parameter 'xml'"
If I submit the following XML on their test form
<?xml version="1.0"?>
<apirequest version="1">
<user>
<username>**USER**</username>
<password>**PASSWORD**</password>
</user>
<application>
<name>Example Application</name>
<version>1.0</version>
</application>
<inboundcheck lastid="10711399"/>
</apirequest>
I get an XML response back with the messages in my inbox.
This is the code I am trying to use to accomplish the same from PL/SQL : I know a response is coming back as there is header information - just no content. What am I doing wrong ?
l_xml VARCHAR2(5000);
req utl_http.req;
resp utl_http.resp;
header_name VARCHAR2(256); -- Response header name
header_value VARCHAR2(1024); -- Response header value
response_text VARCHAR2(4000); -- Response body
l_url VARCHAR2(100);
BEGIN
l_xml := 'xml=<?xml version="1.0"?>';
l_xml := '<apirequest version="1">';
l_xml := '<user>';
l_xml := '<username>**USER**</username>';
l_xml := '<password>**PASSWORD**</password>';
l_xml := '</user>';
l_xml := '<application>';
l_xml := '<name>Example Application</name>';
l_xml := '<version>1.0</version>';
l_xml := '</application>';
l_xml := '<inboundcheck lastid="10711399"/>';
l_xml := '</apirequest>';
-- Open HTTP connection
l_url := 'http://api.fastsms.co.uk/api/xmlapi.php';
req := utl_http.begin_request(l_url,'POST',utl_http.HTTP_VERSION_1_1);
-- Set headers for type and length
utl_http.set_header(req,'Content-Type','application/x-www-form-urlencoded');
utl_http.set_header(req,'Content-Length',to_char(length(l_xml)));
-- Write parameter
utl_http.write_text(req,l_xml);
-- Read response file
resp := utl_http.get_response(req);
-- Print out the response headers
FOR i IN 1 .. utl_http.get_header_count(resp) LOOP
utl_http.get_header(resp,i,header_name,header_value);
logging_pkg.info(header_name || ': ' || header_value);
END LOOP;
-- Print out the response body
BEGIN
LOOP
utl_http.read_text(resp,response_text);
logging_pkg.info(response_text);
END LOOP;
EXCEPTION
WHEN utl_http.end_of_body THEN
logging_pkg.info('End of body');
END;
-- close http connection
utl_http.end_response(resp);
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
END;
Cheers,
Brent
Hi Billy
Yikes - how embarassing ! Thanks for pointing out my beginners mistake there. I've fixed my code - and also implemented the substitutions of parameters like you suggested - I like that approach.
Unfortunately the end result is no better - the line
utl_http.read_text(resp,response_text);
Still returns nothing back
The headers that are coming back are
Date: Thu, 04 Jul 2013 08:31:56 GMT
Server: Apache/2.2.16 (Ubuntu)
X-Powered-By: PHP/5.3.3-1ubuntu9.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Connection: close
I guess I will need to try chasing it with the fastsms vendor so see if they can check my incoming request and see if there are any glaring problems. I know the xml is correct as I am now logging the xml string just before I send it and when I take that string and put it in their test form it works perfectly - something else in the puzzle is missing. I've had no experience using utl_http before - perhaps it's no possible to read the xml repsonse using this ?
Anyway, thanks for your help Billy.
ps - How do you paste your code into your message to get that formatting ?
Cheers,
Brent
Similar Messages
-
How to use method POST to send XML using utl_http?
Hi,
I am trying to work out how to use the POST method to mimic submitting data from a HTML form, using utl_http.
I cannot use SOAP for this as the people I am sending the data to are just expecting an XML document to be sent to a standard CGI script running on their web server.
There is a lot of documentation on how to submit data using the POST method (using Utl_Http.Write_Text etc), but I cannot find anything that tells me how to submit form variables.
The examples on OTN say this:
"Alternatively use method => 'POST' and Utl_Http.Write_Text to
build an arbitrarily long message"
but don't tell me how to actually place the data into the required input parameters of the CGI program I am hitting.
I need to hit a URL such as
www.asite.com/cgiprogram
and pass in a parameter, eg
in_param="test+data"
I am currently doing this as a GET, which works, but the XML document I am passing in could potentially be bigger than the GET method will allow.
Any help would be greatly appreciated.
Thanks,
Leon.Please try the PL/SQl forum
-
How to send XML file to https server using POST
Hi, I am having an requirement, that I have to connect to https server and I have to pass an input XML file as a response server will give me output XML file.
The certificate validation part is over, I am using FileInputStream to read the XML file and attaching this to connection.getOutputStream(); but server is throwing me DTD does n't match.
Can any body tell me how to send XML file, I have to use any DOM parser to send the XML file, suggest me and give me sample code.
Thanks,Can anybody give me the solution
-
how to edit xml file particular value. and how to send xml file over ip address 192.168.2.10 device using ftp through Ethernet
Hello
For using FTP function in LabVIEW, I recommend you to check this document: FTP Basics
Also, take a look at FTP Browser.vi, which is available at the Example Finder.
To edit a XML file, try to use VIs in XML palette. Maybe Write to XML.vi helps you.
Post your current VI if possible.
Regards
Mondoni -
How can send mails using hotmail/rediffmail domain name?
I have used the below code to send a mail using javamail API?Even when I am sending my application does not have notified any of error/exceptions,But the message is not reached to I have given receipient's address in the to field.
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Sendmail1 extends HttpServlet {
private String smtpHost;
// Initialize the servlet with the hostname of the SMTP server
// we'll be using the send the messages
public void init(ServletConfig config)
throws ServletException {
super.init(config);
smtpHost = config.getInitParameter("smtpHost");
//smtpHost = "sbm5501";
smtpHost = "www.rediffmail.com";
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, java.io.IOException {
String from = request.getParameter("from");
String to "[email protected]";
String cc = "[email protected]";
String bcc ="[email protected]";
String smtp ="www.rediffmail.com";
String subject = "hai";
String text = "Hai how r u";
PrintWriter writer = response.getWriter();
if (subject == null)
subject = "Null";
if (text == null)
text = "No message";
String status;
try {
// Create the JavaMail session
java.util.Properties properties = System.getProperties();
if (smtp == null)
smtp = "www.rediffmail.com";
properties.put("mail.smtp.host", smtp);
Session session = Session.getInstance(properties, null);
//to connect
//Transport transport =session.getTransport("smtp");
//transport.connect(smtpHost,user,password);
// Construct the message
MimeMessage message = new MimeMessage(session);
// Set the from address
Address fromAddress = new InternetAddress(from);
message.setFrom(fromAddress);
// Parse and set the recipient addresses
Address[] toAddresses = InternetAddress.parse(to);
message.setRecipients(Message.RecipientType.TO,toAddresses);
Address[] ccAddresses = InternetAddress.parse(cc);
message.setRecipients(Message.RecipientType.CC,ccAddresses);
Address[] bccAddresses = InternetAddress.parse(to);
message.setRecipients(Message.RecipientType.BCC,bccAddresses);
// Set the subject and text
message.setSubject(subject);
message.setText(text);
Transport.send(message);
//status = "<h1>Congratulations,</h1><h2>Your message was sent.</h2>";
} catch (AddressException e)
status = "There was an error parsing the addresses. " + e;
} catch (SendFailedException e)
status = "<h1>Sorry,</h1><h2>There was an error sending the message.</h2>" + e;
} catch (MessagingException e)
status = "There was an unexpected error. " + e;
// Output a status message
response.setContentType("text/html");
writer.println("<title>sendForm</title><body bgcolor= ><b><h3><font color=green><CENTER>CALIBERINFO.COM</CENTER></h3>Your message was sent to recepient(s).<br><font color=red>"+"\n"+to);
writer.println("<br><br><a href=e:/mail/javamail/mail.html>back to compose</a>");
writer.close();
Please any one help me out from this probs.
Awaiting for yours reply,
or give me a reply to: [email protected]
Regards,
@maheshkumar.kHi,
how can send mails using hotmail/rediffmail domain name?In your java application,you specified www.rediffmail.com as your
smtp server.But that is the address of that website.Try will a smtp
server instead.For a list of free smtp servers,please visit http://www.thebestfree.net/free/freesmtp.htm
Hope this helps.
Good Luck.
Gayam.Srinivasa Reddy
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support/ -
How to send attachments using java application and outlook
Hi ,
I created an application in java which is as
on the Conference Tab i can schedule a conference and with the send command on page it map all the scheduled data to outlook(with all conference details) and using outlook send option the mails are send to appropriate user.
but now i want to modify this application such as when i use the send command from my jsp page it should attach the file that is in .vcs or .ics format for auto updation of user calender.
can any one know how to send attachment using java application .Last time I checked, SMS was a service between carriers and doing SMS yourself was really tricky. Some services existed to let you do it but as I recall they wanted non-trivial money.
However, most phone carriers provide an email-to-SMS bridge of some kind.
So the easiest thing is just to send an email.
That's sending from a non-phone to a phone. There's a J2ME library to send/receive SMS from/to a phone.
However, this is from memory, and a little out of date, so I could be entirely wrong. Hope it helps anyway. -
Hi All
please tell me how to validate xml using xsd
regardsTry using this link:
= http://www.google.nl/search?q=XML+validate+oracle for instance or
= use the search button on this forum and / or
= read the FAQ on this (XML DB FAQ
Thanks Eddie et all, for educating me via http://awads.net/wp/2006/11/14/barts-punishment-for-asking-dumb-questions (don't mind the URL , the info there is really useful)
The following link on this site is just brilliant: http://www.albinoblacksheep.com/flash/posting.php
Grz
Marco
Message was edited by:
mgralike -
How to send attachments using HTTP Binding Adapter?
How to send attachments using HTTP Binding Adapter in Jdeveloper?
Requirement: I need to send attachments to a system which can communicate with the middleware using https only.
Kindly suggest..
Edited by: Richa Juneja on Jan 28, 2013 4:03 AMHi,
Following links may help U
/people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
http://help.sap.com/saphelp_nw04/helpdata/en/3c/b4a6490a08cd41a8c91759c3d2f401/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/29/5bd93f130f9215e10000000a155106/frameset.htm
to know the basics about soap adapter u cn check out this link
/people/padmankumar.sahoo/blog/2005/02/15/an-overview-of-soap
to get in detail about the attachments chk out this link
hi i am unable to attach an attachment in File to mail scenario
Regards
Pullarao -
How to send XML file into XI using sender HTTP adapter
I am using HTTP sender adapter to post the XML file into XI. I tried to form the URL by using the following String query , but I am unable to execute file.
String urlString = "http://<servername:portno>/sap/xi/adapter_plain?namespace=<namespace>&interface=<interface name>&service=<service name>&party=&agency=&scheme=&QOS=BE&sap-user=xiappluser&sap-password=satyam&sap-client=100&sap-language=EN";
How can I execute xml file by using HTTP sender adapter.
Any one with better suggestions, about this idea?
Thanks in advance for all.
Ram RajHi
Just use the following parameter to send xml file using HTTP adapter.
"http://xiserver:8000/sap/xi/adapter_plain?namespace="senderNamespace"&interface=senderinterface&service=sender service";
"&party=sender party"&agency=&scheme=&QOS=BE&sap-user=userid &sap-password=password&sap-client=100&sap-language=D";
with the help of this you are able to point out which interface you would like to use.
And in payload pass the xml.
and thats it
carry on
Cheers
Regards
Piyush -
How to send emails using Automatic Work Items in Collections using XML Publ
Hi,
We are using XML Publisher to send correspondances in Advanced Collections.
We want to send email correspondances using Automatic Strategy Work Items.
Can anybody please help on how to send these?I believe you have to define your dunning template and assign that template to the strategy work item.
Let me know if you are still not able to do it.
Thanks,
Anil -
HOW TO SEND XML BACK TO PRINT? (See Inside thread for more info)
Hello Everybody,
Because there is not a lot of documentation on if_fp and if_fp_pdf_object
I found out that i can retrive my PDF from the ADS with the following code:
data:
lo_fp TYPE REF TO if_fp ,
lo_pdfobj TYPE REF TO if_fp_pdf_object,
pdf_xstring TYPE xstring,
xml_data TYPE xstring,
lv_xml_data_string TYPE string.
Get FP reference
lo_fp = cl_fp=>get_reference( ).
Create PDF Object using destination 'ADS' (<-- this is how it is defined in SM59)
lo_pdfobj = lo_fp->create_pdf_object( connection = 'ADS' ).
set document
lo_pdfobj->set_document(
EXPORTING
pdfdata = fp_formoutput-pdf ). " fp_formoutput-pdf is of type xstring
Tell PDF object to extract data
lo_pdfobj->set_extractdata( )." obsolate!!!
call METHOD lo_pdfobj->set_task_extractdata( ).
Execute the call to ADS
lo_pdfobj->execute( ).
lo_pdfobj->get_data(
IMPORTING
formdata = xml_data ).
After this i can manipulate xml_data but dont know how to send it back to print...
Can you direct me to the solution please?
Thank you in advance,
Eran Fox
p.s.:
Component version SAP ECC 6.0
Unicode System No
Database system ORACLE
Release 10.2.0.2.0
Kernel release 700Hi Billy
Yikes - how embarassing ! Thanks for pointing out my beginners mistake there. I've fixed my code - and also implemented the substitutions of parameters like you suggested - I like that approach.
Unfortunately the end result is no better - the line
utl_http.read_text(resp,response_text);
Still returns nothing back
The headers that are coming back are
Date: Thu, 04 Jul 2013 08:31:56 GMT
Server: Apache/2.2.16 (Ubuntu)
X-Powered-By: PHP/5.3.3-1ubuntu9.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Connection: close
I guess I will need to try chasing it with the fastsms vendor so see if they can check my incoming request and see if there are any glaring problems. I know the xml is correct as I am now logging the xml string just before I send it and when I take that string and put it in their test form it works perfectly - something else in the puzzle is missing. I've had no experience using utl_http before - perhaps it's no possible to read the xml repsonse using this ?
Anyway, thanks for your help Billy.
ps - How do you paste your code into your message to get that formatting ?
Cheers,
Brent -
How to send XML via HTTPS in Servlet
I am new to Java. I need to make a servlet which can send a message via HTTPS with a content type of XML to another web server when it is called. each msg is proceeded with a header in the following format:
requestID=rid&userID=uid&password=mypd
and a detail information in XML:
<S_Request>
<requestControllID>1-rf200</requestControlID>
<zipCode>99012</zipCode>
<orderQuantity>35</orderQuantity>
</S_Request>
I have basic idea of how to send an http post with parameter string by using the Redirect function but don't know how to deal with the XML detail. Any one has idea about this? Any help will be greatly appreciated!This is what I did for one of my projects;
String myXML = "all the xml tags and fields";
URL url = new URL("https://www.somesite.com");
HttpsURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
OutputStream outXML = connection.getOutputStream();
outXML.write(myXML.getBytes());
I think you can add the requestID and all to the begining of the string myXML
Good luck
Rajesh -
How to send XML files through Business Connector to client URL
Dear ALL
I am new to SAP BC. We have setup BC 4.8 and would like to send out a XML file from BC to Client URL. Could someone please guide me.
Please suggest solutions.
Thanks
AhmedHello Mickael
Thanks for your reply. No, we do not have PI. This BC will be used for point to point communication with client.
Scenario:
R/3 server to send XML files to BC. BC will load these files ( using pub.getfile service), this file is to be parsed using pub.loaddocument service and then sent to client in XML format wrapped with digital signature. As i am new to BC i am unable to parse this file and wrap it with the digital signaature to send it.
Kindly advise on how best can we perform this action.
Thanks
Ahmed -
How to send xml file from local folder to azure storage
Hi,
My plan is i have xml files which are under folders in my local.
I want to use mobile service to send xml files to azure storage,
how shall i do that, either by c# or mobile service.
If internet stop, I will use my mobile service to transfer all xml files to azure storage and run web job to do to update azure
sql by xml file.
please advice.
SupermanHi,
You could refer the following link for assistance with uploading image files to Azure Blob Storage using Mobile Services:
http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-phone-upload-data-blob-storage/
And for image files you could refer the following link:
http://stackoverflow.com/questions/25977406/upload-a-text-file-with-azure-mobile-services
Regards,
Malar. -
How to send data using serial Communication
I want to make serial communication using RXTXcomm.jar file.I was written the code.From this I got the list of serial ports avilable on pc but then after when I was tring to send command to machine which is attached to port it didn't gave any reply.
Tell me that how to send command to port?This is how I do it:// open port, get ownership
SerialPort serialPort= (SerialPort)portId.open(APPLICATIONNAME, timeout);
// no framing and no threshold
serialPort.disableReceiveFraming();
serialPort.disableReceiveThreshold();
// communication speed, parity, stopbits and databits
serialPort.setSerialPortParams(BAUDRATE, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
// no handshaking or other flow control
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
// timer on any read of the serial port
serialPort.enableReceiveTimeout(TIMEOUT);
// open streams for reading and writing
InputStream is= serialPort.getInputStream();
OutputStream os= serialPort.getOutputStream();... then you use the 'os' stream for writing and the 'is' stream for reading.
kind regards,
Jos
Maybe you are looking for
-
Fail to update record in the RowUpdating event
If I have well understood, the RowUpdating event is called before to send the row to the database. I want to modify the row argument of this event before to send it to oracle to add traceability info (user name of the user and the date of modificatio
-
Installation of oracle 9205 database and client software on same machine
Hi, I have installed Oracle 9205 on my laptop running on windowsxp sp2. I intent to create a Database and access the same using developer forms which again would be installed on the same laptop. Please help me in configuring this scenario. how to con
-
Env: Weblogic 8.1.5 Getting empty return in test view with new data
Hi, I am using Weblogic 8.1.5, Basically a run down of this issue is that my response in test view, is completely Empty when I add a new piece of data in the response current code example below: SuccessResponseType srtype = SuccessResponseType.Fact
-
so yesterday I bought 4 songs on my laptop expecting them to be on my main computer on itunes as well because I was using the homesharing option, but the new songs are not showing up on my original computer - only on the laptop. What do I do? I wan
-
How to preserver Face data in Aperture 3.5.1 export to new library ?
In an Aperture 3.5.1 library I add some face names and export smart albums to a new Aperture 3.5.1 library. However, in the new library, when I create a smart album of Faces that include a name I had added in the old library, the album is empty. The