php使用curl模拟post请求提交xml (请求的是java服务器上的接口)
但是使用httprequest 在jsp里边请求能够成功
java中这样对post数据做了处理,同样我在php中用过asxml()之后还是不能解决
element r=rootele.element(hmac);
r.settext(signmessage);
result.put(xml,xml);
document.setxmlencoding(gbk);
system.out.println(完整xml请求报文:+document.asxml());
下边是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;
}