Skip to content

Commit

Permalink
Create webservice01
Browse files Browse the repository at this point in the history
  • Loading branch information
miscsstake committed Sep 20, 2014
1 parent 701597c commit 7f397dd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions webservice01
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
$data = sprintf('<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getWeatherbyCityName xmlns="http://WebXml.com.cn/">
<theCityName>%s</theCityName>
</getWeatherbyCityName>
</soap:Body>
</soap:Envelope>','北京');
$curlobj = curl_init();
curl_setopt($curlobj, CURLOPT_URL, "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
curl_setopt($curlobj, CURLOPT_POST, 1);
curl_setopt($curlobj, CURLOPT_HEADER, 0);
curl_setopt($curlobj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlobj, CURLOPT_POSTFIELDS, $data);
curl_setopt($curlobj, CURLOPT_HTTPHEADER, array("Content-Type: application/soap+xml; charset=utf-8",
"Content-length: ".strlen($data),
"SOAPAction:\"http://WebXml.com.cn/getWeatherbyCityName\""));
$rtn = curl_exec($curlobj);
if(!curl_errno($curlobj)){
$info = curl_getinfo($curlobj);
print_r($info);
echo "RETURN: " . $rtn;
} else {
echo 'Curl error: ' . curl_error($curlobj);
}
curl_close($curlobj);
?>

0 comments on commit 7f397dd

Please sign in to comment.