php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35593 SOAP Response is incorrect
Submitted: 2005-12-08 03:55 UTC Modified: 2005-12-10 07:31 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: lixd at dragonsoft dot com dot cn Assigned: dmitry (profile)
Status: Not a bug Package: SOAP related
PHP Version: 5CVS-2005-12-09 (snap) OS: Win2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lixd at dragonsoft dot com dot cn
New email:
PHP Version: OS:

 

 [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>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-08 04:11 UTC] lixd at dragonsoft dot com dot cn
I am sorry for huge text
you can get full code here
http://218.85.132.173/vnet.rar

or view test.wsdl here
http://218.85.132.173/test.wsdl
 [2005-12-08 08:22 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2005-12-08 08:42 UTC] lixd at dragonsoft dot com dot cn
thanks for you reply. I try it and hope it can work,but I am disappointed...
 [2005-12-09 09:06 UTC] sniper@php.net
Dmitry, can you help?
 [2005-12-09 19:54 UTC] dmitry@php.net
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.
 [2005-12-10 07:31 UTC] lixd at dragonsoft dot com dot cn
yeah...
thank you so much....
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC