2011-11-18 3 views
1

PHP에서 비누 서비스를 구축하려고합니다. WSDL은 Visual Studio 2010에서 자동 생성되었습니다 (Visual Studio를 사용하여 WSDL을 작성했습니다. 실제 서버는 SoapServer가있는 PHP로 작성되었습니다). 비누 서비스에 대한 요청이 처리되고 있지만 문자열 배열을 반환하려고 시도하면 클라이언트가 결과를 다시 얻지 못합니다.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의 서버 코드는 다음과 같다 : 다음은 WSDL의 관련 섹션 인 PHP 기능 getgroups에서

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()); 
} 

나는 또한 단지 배열을 반환 시도 ('안녕하세요') 기능이 있지만 작동하지 않습니다. 누군가 내 WSDL 정의와 일치하는 문자열 배열을 반환하는 PHP 코드를 수정하도록 도울 수 있습니까?

답변

1

는 복합 타입의 이런 종류의 작동 :

ini_set("soap.wsdl_cache_enabled", "0"); 

또는 결과를 예측할 수 : server.php 내부

<s:complexType name="ArrayOfString2"> 
    <complexContent> 
     <restriction base="SOAP-ENC:Array"> 
     <attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="string[]"/> 
     </restriction> 
    </complexContent> 
</s:complexType> 
. 
. 
<wsdl:message name="getGroupsSoapOut"> 
    <wsdl:part name="parameters" type="tns:ArrayOfString2" /> 
</wsdl:message> 

이 줄을 추가 때로는 매우 중요합니다.