Sonos' Music API (SMAPI)에 대한 서비스를 구축 중입니다.PHP의 SOAP 라이브러리를 사용하여 SoapFault의 세부 구역에 사용자 지정 요소를 추가하는 방법
throw new SoapFault('Client.NOT_LINKED_RETRY', 'Link Code not found retry...');
그러나 때 나는 PHP SOAP library하고, 상기 응답 나는이 같은 SoapFault
을 던지는 시도를 사용하여 내 서비스를 구축하고
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>Client.NOT_LINKED_RETRY</faultcode>
<faultstring>Link Code not found retry...</faultstring>
<detail>
<ExceptionInfo>NOT_LINKED_RETRY</ExceptionInfo>
<SonosError>5</SonosError>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
: 가끔 다음과 같은 형식의 응답을 다시 전송해야 더 ExceptionInfo
그이 없음을
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>Client.NOT_LINKED_RETRY</faultcode>
<faultstring>Link Code not found retry...</faultstring>
<detail>
<SonosError/>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
주의 사항 :이처럼 다시 전송 보인다되는이 응답을 시도이 비어 있습니다. ExceptionInfo
및 SonosError
을 SoapFault
을 사용하여 설정할 수 있습니까? 나는 모든 종류의 것들을했지만, 내가 지금이 일을하고 주위에 그렇게 작품으로, 작업을 가져올 수 없습니다 : 그것은 관련이 있지만, WSDL은 here을 찾을 수 있습니다
http_response_code(500);
header("Content-type: text/xml");
$ret = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$ret .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">';
$ret .= '<SOAP-ENV:Body>';
$ret .= '<SOAP-ENV:Fault>';
$ret .= '<faultcode>Client.NOT_LINKED_RETRY</faultcode>';
$ret .= '<faultstring>Link Code not found retry...</faultstring>';
$ret .= '<detail>';
$ret .= '<ExceptionInfo>NOT_LINKED_RETRY</ExceptionInfo>';
$ret .= '<SonosError>5</SonosError>';
$ret .= '</detail>';
$ret .= '</SOAP-ENV:Fault>';
$ret .= '</SOAP-ENV:Body>';
$ret .= '</SOAP-ENV:Envelope>'."\n";
echo $ret; exit;
확실하지합니다. 나는이 같은 아래의 제안하려고 할 때 :
업데이트
$detail = new StdClass();
$detail->SonosError = 5;
$detail->ExceptionInfo = 'NOT_LINKED_RETRY';
throw new SoapFault(
'Client.NOT_LINKED_RETRY',
'Link Code not found retry...',
NULL,
$detail
);
를 내가 얻을 :
<detail>
<customFault>
<SonosError>5</SonosError>
<ExceptionInfo>NOT_LINKED_RETRY</ExceptionInfo>
</customFault>
</detail>
이 내가 <customFault>
태그를 제외하고, 필요가 거의 것입니다. 그것을 없애는 방법이 SonosError
과 ExceptionInfo
에 <detail>
에 직접 있습니까?
처럼된다? – alkis