1
我想在PHP中構建一個soap服務。我用於webservice的WSDL是由Visual Studio 2010自動生成的(我剛剛使用Visual Studio創建了WSDL,實際的服務器是使用SoapServer在PHP中構建的)。正在處理對soap服務的請求,但是當我嘗試返回一個字符串數組時,客戶端沒有收到任何結果。這裏是WSDL的相關章節:從PHP SoapServer返回一個字符串數組
<s:element name="getGroups">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="code" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getGroupsResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="getGroupsResult" type="tns:ArrayOfString" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfString">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
</s:sequence>
</s:complexType>
.
.
<wsdl:message name="getGroupsSoapIn">
<wsdl:part name="parameters" element="tns:getGroups" />
</wsdl:message>
<wsdl:message name="getGroupsSoapOut">
<wsdl:part name="parameters" element="tns:getGroupsResponse" />
</wsdl:message>
.
.
<wsdl:operation name="getGroups">
<wsdl:input message="tns:getGroupsSoapIn" />
<wsdl:output message="tns:getGroupsSoapOut" />
</wsdl:operation>
PHP服務器的代碼如下:
function getGroups($args)
{
return array('ArrayOfString' => array('hello world'));
}
$server = new SoapServer('admin.wsdl');
$server->addFunction('getGroups');
try {
$server->handle();
}
catch (Exception $e) {
$server->fault('Sender', $e->getMessage());
}
我也試過,只返回陣列( '世界你好')從PHP getGroups功能,但也沒有工作。有人可以幫我糾正PHP代碼,以返回一個匹配我的WSDL定義的字符串數組。