3 require_once
'ComposerAdvicePortafirmas.php';
4 require_once
'WSComunSoapServer.php';
8 private $fnCallback = null;
20 $currentURL = (isset($_SERVER[
'HTTPS']) ?
"https" :
"http") .
"://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]";
21 if (is_string($serviceURL)) {
22 $currentURL = $serviceURL;
26 if (isset($_REQUEST[
'wsdl'])) {
27 $baseWSDL = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR .
'PFAdviceWS.wsdl');
28 $finalWSDL = str_replace(
'http://servidor/AdviceService', $currentURL, $baseWSDL);
30 header(
'Content-type: application/xml');
37 if (isset($_REQUEST[
'types']) && ($serviceURL !==
false)) {
38 $xsdContent = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR .
'WebServiceTypes.xsd');
40 header(
'Content-type: application/xml');
50 'type_name' =>
'userJob',
51 'type_ns' =>
'urn:juntadeandalucia:cice:pfirma:type:v2.0',
52 'from_xml' =>
'PFAdviceServer\PFAdviceSOAPServer::userJob_from_xml',
58 $service->fnCallback = $fnCallback;
61 $server = new \WSComunSoapServer($currentURL .
'?wsdl', $opts);
62 $server->setObject($service);
67 public static function userJob_from_xml($xml) {
68 $sxe = simplexml_load_string($xml);
71 $obj = new \stdClass();
72 $obj->identifier = (string) $sxe->identifier;
75 $attributes =
"@attributes";
76 if (isset($sxe->attributes(
'xsi', TRUE)->type)) {
77 $obj->$attributes = array(
'type' => (
string) $sxe->attributes(
'xsi', TRUE)->type);
78 } elseif (isset($sxe->attributes()->type)) {
79 $obj->$attributes = array(
'type' => (
string) $sxe->attributes()->type);
83 if (SoapObject::endsWith((
string) $sxe->attributes()->type,
':user')) {
85 } elseif (SoapObject::endsWith((
string) $sxe->attributes()->type,
':job')) {
92 if (isset($sxe->name)) {
93 $obj->name = (string) $sxe->name;
95 if (isset($sxe->surname1)) {
96 $obj->surname1 = (string) $sxe->surname1;
98 if (isset($sxe->surname2)) {
99 $obj->surname2 = (string) $sxe->surname2;
103 if (isset($sxe->description)) {
104 $obj->description = (string) $sxe->description;
120 private function objectTree2array($obj)
122 if (is_array($obj) || is_object($obj))
125 foreach ($obj as $key => $value)
127 $result[$key] = $this->objectTree2array($value);
153 if (!isset($oData->authentication)) {
154 throw new \Exception(
'tag authentication required');
156 if (!isset($oData->request)) {
157 throw new \Exception(
'tag request required');
161 $vAuth = $this->objectTree2array($oData->authentication);
162 $vReq = $this->objectTree2array($oData->request);
164 if (isset($oData->signature)) {
165 $vSign = $this->objectTree2array($oData->signature);
169 $oAuth = authentication::fromSoap($vAuth);
170 $oReq = request::fromSoap($vReq);
172 if (!is_null($vSign)) {
173 $oSign = signature::fromSoap($vSign);
177 $return = call_user_func($this->fnCallback, $oAuth, $oReq, $oSign);
178 if (is_bool($return)) {
179 return array(
'result' => $return);
181 if ($return instanceof \SoapFault) {
197 $encIden = utf8_encode($identifier);
198 $encDesc = utf8_encode($description);
200 $array_details = array(
201 'identifier' => $encIden,
202 'description' => $encDesc
204 return new \SoapFault(
"Server",
"[$encIden] $encDesc", null, $array_details,
'pfirmaException');
static createExceptionInfo($identifier, $description)
updateRequestStatus($oData)
static createSoapServer($fnCallback, $serviceURL=true)