APIを経由してシステムにデータを登録したいと思っています。
APIのスキーマは下記のとおりです。(主要部分のみ)
xml
1<complexType name="ConstructionTarget"> 2 <sequence> 3 <element name="hostName" nillable="true" type="soapenc:string"/> 4 <element name="interfaceName" nillable="true" type="soapenc:string"/> 5 <element name="ipAddress" nillable="true" type="soapenc:string"/> 6 <element name="portNumber" nillable="true" type="soapenc:string"/> 7 <element name="slotNumber" nillable="true" type="soapenc:string"/> 8 </sequence> 9</complexType> 10 11<complexType name="ArrayOfConstructionTarget"> 12 <complexContent> 13 <restriction base="soapenc:Array"> 14 <attribute ref="soapenc:arrayType" wsdl:arrayType="impl:ConstructionTarget[]"/> 15 </restriction> 16 </complexContent> 17</complexType> 18 19<complexType name="Construction"> 20 <sequence> 21 <element name="constructionTargets" nillable="true" type="impl:ArrayOfConstructionTarget"/> 22 <element name="constructionType" type="xsd:int"/> 23 <element name="name" nillable="true" type="soapenc:string"/> 24 <element name="startTime" nillable="true" type="xsd:dateTime"/> 25 <element name="endTime" nillable="true" type="xsd:dateTime"/> 26 </sequence> 27</complexType>
これに対して下記のスクリプトでデータを登録しようとしたところ、うまくいきました。
PHP
1<?php 2$cctServer = "xxx.xxx.xxx.xxx:8080"; 3$cctFlow = "/cct/services/Constructions"; 4$cctWSDL = sprintf("http://".$cctServer.$cctFlow."?wsdl"); 5 6$soap_param = array( 7 'Construction' => array( 8 'constructionTargets' => '', 9 'constructionType' => '3', 10 'name' => 'testname1111', 11 'startTime' => '2018-07-06T15:10:00.000Z' 12 'endTime' => '2018-07-06T18:30:00.000Z' 13 ) 14); 15 16try{ 17 $client = new SoapClient($cctWSDL, array('trace' => 1, 'cache_wsdl' => WSDL_CACHE_NONE)); 18 $result = $client->__soapCall("put", $soap_param); 19} catch (Exception $e) { 20 echo $e; 21 die(); 22} 23 24die();
しかし、実際には'constructionTargets'のところは配列になっており、
hostName、interfaceNameなどのデータを配列で指定しなければなりません。
そこで下記のように指定したのですが、うまくいきません。
PHP
1$soap_param = array( 2 'Construction' => array( 3 'ConstructionTarget' => array( 4 'hostName' => 'testhost2222', 5 'interfaceName' => 'intf3333', 6 'ipAddress' => '192.168.1.1', 7 'portNumber' => '7', 8 'slotNumber' => '8' 9 ), 10 'constructionType' => '3', 11 'name' => 'testname1111', 12 'startTime' => '2018-07-06T15:10:00.000Z' 13 'endTime' => '2018-07-06T18:30:00.000Z' 14 ) 15);
'ConstructionTarget'を'constructionTargets'にしてもNGでした。
配列をどのように指定したら、うまくいくのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。