8

How to publish XML data in node.js http.request

 2 years ago
source link: https://www.codesd.com/item/how-to-publish-xml-data-in-node-js-http-request.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to publish XML data in node.js http.request

advertisements

i am trying to submit a xml request to a web service via Node.js using http.request.

Here is my code. My issue is that instead of data=1 i want to post xml to the service.

http.request({
   host: 'service.x.yyy.x',
   port: 80,
   path: "/a.asmx?data=1",
   method: 'POST'
}, function(resp) {
   console.log(resp.statusCode);
   if(resp.statusCode) {
        resp.on('data', function (chunk) {
            console.log(chunk);
            str +=  chunk;
        });
        resp.on('end', function (chunk) {
            console.log(str);
        });
  }
}).end();

Ho to do this?


http.request returns ClientRequest object which is also a writable stream. Instead of .end() do end(xmlbody) or .write(xmlbody).end()

Related Articles

& Lt; Solved & gt; How do I retrieve data from the .ajax HTTP request using Jquery and PHP?

I need to retrieve an array from a PHP file which is a SQL query coming back in an array. I've encoded it in with json_encode(); and returned it. Here is my JS file: $(document).ready(function() { $('#indicators').change(function() { $('#countries').

How to send XML data in the body of the HttpBuilder query in groovy

Here data is the XML content How to send XML data in HttpBuilder request body in java or groovy def http = new HTTPBuilder(baseUrl) http.request(Method.POST, ContentType.XML) { uri.path = path headers.'Accept' = 'application/xml' headers.'Authorizati

How to select xml data from a sql table

I'm trying to write a sql query to get results as follows from a xml data type column in MS Sql Server 2012 database table Data is stored in the database as follows ID |Summary ========================== 1 |<Summary><Field Key="Col1" Va

How to turn XML data into a SQL Server table

I have a XML data like this : <root> <log realm="ABC" at="Wed Oct 15 00:00:02 2014.211" lifespan="2279ms"> <receive> <isomsg direction="IN"> <header>6000911384</header> <field

AS3 & amp; XML - How to build xml data in as3?

I am playing around with saving .xml files from data in my game. I know how to convert an xml object to a ByteArray and write that to a FileReference. What I need to know now is how to go from an empty xml object (using var xml:XML = new XML()) to a

How to load xml data with condition?

How can I load data from an xml file into a DataTable with a condition?You can't apply a condition when loading the data. You can easily load an XML file into a DataTable, and then either create a DataView over the DataTable to show you only the rows

How to filter xml data using jquery?

<Item id="419" rank="0.0000" date_added="2012-09-24T19:43:14" date_end="2012-10-15T19:43:14" uid="134333" price=" ,-" district="-1" district_text="Friend" cid="9"

How to store xml data from the sql server to the arraylist in java

I am retrieving data from the MySQL server, where one column name is having the datatype as XML. I need the data inside XML attribute for some comparison. I want to store data type and values of the XML attribute in one List<ArrayList<String>>

Android: How to read XML data in URL

I want to read XML data from URL and have tried in different ways. But unable to find the answer. Iam developing a agumented reality application, where iam reading location information from XML ( which is in URL ) Iam new bee to android as well I hav

How to view backend data in Node.js + jade + angularJS + mongoose

I'm going to make web application (SPA) with: Backend: Node.js (express) Frontend: Jade + AngularJS Database: Mongoose I will send data (as a form) to backend in this way ExpressJS AngularJS POST (Check ANSWER) It will be simple CRUD. However i wonde

How to view xml data using Reactjs

I want to get the input for React JS as XML format instead of json format. So please reply how to display XML in React js .I would suggest you parse your xml data to a Javascript object. You can the xml2js library to this end.

How to browse XML data in Golang?

I have used xml.UnMarshal method to get a struct object but it has it's own limitations. I need a way where I can get all the descendants of a particular type inside a node without specifying the exact xpath. For example, I have an xml data of the fo

How to extract XML data

I have a XML file that has the following data, <extcode Type="abc" Code="12345" /> I want to be able to extract the Code, i.e., 12345, for rows where Type is abc. I tried XPathSelectElements("Type[@name='abc']") but it

How to format XML data using C #, JQuery, or HTML

How i can get following XML data to easy understand format. Input XML Data <?xml version="1.0"?> <user> <details><name>xyz</name><class>mno</class><city>pqr</city></details> <info>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK