PHP - Pasar un xml por php

 
Vista:

Pasar un xml por php

Publicado por Juanlu (1 intervención) el 18/09/2014 11:53:48
Hola buenas, tengo que atacar desde un php un servicio SOAP, para hacerlo me piden que envie la solicitud mediante un xml.

El xml es el siguinte:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'<?xml version="1.0" standalone="no"?>
	<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
			<soapenv:Header>
					<vodh:VODHeader xmlns:vodh="http://www.vodafone.com/soap/header/">
							<vodh:commandId>ServiceDelivery</vodh:commandId>
							<vodh:authentication>
									<vodh:username>xxxx</vodh:username>
									<vodh:password>xxxxxxx</vodh:password>
							</vodh:authentication>
							<vodh:service>
									<vodh:serviceID>xxxxxx</vodh:serviceID>
									<vodh:serviceType>SMS</vodh:serviceType>
							</vodh:service>
					</vodh:VODHeader>
			</soapenv:Header>
			<soapenv:Body>
					<vodb:VODBody xmlns:vodb="http://www.vodafone.com/soap/body/" version="1.0">
							<vodb:contextID></vodb:contextID>
							<vodb:destAddress>666666666</vodb:destAddress>
							<vodb:subServiceId>123456</vodb:subServiceId>
							<vodb:messageBody>texto de prueba</vodb:messageBody>
							<vodb:bodyIsText>true</vodb:bodyIsText>
							<vodb:deliveryReport>false</vodb:deliveryReport>
							<vodb:priorityFlag>0</vodb:priorityFlag>
							<vodb:dataCodingScheme>0</vodb:dataCodingScheme>
							<vodb:sourceTON>0</vodb:sourceTON>
							<vodb:destTON>1</vodb:destTON>
							<vodb:sourceNPI>0</vodb:sourceNPI>
							<vodb:destNPI>1</vodb:destNPI>
							<vodb:esmClass>0</vodb:esmClass>
							<vodb:protocolId>0</vodb:protocolId>
					</vodb:VODBody>
			</soapenv:Body>
	</soapenv:Envelope>'

¿como puedo hacer esa petición desde php? he visto varias opciones pero no entiendo muy bien lo que tengo que hacer.

Por ejemplo para la cabecera lo hago así:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class autorizacion {
 
        public $username;
        public $password;
 
        public function __construct($usuario, $pass) {
            $this->username = $usuario;
            $this->password = $pass;
        }
    }
 
    class servicio {
        public $serviceID;
        public $serviceType;
 
        public function __construct($serviceID, $serviceType) {
            $this->serviceID = $serviceID;
            $this->serviceType = $serviceType;
        }
    }
 
    $usuario = "xxxxx";
    $pass ="xxxxxxx";
    $url = "http://serv.prep.cdm.vodafone.es/soap/SOAPSMS";
    $cliente = new SoapClient($url, array("trace" => 1, "exception" => 0));
    // crear cabecera
    $autorizar = new autorizacion($usuario, $pass);
    $servicio = new servicio("xxxxxxxxxx", "SMS");
    $cabecera[] = new SoapHeader("http://www.w3.org/2001/XMLSchema-instance", "commandId", "ServiceDelivery", FALSE);
    $cabecera[] = new SoapHeader("http://www.w3.org/2001/XMLSchema-instance", "authentication", $autorizar, FALSE);
    $cabecera[] = new SoapHeader("http://www.w3.org/2001/XMLSchema-instance/", "service", $servicio, FALSE);

pero ya no se como meter el body

¿me podéis ayudar?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder