0

xml POST method using http protocol

i got a link from a travel hotel booking people like bellow link

Each request needs to be posted (through POST method) using http protocol to http://xmldev.dotwconnect.com/request.dotw and it receives a response irrespectively the request is successfully processed or not informing about the success of the operation.

how i can create a xml post method using php

4
Contributors
6
Replies
8
Views
8 Years
Discussion Span
Last Post by digital-ether
1

PHP5+, you can also use the stream functions.
http://www.php.net/manual/en/book.stream.php
http://www.php.net/manual/en/function.stream-socket-client.php

or the similar fsockopen() in PHP4:
http://www.php.net/fsockopen

With both of these you will create the raw HTTP request to send over TCP. However, if you need something more abstracted like cURL, you can use fopen(), with stream_context_create() in PHP5:
http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.stream-context-create.php

There are also many HTTP libraries based on fsockopen and stream_socket_client. You can use these or follow their examples.
http://pear.php.net/package/HTTP

0

PHP5+, you can also use the stream functions.
http://www.php.net/manual/en/book.stream.php
http://www.php.net/manual/en/function.stream-socket-client.php

or the similar fsockopen() in PHP4:
http://www.php.net/fsockopen

With both of these you will create the raw HTTP request to send over TCP. However, if you need something more abstracted like cURL, you can use fopen(), with stream_context_create() in PHP5:
http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.stream-context-create.php

There are also many HTTP libraries based on fsockopen and stream_socket_client. You can use these or follow their examples.
http://pear.php.net/package/HTTP

Those are all pretty much WAY overkill for what he needs. He's just trying to hit an API but the API writers evidently like their job too much and wrote the description in an extremely overtechnical way.

2

Those are all pretty much WAY overkill for what he needs. He's just trying to hit an API but the API writers evidently like their job too much and wrote the description in an extremely overtechnical way.

I find the stream_context_create() function simpler then cURL since you don't have to remember or look up all those CURLOPT_* constants.

// the xml to send
$xml = 'your xml payload';

// build your http request
$context = stream_context_create(array( 
    'http' => array( 
      'method'  => 'POST', 
      'header'  => "Content-type: text/xml\r\n", 
      'content' => $xml, 
      'timeout' => 10, 
    ), 
  )); 

// send it
  $resp = file_get_contents('http://xmldev.dotwconnect.com/request.dotw', false, $context);

Edited by digital-ether: n/a

0

hi
can anybody tell me how to use php with xml post.plz give some example.i go through php site but not able to find it.

plz help me asap.

thanks

0

hi
can anybody tell me how to use php with xml post.plz give some example.i go through php site but not able to find it.

plz help me asap.

thanks

The last post in the thread is an example of a HTTP POST of XML content. Are you having problems with it?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.