私は何もしていないので、私はそれを試してみて、それを理解しました。私は間違った順序でほとんどの正しい要素を持っていました。
私のWSDLは変わっていませんでしたが、変更する必要はありませんでした。私の最初のXSDでは、私はこれに私の出力要素を変更:
<xs:element name="GetDictionaryResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="GetDictionaryResult" nillable="true" type="q2:DictionaryResponse" xmlns:q2="http://reachchallenges.infectionist.com/api/" />
</xs:sequence>
</xs:complexType>
</xs:element>
基本的に私は、第二のXSDからGetDictionaryResultという名前DictionaryResponseオブジェクトを返すよ、DictionaryResponseはGetDictionaryResponseオブジェクトに包まれています。
<xs:complexType name="DictionaryResponse">
<xs:sequence>
<xs:element minOccurs="0" name="status" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="Data" type="tns:ArrayOfKeyValueOfintComment" />
</xs:sequence>
</xs:complexType>
<xs:element name="DictionaryResponse" nillable="true" type="tns:DictionaryResponse" />
<xs:complexType name="ArrayOfKeyValueOfintComment">
<xs:annotation>
<xs:appinfo>
<IsDictionary xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsDictionary>
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="ArrayOfKeyValueOfintComment">
<xs:complexType>
<xs:sequence>
<xs:element name="Key" type="xs:int" />
<xs:element name="Value" nillable="true" type="tns:Comment" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="ArrayOfKeyValueOfintComment" nillable="true" type="tns:ArrayOfKeyValueOfintComment" />
DictionaryResponseオブジェクトは、私が唯一のテストとしてそこに置く「ステータス」と呼ばれる文字列を、含まれています。私の第二XSDは、私が間違って行っていたところ、SOAPは紛らわしいですが、私は、これらの要素になってしまったでした。また、無限のArrayOfKeyValueOfintCommentオブジェクトも含まれています。これは、マジックが起こる場所です。最後に、PHP自体:
class GetDictionaryResponse {
var $GetDictionaryResult;
function GetDictionaryResponse() {
$this->GetDictionaryResult = new GetDictionaryResult();
}
}
class GetDictionaryResult {
var $status;
var $Data;
function GetDictionaryResult() {
$this->status = (string)"Ok";
}
function AddItem($k, $v) {
$d = new ArrayOfKeyValueOfintComment($k, $v);
$this->Data[] = $d;
}
}
class ArrayOfKeyValueOfintComment {
var $Key, $Value;
function ArrayOfKeyValueOfintComment($k, $v) {
$this->Key = $k;
$this->Value = $v;
}
}
function GetDictionary() {
$ret = new GetDictionaryResponse();
for($i = 0; $i < 3; $i++) {
$c = new Comment(array([comment elements]));
$ret->GetDictionaryResult->AddItem($i, $c);
}
return $ret;
}
うまくいけばあまり混乱しないように見えます。基本的にリターンは次のようになります。
GetDictionaryResponse->
GetDictionaryResult->
string status;
Dictionary<int, Comment> Data;
私はネットでそれを消費し、このようにそれから有効な辞書を取得することができます。
DictionaryResponse R = client.GetDictionary(); コメントc = r.Data [0];
今後の読者を支援してくれたらと思っています。