Php uses curl to simulate post request to submit xml

Source: Internet
Author: User
Php uses curl to simulate post request to submit xml
Php uses curl to simulate the xml submission of post requests (the interface on the Java server is requested)
However, the request using httprequest in jsp can be successful.
In JAVA, post data is processed in this way. After I use asXML () in php, it still cannot be solved.
Element r = rootEle. element ("hmac ");
R. setText (signMessage );
Result. put ("xml", xml );
Document. setXMLEncoding ("GBK ");
System. out. println ("complete xml request message:" + document. asXML ());


Below is the php
Public function test (){
$ TestHost = 'http: // 127.0.0.1: 8080'
$ Data =' George John Reminder Don't forget the meeting! ';
$ Response = $ this-> sendPost ($ textHost, $ data );
Echo ($ response );

}
Protected function sendPost ($ url, $ data ){
$ Curl = curl_init ();
Curl_setopt ($ curl, CURLOPT_URL, $ url );
Curl_setopt ($ curl, CURLOPT_SSL_VERIFYPEER, FALSE );
Curl_setopt ($ curl, CURLOPT_SSL_VERIFYHOST, FALSE );
If (! Empty ($ data )){
Curl_setopt ($ curl, CURLOPT_POST, 1 );
Curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ data );
}
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
$ Output = curl_exec ($ curl );
Curl_close ($ curl );
Return $ output;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.