/* * Copyright 2005,2008 WSO2, Inc. http://wso2.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function echoFunction($inMessage) { $returnMessage = new WSMessage($inMessage->str); return $returnMessage; } $cert = ws_get_cert_from_file("../../keys/bob_cert.cert"); $pvt_key = ws_get_key_from_file("../../keys/bob_key.pem"); $operations = array("echoString" => "echoFunction"); $policy_xml = file_get_contents("policy.xml"); $policy = new WSPolicy($policy_xml); $sec_token = new WSSecurityToken(array("privateKey" => $pvt_key, "certificate" => $cert)); $actions = array("http://wso2.org/wsfphp/samples/echoString" => "echoString"); $svr = new WSService(array("operations" => $operations, "actions" => $actions, "policy" => $policy, "securityToken" => $sec_token)); $svr->reply();
* @var array of string $boo2 * maps to xs:duration */ public $boo2; } /** * classname FooResponse * @namespace http://mytest/xsd3 */ class FooResponse { /** * @var array of object Boo $ret_value */ public $ret_value; public function __construct($param_value) { $this->ret_value = $param_value; } } $operations = array("echoString" => "echoValue"); $opParams = array("echoValue" => "MIXED"); $actions = array("urn:echoString" => "echoString"); $classmap = array("Foo" => "Foo", "Bay" => "Bay"); // Security options $policy_xml = file_get_contents("policy.xml"); $policy = new WSPolicy($policy_xml); $security_token = new WSSecurityToken(array("user" => "Alice", "password" => "abcd!123", "passwordType" => "Digest")); $service = new WSService(array("classes" => array("Bar" => array("operations" => $operations, "args" => array("Welcome", "Bye!"))), "bindingStyle" => "doclit", "cacheWSDL" => FALSE, "useWSA" => TRUE, "policy" => $policy, "securityToken" => $security_token, "actions" => $actions, "classmap" => $classmap, "opParams" => $opParams)); $service->reply();
function ws_reply($options) { $svr = new WSService($options); $svr->reply(); }
$imageName = $i . "." . "jpg"; $file_saved = file_put_contents($imageName, $f); } else { $imageName = $i . "." . "jpg"; $file_saved = file_put_contents("/tmp/" . $imageName, $f); } } } if ($file_saved) { $resPayload = <<<XML <ns1:response xmlns:ns1="http://wso2.org/wsfphp/samples/mtom">Image Saved</ns1:response> XML; } else { $resPayload = <<<XML <ns1:response xmlns:ns1="http://wso2.org/wsfphp/samples/mtom">Image Saving Failed</ns1:response> XML; } $returnMessage = new WSMessage($resPayload); return $returnMessage; } $alice_cert = ws_get_cert_from_file("../../keys/alice_cert.cert"); $pub_key = ws_get_cert_from_file("../../keys/bob_cert.cert"); $pvt_key = ws_get_key_from_file("../../keys/bob_key.pem"); $policy_xml = file_get_contents("policySignOnlyMtom.xml"); $policy = new WSPolicy($policy_xml); $sec_token = new WSSecurityToken(array("privateKey" => $pvt_key, "certificate" => $pub_key, "receiverCertificate" => $alice_cert)); $actions = array("http://wso2.org/upload" => "upload"); $operations = array("upload" => "getAttachment"); $server = new WSService(array("operations" => $operations, "actions" => $actions, "requestXOP" => TRUE, "policy" => $policy, "securityToken" => $sec_token)); $server->reply();
<?php /* * Copyright 2005,2008 WSO2, Inc. http://wso2.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* sample test payload */ $requestPayloadString = <<<XML <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Header/><soapenv:Body><ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples"><text>Hello World!</text></ns1:echoString></soapenv:Body></soapenv:Envelope> XML; function echoFunction($inMessage) { $outMessage = new WSMessage($inMessage->str); return $outMessage; } $operations = array("echoString" => "echoFunction"); $service = new WSService(array("operations" => $operations)); $service->reply($requestPayloadString);
<?php $reqPayloadString = <<<XML <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Header/> <soapenv:Body> <ns1:getFault xmlns:ns1="http://php.axis2.org/samples"> <text>Hello World!</text> </ns1:getFault> </soapenv:Body></soapenv:Envelope> XML; function sendFault($inMessage) { return new WSFault(NULL, NULL); } $operations = array("getFault" => "sendFault"); $svr = new WSService(array("operations" => $operations)); $svr->reply($reqPayloadString);
function procesar() { toba::logger_ws()->debug('Servicio Llamado: ' . $this->info['basica']['item']); toba::logger_ws()->set_checkpoint(); set_error_handler('toba_logger_ws::manejador_errores_recuperables', E_ALL); $this->validar_componente(); //-- Pide los datos para construir el componente, WSF no soporta entregar objetos creados $clave = array(); $clave['proyecto'] = $this->info['objetos'][0]['objeto_proyecto']; $clave['componente'] = $this->info['objetos'][0]['objeto']; list($tipo, $clase, $datos) = toba_constructor::get_runtime_clase_y_datos($clave, $this->info['objetos'][0]['clase'], false); agregar_dir_include_path(toba_dir() . '/php/3ros/wsf'); $opciones_extension = toba_servicio_web::_get_opciones($this->info['basica']['item'], $clase); $wsdl = strpos($_SERVER['REQUEST_URI'], "?wsdl") !== false; $sufijo = 'op__'; $metodos = array(); $reflexion = new ReflectionClass($clase); foreach ($reflexion->getMethods() as $metodo) { if (strpos($metodo->name, $sufijo) === 0) { $servicio = substr($metodo->name, strlen($sufijo)); $prefijo = $wsdl ? '' : '_'; $metodos[$servicio] = $prefijo . $metodo->name; } } $opciones = array(); $opciones['serviceName'] = $this->info['basica']['item']; $opciones['classes'][$clase]['operations'] = $metodos; $opciones = array_merge($opciones, $opciones_extension); $this->log->debug("Opciones del servidor: " . var_export($opciones, true), 'toba'); $opciones['classes'][$clase]['args'] = array($datos); toba::logger_ws()->set_checkpoint(); $service = new WSService($opciones); $service->reply(); $this->log->debug("Fin de servicio web", 'toba'); }