2013-06-29 4 views
0

nuSOAP을 사용하여 PHP로 웹 서비스를하고 있습니다. webservice는 객체 배열을 반환합니다. 호출이 thingArray에 일 [] 변환 할 수 없습니다 불평 할 때 WCF에서 호출 할 수있는 배열을 반환하는 PHP의 nuSoap에 웹 서비스를 만들려면 어떻게해야합니까?

$server->wsdl->addComplexType(
    "thingArray",   // type name 
    "complexType",  // soap type 
    'array',    // php type (struct/array) 
    'sequence',   // composition (all/sequence/choice) 
    '',     // base restriction 
    array(    // elements 
     'item' => array(
      'name' => 'item', 
      'type' => 'tns:thing', 
      'minOccurs' => '0', 
      'maxOccurs' => 'unbounded' 
     ) 
    ), 
    array(),    // attributes 
    "tns:thing"   // array type 
); 

WCF 클라이언트를 사용하여 실패합니다.

답변

0

먼저 WCF가 응답을 이해할 수 있도록 UTF8을 켜야합니다.

// Configure UTF8 so that WCF will be happy 
    $server->soap_defencoding='UTF-8'; 
    $server->decode_utf8=false; 

WCF가 배열을 이해하게하려면 시퀀스 구성보다는 배열에 SOAP 인코딩을 사용해야합니다.

이 WCF 소비 할 수있는 배열을 방출 nuSOAP 것 :

$server->wsdl->addComplexType(
     'thingArray',   // type name 
     'complexType',   // Soap type 
     'array',    // PHP type (struct, array) 
     '',     // composition 
     'SOAP-ENC:Array',  // base restriction 
     array(),    // elements 
     array(    // attributes 
     array(
      'ref'=>'SOAP-ENC:arrayType', 
      'wsdl:arrayType'=>'tns:thing[]' 
     ) 
    ),  // attribs 
     "tns:thing"  // arrayType 
); 

이 타입은 현재 대응 사용될 수 있고 WCF 클라이언트 게 nuSOAP가 생성하는 SOAP 응답을 소비한다.

var client = new Svc.servicePortTypeClient(); 
    thing[] things = new thing[3]; 
    thing[] result = client.serviceMethod(things); 
    foreach(thing x in result) 
    { ... do something with x ... } 
:

// Register the method to expose 
    $server->register('serviceMethod',   // method name 
     array('param1' => 'tns:thingArray'),  // input parameters 
     array('return' => 'tns:thingArray'),  // output parameters 
     $ns,          // namespace 
     $ns.'#serviceMethod',     // soapaction 
     'rpc',         // style 
     'encoded',        // use 
     'Says hello'        // documentation 
); 

WCF 클라이언트는 다음과 같이 찾고 끝