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=' $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; } |