本文整理汇总了PHP中RPC::encodeResponseForSuccess方法的典型用法代码示例。如果您正苦于以下问题:PHP RPC::encodeResponseForSuccess方法的具体用法?PHP RPC::encodeResponseForSuccess怎么用?PHP RPC::encodeResponseForSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RPC
的用法示例。
在下文中一共展示了RPC::encodeResponseForSuccess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invokeAndEncodeResponse
/**
* Returns a string that encodes the result of calling a service method, which
* could be the value returned by the method or an exception thrown by it.
*
* <p>
* If the serializationPolicy parameter is not <code>null</code>, it is
* used to determine what types can be encoded as part of this response. If
* this parameter is <code>null</code>, then only subtypes of
* {@link com.google.gwt.user.client.rpc.IsSerializable IsSerializable} or
* types which have custom field serializers may be encoded.
* </p>
*
* <p>
* This method does no security checking; security checking must be done on
* the method prior to this invocation.
* </p>
*
* @param Object $target instance on which to invoke the serviceMethod
* @param MappedMethod $serviceMethod the method to invoke
* @param array $args arguments used for the method invocation
* @param SerializationPolicy $serializationPolicy determines the serialization policy to be used
* @return strinta string which encodes either the method's return or a checked
* exception thrown by the method
*
* @throws NullPointerException if the serviceMethod or the
* serializationPolicy are <code>null</code>
* @throws SecurityException if the method cannot be accessed or if the number
* or type of actual and formal arguments differ
* @throws SerializationException if an object could not be serialized by the
* stream
* @throws UnexpectedException if the serviceMethod throws a checked exception
* that is not declared in its signature
*/
public static function invokeAndEncodeResponse($target, MappedMethod $serviceMethod, $args, SerializationPolicy $serializationPolicy, MappedClassLoader $mappedClassLoader)
{
//Object $target,
//ReflectionMethod $serviceMethod, array $args,
//SerializationPolicy $serializationPolicy
if ($serviceMethod === null) {
throw new NullPointerException("Not found matches serviceMethod (TIP: did you map your service method correctly?");
}
if ($serializationPolicy === null) {
throw new NullPointerException("serializationPolicy");
}
/*String*/
$responsePayload = '';
try {
/*Object*/
$result = $serviceMethod->invoke($target, $args);
$responsePayload = RPC::encodeResponseForSuccess($serviceMethod, $result, $serializationPolicy, $mappedClassLoader);
//} catch (IllegalAccessException $xe) {
// SecurityException securityException = new SecurityException(
// formatIllegalAccessErrorMessage(target, serviceMethod));
// securityException.initCause(e);
// throw securityException;
// } catch (IllegalArgumentException e) {
// SecurityException securityException = new SecurityException(
// formatIllegalArgumentErrorMessage(target, serviceMethod, args));
// securityException.initCause(e);
// throw securityException;
} catch (Exception $ex) {
// // Try to encode the caught exception
// //
// Throwable cause = e.getCause();
//
$responsePayload = RPC::encodeResponseForFailure($serviceMethod, $ex, $serializationPolicy, $mappedClassLoader);
}
return $responsePayload;
//}
//catch (Exception $ex) {
//print_r($ex) ;
//}
}