xml のこの部分の繰り返し配列を配列として作成する必要がありますが、ご覧のとおり、ここに繰り返し項目があります。
<orderItems>
<OrderItemRequest>
<line_id>int</line_id>
<product_id>string</product_id>
<product_variant_id>string</product_variant_id>
<product_desc>string</product_desc>
<quantity>int</quantity>
<variant_desc>string</variant_desc>
<item_total>decimal</item_total>
</OrderItemRequest>
<OrderItemRequest>
<line_id>int</line_id>
<product_id>string</product_id>
<product_variant_id>string</product_variant_id>
<product_desc>string</product_desc>
<quantity>int</quantity>
<variant_desc>string</variant_desc>
<item_total>decimal</item_total>
</OrderItemRequest>
</orderItems>
これは私がやろうとしたことです:
$orderItemRequest = "";
foreach($requestArray as $array) {
foreach ($array as $key => $val) {
$orderItemRequest .= $comma."<$key>";
foreach ($val as $key2 => $val2) {
$orderItemRequest .= "<$key2>$val2</$key2>";
}
$orderItemRequest .= "</$key>";
}
}
array('carrier_code' => 'UPS',
'dob' => date("Y-m-d", strtotime($dob)),
'creditcard_number' => $CCNumber,
'card_type' => $CCType,
'card_expire_date' => $CCExpireMonth."/".$CCExpireYear,
'CV_Code' => $CCSecurity,
'Customer_Email' => $email,
'orderItems' => $orderItemRequest,
'ChallengeQuestion' => '',
'ChallengeAnswer' => '',
'localeSetting' => '',
'ignoreAddressValidation' => '1',
'auth_code' => '',
'affiliate_code' => '');
の値として xml を直接挿入しようとしましorderItems
たが、エラーが発生しました: nusoap_client: got wsdl error: phpType is struct, but value is not an array: see debug output for details
。
デバッグ情報の最後のビットは次のとおりです。
2013年
-04-27 05:22:42.816864 wsdl: in serializeType: name=orderItems, type=http://phepartnerws/:ArrayOfOrderItemRequest, use=literal, encodingStyle=, unqualified=qualified
value=string(845) "<OrderItemRequest><line_id>0</line_id><product_id>005K</product_id><product_variant_id>005K</product_variant_id><product_desc>TANTRIC AURA MASSAGER</product_desc><variant_desc>TANTRIC AURA MASSAGER</variant_desc><quantity>1</quantity><item_total>24.98</item_total></OrderItemRequest><OrderItemRequest><line_id>1</line_id><product_id>754</product_id><product_variant_id>754</product_variant_id><product_desc>SENSUAL SUBMISSION KIT</product_desc><variant_desc>SENSUAL SUBMISSION KIT</variant_desc><quantity>2</quantity><item_total>31.48</item_total></OrderItemRequest><OrderItemRequest><line_id>2</line_id><product_id>239</product_id><product_variant_id>239</product_variant_id><product_desc>G-SPOT VIBE AND LUBE</product_desc><variant_desc>G-SPOT VIBE AND LUBE</variant_desc><quantity>1</quantity><item_total>14.95</item_total></OrderItemRequest>"
2013-04-27 05:22:42.816888 wsdl: in serializeType: got a prefixed type: ArrayOfOrderItemRequest, http://phepartnerws/
2013-04-27 05:22:42.816904 wsdl: in getTypeDef: type=ArrayOfOrderItemRequest, ns=http://phepartnerws/
2013-04-27 05:22:42.816918 wsdl: in getTypeDef: have schema for namespace http://phepartnerws/
2013-04-27 05:22:42.816937 nusoap_xmlschema: <http://phepartnerws/> in getTypeDef, found complexType ArrayOfOrderItemRequest
2013-04-27 05:22:42.816954 wsdl: in getTypeDef: found type ArrayOfOrderItemRequest
2013-04-27 05:22:42.816968 wsdl: in serializeType: found typeDef
typeDef=array(6) {
["name"]=>
string(23) "ArrayOfOrderItemRequest"
["typeClass"]=>
string(11) "complexType"
["phpType"]=>
string(6) "struct"
["simpleContent"]=>
string(5) "false"
["compositor"]=>
string(8) "sequence"
["elements"]=>
array(1) {
["OrderItemRequest"]=>
array(6) {
["minOccurs"]=>
string(1) "0"
["maxOccurs"]=>
string(9) "unbounded"
["name"]=>
string(16) "OrderItemRequest"
["nillable"]=>
string(4) "true"
["type"]=>
string(37) "http://phepartnerws/:OrderItemRequest"
["form"]=>
string(9) "qualified"
}
}
}
2013-04-27 05:22:42.817006 wsdl: in serializeType: uqType: ArrayOfOrderItemRequest, ns: http://phepartnerws/, phptype: struct, arrayType:
2013-04-27 05:22:42.817022 wsdl: in serializeType: phpType is struct, but value is not an array
2013-04-27 05:22:42.817037 wsdl: in serializeType: returning:
2013-04-27 05:22:42.817058 wsdl: in serializeType: name=CV_Code, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
value=string(3) "123"
2013-04-27 05:22:42.817080 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817095 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
2013-04-27 05:22:42.817115 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817131 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817146 wsdl: in serializeType: returning: <CV_Code>123</CV_Code>
2013-04-27 05:22:42.817166 wsdl: in serializeType: name=ChallengeQuestion, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
value=string(0) ""
2013-04-27 05:22:42.817189 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817203 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
2013-04-27 05:22:42.817222 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817238 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817252 wsdl: in serializeType: returning: <ChallengeQuestion></ChallengeQuestion>
2013-04-27 05:22:42.817273 wsdl: in serializeType: name=ChallengeAnswer, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
value=string(0) ""
2013-04-27 05:22:42.817294 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817309 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
2013-04-27 05:22:42.817328 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817344 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817359 wsdl: in serializeType: returning: <ChallengeAnswer></ChallengeAnswer>
2013-04-27 05:22:42.817382 wsdl: in serializeType: name=localeSetting, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
value=string(0) ""
2013-04-27 05:22:42.817404 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817419 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
2013-04-27 05:22:42.817438 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817454 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817469 wsdl: in serializeType: returning: <localeSetting></localeSetting>
2013-04-27 05:22:42.817492 wsdl: in serializeType: name=ignoreAddressValidation, type=http://www.w3.org/2001/XMLSchema:boolean, use=literal, encodingStyle=, unqualified=qualified
value=string(1) "1"
2013-04-27 05:22:42.817514 wsdl: in serializeType: got a prefixed type: boolean, http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817529 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
2013-04-27 05:22:42.817546 wsdl: in getTypeDef: type=boolean, ns=http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817561 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817576 wsdl: in serializeType: returning: <ignoreAddressValidation>true</ignoreAddressValidation>
2013-04-27 05:22:42.817596 wsdl: in serializeType: name=auth_code, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
value=string(0) ""
2013-04-27 05:22:42.817618 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817633 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
2013-04-27 05:22:42.817651 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817667 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817681 wsdl: in serializeType: returning: <auth_code></auth_code>
2013-04-27 05:22:42.817702 wsdl: in serializeType: name=affiliate_code, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
value=string(0) ""
2013-04-27 05:22:42.817723 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817738 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
2013-04-27 05:22:42.817757 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817773 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
2013-04-27 05:22:42.817787 wsdl: in serializeType: returning: <affiliate_code></affiliate_code>
2013-04-27 05:22:42.817805 wsdl: in serializeType: returning: <oOrderRequest><RequestCredentials><CallerID>livereps</CallerID><Timestamp>2013-04-27T01:22:42-04:00</Timestamp><Token>1/kUrVDZmoYqbj1/PhCE4w==</Token></RequestCredentials><company></company><xml></xml><partnerID>livereps</partnerID><sourceCode></sourceCode><item_total>102.89</item_total><amount_total>122.89</amount_total><amount_tax>6.69</amount_tax><shipping_charge>20.00</shipping_charge><shipping_total>20.00</shipping_total><shipping_allowance>0</shipping_allowance><amount_ins>0</amount_ins><order_create_date>2013-04-27</order_create_date><amount_disc></amount_disc><bfirst>James</bfirst><blast>James</blast><baddr1>Jewell</baddr1><baddr2></baddr2><bcity>Cincinnati</bcity><bstate>OH</bstate><bcountry>US</bcountry><bzip>45255</bzip><sfirst>James</sfirst><slast>James</slast><saddr1>Jewell</saddr1><saddr2></saddr2><scity>Cincinnati</scity><sstate>OH</sstate><scountry>US</scountry><szip>45255</szip><carrier_code>UPS</carrier_code><dob>1970-01-01</dob><creditcard_number>5434651900577797</creditcard_number><card_type>M</card_type><card_expire_date>01/14</card_expire_date><Customer_Email>jamesnjewell@yahoo.com</Customer_Email><CV_Code>123</CV_Code><ChallengeQuestion></ChallengeQuestion><ChallengeAnswer></ChallengeAnswer><localeSetting></localeSetting><ignoreAddressValidation>true</ignoreAddressValidation><auth_code></auth_code><affiliate_code></affiliate_code></oOrderRequest>
2013-04-27 05:22:42.817823 wsdl: in serializeType: returning: <CreateOrder xmlns="http://phepartnerws/"><oOrderRequest><RequestCredentials><CallerID>livereps</CallerID><Timestamp>2013-04-27T01:22:42-04:00</Timestamp><Token>1/kUrVDZmoYqbj1/PhCE4w==</Token></RequestCredentials><company></company><xml></xml><partnerID>livereps</partnerID><sourceCode></sourceCode><item_total>102.89</item_total><amount_total>122.89</amount_total><amount_tax>6.69</amount_tax><shipping_charge>20.00</shipping_charge><shipping_total>20.00</shipping_total><shipping_allowance>0</shipping_allowance><amount_ins>0</amount_ins><order_create_date>2013-04-27</order_create_date><amount_disc></amount_disc><bfirst>James</bfirst><blast>James</blast><baddr1>Jewell</baddr1><baddr2></baddr2><bcity>Cincinnati</bcity><bstate>OH</bstate><bcountry>US</bcountry><bzip>45255</bzip><sfirst>James</sfirst><slast>James</slast><saddr1>Jewell</saddr1><saddr2></saddr2><scity>Cincinnati</scity><sstate>OH</sstate><scountry>US</scountry><szip>45255</szip><carrier_code>UPS</carrier_code><dob>1970-01-01</dob><creditcard_number>5434651900577797</creditcard_number><card_type>M</card_type><card_expire_date>01/14</card_expire_date><Customer_Email>jamesnjewell@yahoo.com</Customer_Email><CV_Code>123</CV_Code><ChallengeQuestion></ChallengeQuestion><ChallengeAnswer></ChallengeAnswer><localeSetting></localeSetting><ignoreAddressValidation>true</ignoreAddressValidation><auth_code></auth_code><affiliate_code></affiliate_code></oOrderRequest></CreateOrder>
2013-04-27 05:22:42.817840 wsdl: serializeRPCParameters returning: <CreateOrder xmlns="http://phepartnerws/"><oOrderRequest><RequestCredentials><CallerID>livereps</CallerID><Timestamp>2013-04-27T01:22:42-04:00</Timestamp><Token>1/kUrVDZmoYqbj1/PhCE4w==</Token></RequestCredentials><company></company><xml></xml><partnerID>livereps</partnerID><sourceCode></sourceCode><item_total>102.89</item_total><amount_total>122.89</amount_total><amount_tax>6.69</amount_tax><shipping_charge>20.00</shipping_charge><shipping_total>20.00</shipping_total><shipping_allowance>0</shipping_allowance><amount_ins>0</amount_ins><order_create_date>2013-04-27</order_create_date><amount_disc></amount_disc><bfirst>James</bfirst><blast>James</blast><baddr1>Jewell</baddr1><baddr2></baddr2><bcity>Cincinnati</bcity><bstate>OH</bstate><bcountry>US</bcountry><bzip>45255</bzip><sfirst>James</sfirst><slast>James</slast><saddr1>Jewell</saddr1><saddr2></saddr2><scity>Cincinnati</scity><sstate>OH</sstate><scountry>US</scountry><szip>45255</szip><carrier_code>UPS</carrier_code><dob>1970-01-01</dob><creditcard_number>5434651900577797</creditcard_number><card_type>M</card_type><card_expire_date>01/14</card_expire_date><Customer_Email>jamesnjewell@yahoo.com</Customer_Email><CV_Code>123</CV_Code><ChallengeQuestion></ChallengeQuestion><ChallengeAnswer></ChallengeAnswer><localeSetting></localeSetting><ignoreAddressValidation>true</ignoreAddressValidation><auth_code></auth_code><affiliate_code></affiliate_code></oOrderRequest></CreateOrder>
2013-04-27 05:22:42.817889 nusoap_client: got wsdl error: phpType is struct, but value is not an array: see debug output for details
私はまだsoap/nusoapの使用にかなり慣れていませんが、エラーは私が直接渡しているxml値であると信じています. 行を削除すると'orderItems' => $orderItemRequest,
、エラーは発生しません。同じキーを持つ複数の配列を同じ配列に入れる方法はありますか?