私はPHPのSoapServerを使用しています。同じタイプの複数の項目を含めるようにします。このセクションのwsdlは次のようになります。 PHPでPHPを使用してSOAPレスポンスに同じタイプの複数のオブジェクトを含める方法
<xsd:element name="getSalesTaxResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="totalTaxAmount" type="xsd:string"></xsd:element>
<xsd:element maxOccurs="unbounded" minOccurs="1" name="productTax" type="tns:getSalesTaxResultInformation" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="getSalesTaxResultInformation">
<xsd:annotation>
<xsd:documentation>This object stores information related to product tax request
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="productId" type="xsd:string"></xsd:element>
<xsd:element name="productNRCPrice" type="xsd:string"></xsd:element>
<xsd:element name="taxAmount" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
私の脳が滞っていると私は私の人生のために応じて、複数の「productTax」レコードを含める方法を見つけ出すことはできません。私は現在これをやっていますが、私がしたいことはしません。
$this->response = new GetSalesTaxResponse();
$this->response->totalTaxAmount = '21.93';
$this->response->productTax = array(
(object) array(
'productId'=>'3123',
'productNRCPrice'=>'201.20',
'taxAmount'=>'10.10'),
(object) array('productId'=>'2103',
'productNRCPrice'=>'102.10',
'taxAmount'=>'11.83')
);
file_put_contents('/tmp/burp', print_r($this->response, TRUE), FILE_APPEND);
return $this->response->getSoapVar();
しかし、SOAP-UIではこれが表示されます。私はPHPでやっているものに基づいて理にかなっているが、どのように私は、代わりにこのように見えるようにPHPでの応答を構築するん
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.example.com/SOAP/Billing">
<SOAP-ENV:Body>
<ns1:getSalesTaxResponse>
<totalTaxAmount>21.93</totalTaxAmount>
<productTax>
<SOAP-ENC:Struct>
<productId>3123</productId>
<productNRCPrice>201.20</productNRCPrice>
<taxAmount>10.10</taxAmount>
</SOAP-ENC:Struct>
<SOAP-ENC:Struct>
<productId>2103</productId>
<productNRCPrice>102.10</productNRCPrice>
<taxAmount>11.83</taxAmount>
</SOAP-ENC:Struct>
</productTax>
</ns1:getSalesTaxResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
?
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.example.com/SOAP/Billing">
<SOAP-ENV:Body>
<ns1:getSalesTaxResponse>
<totalTaxAmount>21.93</totalTaxAmount>
<productTax>
<productId>3123</productId>
<productNRCPrice>201.20</productNRCPrice>
<taxAmount>10.10</taxAmount>
</productTax>
<productTax>
<productId>2103</productId>
<productNRCPrice>102.10</productNRCPrice>
<taxAmount>11.83</taxAmount>
</productTax>
</ns1:getSalesTaxResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
、しかし:Rの配列データは、のSoapServerは、右の配列要素の型が見つからない場合は、
getSalesTaxResultInformation
に自分自身を各productTax
行をキャストする必要があります、基本的にマップです検証エラーが発生しました。 src-resolve.4.2:コンポーネント 'soapenc:Array'の解決でエラーが発生しました。 'soapenc:Array'は 'http://schemas.xmlsoap.org/soap/encoding/'という名前空間にありますが、この名前空間のコンポーネントはスキーマ文書から参照できません。これを定義に追加しました:xmlns:soapenc = "http://schemas.xmlsoap.org/soap/encoding/" – Halfstop