|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-12-08 03:55 UTC] lixd at dragonsoft dot com dot cn
Description: ------------ In win2000\apache 2.0.53\php5.0.4,I wrote some code for test.wsdl(I can't modify it, for some reason),and test by http://192.168.0.228/vnet/client.php,but I can't get result in expectation. Reproduce code: --------------- <?xml version="1.0" encoding="utf-8"?> <wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://192.168.0.228/vnet/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://192.168.0.228/vnet/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> <wsdl:types> <s:schema elementFormDefault="qualified" targetNamespace="http://192.168.0.228/vnet/"> <s:element name="Grant"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="APID" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="Authenticator" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="TimeStamp" type="s:string" /> </s:sequence> </s:complexType> </s:element> <s:element name="GrantResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="GrantResult" type="tns:GrantResult" /> </s:sequence> </s:complexType> </s:element> <s:complexType name="GrantResult"> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="APID" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="Authenticator" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="TimeStamp" type="s:string" /> </s:sequence> </s:complexType> </s:schema> </wsdl:types> <wsdl:message name="GrantSoapIn"> <wsdl:part name="parameters" element="tns:Grant" /> </wsdl:message> <wsdl:message name="GrantSoapOut"> <wsdl:part name="parameters" element="tns:GrantResponse" /> </wsdl:message> <wsdl:portType name="TestSoap"> <wsdl:operation name="Grant"> <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Grant Interface</documentation> <wsdl:input message="tns:GrantSoapIn" /> <wsdl:output message="tns:GrantSoapOut" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="TestSoap" type="tns:TestSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <wsdl:operation name="Grant"> <soap:operation soapAction="http://192.168.0.228/vnet/Grant" style="document" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="Test"> <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Description</documentation> <wsdl:port name="TestSoap" binding="tns:TestSoap"> <soap:address location="http://192.168.0.228/vnet/server.php" /> </wsdl:port> </wsdl:service> </wsdl:definitions> <?php //server.php class GrantResult{ public $APID; } function Grant($req){ $res = new GrantResult(); $res->APID = $req->APID; return $res; } $server = new SoapServer("test.wsdl", array('soap_version' => SOAP_1_1)); $server->addFunction("Grant"); $server->handle(); ?> <?php //client.php header("content-type:text/html;charset=utf-8"); class GrantRequest{ public $APID = "14000019"; } try { $opts = array('trace' => 1, 'exceptions' => 0,'soap_version' => SOAP_1_1); $client = new SoapClient("test.wsdl", $opts); $req = new GrantRequest(); $data = $client->Grant($req); print "RequestHeader :<hr>\n".htmlspecialchars($client->__getLastRequestHeaders()) ."<hr>\n"; print "Request :<hr>\n".htmlspecialchars($client->__getLastRequest()) ."<hr>\n"; print "ResponseHeader :<hr>\n".htmlspecialchars($client->__getLastResponseHeaders()) ."<hr>\n"; print "Response:<hr>\n".htmlspecialchars($client->__getLastResponse())."\n"; } catch (SOAPFault $e) { print "<hr>Error<hr>"; print $e; } Expected result: ---------------- <?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://192.168.0.228/vnet/"> <SOAP-ENV:Body> <ns1:GrantResponse> <ns1:GrantResult> <ns1:APID>14000019</ns1:APID> </ns1:GrantResult> </ns1:GrantResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Actual result: -------------- <?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://192.168.0.228/vnet/"> <SOAP-ENV:Body> <ns1:GrantResponse /> </SOAP-ENV:Body> </SOAP-ENV:Envelope> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 13:00:01 2025 UTC |
SOAP's Grant() operation should returns "GrantResponse" element, but you tries to return "GrantResult" element directly. This is your mistake. The proper server code: function Grant($req){ $res = new GrantResult(); $res->APID = $req->APID; return array("GrantResult"=>$res); } Now you will get that you expect.