PHP SOAP
Publicado por Felipe (1 intervención) el 06/12/2012 15:15:27
Hola, estoy intentando pasar un script en Perl a PHP este consume un webservice:
en Perl: (funciona)
en PHP:
Cuando pruebo el código PHP me arroja el siguiente error:
el tema es que no se como pasarle el tipo de dato, en el codigo Perl se hace con ->type($ns.":".$objectType), ya que este es complex, aca la definición del método getRequest:
si me pueden ayudar muchas gracias
en Perl: (funciona)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[
my $connection = SOAP::Lite
-> proxy("http://$credentials\@$ARGV[0]/xmlservice", timeout=>10)
-> ns("http://www.extremenetworks.com/XMLSchema/xos/switch", "switch") # namespace and prefix for operation
-> autotype(0)
-> envprefix('SOAP-ENV'); # envelope prefix
my $method = SOAP::Data->name('switch:getRequest');
my $ns = "vlan";
my $objectType = "VlanConfig";
my $indexParam ="name";
my $indexParamValue ="sp-600";
my @params = ( SOAP::Data->name("filter" =>
\SOAP::Data->value(SOAP::Data->name("$indexParam" => $indexParamValue)))->type($ns.":".$objectType),
SOAP::Header->name("hdr" =>
\SOAP::Data->value(SOAP::Data->name("sessionId" => $sessionId),
SOAP::Data->name("reqId" => "1")))
);
my $response = $connection->call($method => @params);
en PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ns = "vlan";
$objectType = "VlanConfig";
$indexParam ="name";
$indexParamValue ="sp-600";
$endpoint = "http://192.168.60.2/xmlservice";
$mynamespace = "http://www.extremenetworks.com/XMLSchema/xos/switch";
$client = new nusoap_client($endpoint, false);
$param = array(
"filter"=>array($indexParam => $indexParamValue),
"hdr"=>array("sessionId"=>$sessionId, "reqId"=>1)
);
$response = $client->call('getRequest', $param, $mynamespace);
Cuando pruebo el código PHP me arroja el siguiente error:
1
2
3
4
5
Array
(
[faultcode] => SOAP-ENV:Client
[faultstring] => Validation constraint violation: data type mismatch xsd:int in element <reqId>
)
el tema es que no se como pasarle el tipo de dato, en el codigo Perl se hace con ->type($ns.":".$objectType), ya que este es complex, aca la definición del método getRequest:
1
2
3
4
5
6
7
8
9
10
11
<xsd:element name="getRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="filter" type="common:ExosBase"/>
<xsd:element name="hdr" type="common:ClientHeader" minOccurs="0"/>
<xsd:element name="switchObject" type="xsd:anyType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="action" type="xsd:string"/>
<xsd:attribute name="maxSize" type="xsd:int"/>
</xsd:complexType>
</xsd:element>
si me pueden ayudar muchas gracias
Valora esta pregunta


0