쓰고있는 것을 proxy이라고합니다.
addComplexType
방법을 통해 복잡한 유형을 보내는 NuSoap 서버용 온라인은 some examples입니다.
//Create a complex type
$server->wsdl->addComplexType('MyComplexType','complexType','struct','all','',
array('ID' => array('name' => 'ID','type' => 'xsd:int'),
'YourName' => array('name' => 'YourName','type' => 'xsd:string')));
한 프록시를 구현하는 방법은 실제로 처음 백엔드 서비스 얘기하지 않도록 밖으로 스텁 데이터와 서비스를 구축 할 수 있습니다. 프록시의 고의적 인 응답에 만족하는 원본 클라이언트를 얻을 수 있는지 확인하십시오. 그렇다면 일단 실제 백엔드 서비스를 사용하는 것은 간단해야합니다 (SOAP 클라이언트 작업은 내 경험에서 서버 작업보다 쉽습니다).
또 다른 대안은 네이티브 SoapServer 클래스를 고려하는 것입니다. 첫 번째 주석 here은 복잡한 유형을 만드는 방법을 보여줍니다.
편집
보다 조금 둘러보고 후, 여기에 much better example이다.
addComplextType
(lib 디렉토리/class.wsdl.php)에 docblock 당 NuSoap와 복잡한 유형을 등록하는 두 가지 방법,
/**
* adds an XML Schema complex type to the WSDL types
*
* @param string $name
* @param string $typeClass (complexType|simpleType|attribute)
* @param string $phpType currently supported are array and struct (php assoc array)
* @param string $compositor (all|sequence|choice)
* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
* @param array $elements e.g. array (name => array(name=>'',type=>''))
* @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
* @param string $arrayType as namespace:name (xsd:string)
* @see nusoap_xmlschema
* @access public
*/
그는 내가 게시 된 이후 예에 어떻게하는지보기가 있습니다
은
function updateContact($in_contact) {
$contact = new Contact($in_contact['id']);
$contact->first_name=mysql_real_escape_string($in_contact['first_name']);
$contact->last_name=mysql_real_escape_string($in_contact['last_name']);
$contact->email=mysql_real_escape_string($in_contact['email']);
$contact->phone_number=mysql_real_escape_string($in_contact['phone_number']);
if ($contact->update()) return true;
}
다음
연락 복합 형식으로 응답을 반환하는 방법을 다음
$server->wsdl->addComplexType('Contact',
'complexType',
'struct',
'all',
'',
array(
'id' => array('name' => 'id', 'type' => 'xsd:int'),
'first_name' => array('name' => 'first_name', 'type' => 'xsd:string'),
'last_name' => array('name' => 'last_name', 'type' => 'xsd:string'),
'email' => array('name' => 'email', 'type' => 'xsd:string'),
'phone_number' => array('name' => 'phone_number', 'type' => 'xsd:string')
)
);
그의 예제에서 배열 변형을 사용하는 방법을 볼 수도 있습니다. 거 대 한 대답에 대 한 미안 해요!
스텁 데이터와 관련하여 응답 해 주셔서 감사합니다. Google은 항상 서버에서 최신 응답을 보내려고합니다. 즉, 공급 업체 API가 변경되었거나 다른 출력을 제공하더라도 API는 동일한 실시간을 반영해야합니다. 따라서 스텁 된 데이터는이 상황에서 사용하기 어려울 수 있습니다. nusoap의 complextype 예제에서 서버에서 오는 개체를 구문 분석 한 다음 배열에서 다시 할당하여 복합 형식을 작성해야합니까? 또한 내 API에서 메서드 내에서 complextype을 만들거나 메서드 외부에 있어야합니까? – Ricky
아, 구현하는 데 다소 고통 스러울 수 있지만 스텁 된 데이터에 대해 들었습니다. 복합 유형의 경우 복합 유형을 등록하려는 경우 요청을 처리하는 메소드 (위의 두 번째 예에서'updateContact')에서 클라이언트는'soapclient'를 사용하여 백엔드 서비스에 연결하려고합니다. 그것으로부터 응답을 파싱하고,'addComplexType'에'struct' 또는'array' 옵션을 기반으로 객체 또는 배열을 생성 한 다음 핸들러에서 반환합니다. – quickshiftin