How PHP sends XML messages
POST
http/1.0
User-agent:
Content-type:application/x-fox
content-length:nnnn
...
Now to send the XML data in the format above, try curl but not successful, everybody help
------Solution--------------------
Curl is possible, but the parameter settings are cumbersome. This situation has some out-of-the-box class library implementations that provide a simple example
if ($_server[' request_method ' = = = = ' POST ') {
Receive
$content = file_get_contents (' php://input ');
$xml = simplexml_load_string ($content);
echo "Response from the XML receiver \ n";
Print_r (Get_object_vars ($xml));
Exit
}
Send behavior
$xml = <<
<>
World
xml
$setting = Array (
' http ' = = Array (
' Method ' = ' POST ',
' User_agent ' = '
,
' Header ' = ' content-type:application/x-www-form-urlencoded ',
' Content ' = $xml
)
);
$context = Stream_context_create ($setting);
$url = ' http://localhost/'. $_server[' Request_uri '];
$response = file_get_contents ($url, NULL, $context);
Echo $response;
To illustrate your HTTP request example, the request content entity and header need to be separated by two groups \ r \ n. In addition, your XML file format is incorrect, and the tag attribute also contains the full-width symbol