Sziasztok !
SOAP::Lite (v 0.67) segítségével próbálok írni egy kis webszolgáltatást egy Debian/Testing gépen, de elakadtam: ugyanis sehogy sem tudom ráerőltetni a programra, hogy a válasz milyen típusú legyen.
A soap üzenetek a következők :
-a kérés
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="MYNS" xmlns:types="MYNS/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:GetUsers />
</soap:Body>
</soap:Envelope>
-a válasz
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:namesp1="http://namespaces.soaplite.com/perl"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetUsersResponse xmlns="MYNS">
<return xsi:type="namesp1:usersRst">
<count xsi:type="xsd:int">2</count>
<Users soapenc:arrayType="namesp1:user[2]" xsi:type="soapenc:Array">
<item xsi:type="namesp1:user">
<username xsi:type="xsd:string">sarika</username>
<id xsi:type="xsd:int">1000</id>
</item>
<item xsi:type="namesp1:user">
<username xsi:type="xsd:string">klarika</username>
<id xsi:type="xsd:int">1001</id>
</item>
</Users>
</return>
</GetUsersResponse>
</soap:Body>
</soap:Envelope>
A
'<GetUsersResponse xmlns="MYNS">'
helyett
'<namesp1:GetUsersResponse xmlns:namesp1="urn:MYNS">'
szeretnék,és az elejéről xmlns:namesp1 tünjön el.
Maga script :
#!/usr/bin/perl
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI-> dispatch_to('MYNS')-> handle;
package MYNS;
sub to_struct
{
$ret =
{
username => $_[1],
id => $_[0]
};
return SOAP::Data->type("user" => $ret);
}
sub GetUsers
{
@tmp = ();
$cnt = 0;
$cnt++;
push @tmp,to_struct (1000,"sarika");
$cnt++;
push @tmp,to_struct (1001,"klarika");
$retval = SOAP::Data->name("return" => \SOAP::Data->value(
SOAP::Data->name("count" => $cnt)->type("int"),
SOAP::Data->name("Users" => \@tmp)))->type("usersRst");
return $retval;
}
Any help from anyone
are welcome !
- 1093 megtekintés