私は基本的な PHP の知識しかなく、xml の知識はありません。上司から、この Web サービスhttp://xx.xxx.xxx.xx:1000/Service1.asmx?WSDLから GetWesmData を呼び出すように求められました。
幸いなことに、いくつかのグーグル作業を通じて、一連のコードを見つけて動作しました
<?php
$wsdl = "http://10.246.199.35:1000/Service1.asmx?WSDL";
$client = new SoapClient($wsdl);
$stock = "20130528"; //current date
$parameters= array("strDate_YYYYMMDD"=>$stock);
$value = $client->GetWesmData($parameters);
$xml = $value->GetWesmDataResult;
print "<pre>/n";
print_r($xml);
print "</pre>";
?>
出力は次のようになります
/nstdClass Object
(
[WESMclass] => Array
(
[0] => stdClass Object
(
[output] => Success
[STRdata_fld] => 5/24/2013 12:00:00 AM
[STRtime_in_hours] => 1.000
[STRLuzdem_dapel] => 6341.4
[STRLuzdem_rtdel] => 6301.1
[STRLuzdem_rtxel] => 6332.6
[STRLuzwap_dapel] => 6332.6
[STRLuzwap_rtdel] => 3120.23
[STRLuzwap_rtxel] => 2577.72
)
[1] => stdClass Object
(
[output] => Success
[STRdata_fld] => 5/24/2013 12:00:00 AM
[STRtime_in_hours] => 2.000
[STRLuzdem_dapel] => 6130.7
[STRLuzdem_rtdel] => 6094.4
[STRLuzdem_rtxel] => 6107
[STRLuzwap_dapel] => 6107
[STRLuzwap_rtdel] => 3081.99
[STRLuzwap_rtxel] => 2353.18
)
このデータは 23 まで続きます。私の上司が望んでいるのは、php を使用して [STRLuzdem_dapel] の 23 個のデータすべてを折れ線グラフで表示することです。私はワンプサーバーを使用しています。
インターネットで phpgraphlib.php というグラフ作成ライブラリを見つけて使用しました。これで、折れ線グラフ用のこのコードがあり、うまく機能します。
<?php
include('phpgraphlib.php'); //graph library
$graph = new PHPGraphLib(850,400);
$data = array("1"=>6341, "2"=>6130, "3"=>5991, "4"=>5883,
"5"=>5781, "6"=>5631, "7"=>5942, "8"=>6588, "9"=>7146,
"10"=>7486, "11"=>7800, "12"=>7709, "13"=>7719, "14"=>7970,
"15"=>7853, "16"=>7734, "17"=>7420, "18"=>7064, "19"=>7413,
"20"=>7318, "21"=>7289, "22"=>6867, "23"=>6670, );
$graph->addData($data);
$graph->setTitle('STRLuzdem_dapel');
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataPointColor('maroon');
$graph->setDataValues(true);
$graph->setDataValueColor('maroon');
$graph->setGoalLine(0);
$graph->setGoalLineColor('red');
$graph->setXValuesHorizontal(true);
$graph->createGraph();
?>
しかし、ご覧のとおり、手動でデータを入力しました。私がやりたいことは、Web サービスからデータを呼び出し、すべての [STRLuzdem_dapel] の値を取得して、折れ線グラフで表示することです。これは、私が示した 2 つのコード セットの組み合わせのようなものです。私はそれを組み合わせて、いくつかのコード/変数を無駄に変更しようとしました。誰かが私を助けることができますか?ありがとう