SOAP-PHP5-WSDL:Cannot retrn complex type obj from SOAPServer
Posted: Mon Aug 28, 2006 9:00 am
Hi Folks,
I have been trying to solve the following problem for three days now.. I really hope somebody can help me!
Testsystem:
---------------
Windows XP - XAMPP - PHP 5.1.4
Problem:
-----------
When I try to return an object from the SOAP-Server the SOAP-Client doesn't receive this object. The client
just receives an empty stdClass-object. But the other way around works: The Server can receive complex objects
from the client.
Code:
-------
/***************** CLIENT ***************/
/***************** SERVER ******************/
Actual Output from Client via var_dump:
--------------------------------------------------
object(stdClass)#4 (1) { ["ChangeServiceResult"]=> object(stdClass)#5 (0) { } }
There should be the strings "this is a message", "and a location" from the Server somewhere, but the server just sends an empty object back. I really dont know what the problem is..
the relevant parts from the wsdl file are:
---------------------------------------------------
I have been trying to solve the following problem for three days now.. I really hope somebody can help me!
Testsystem:
---------------
Windows XP - XAMPP - PHP 5.1.4
Problem:
-----------
When I try to return an object from the SOAP-Server the SOAP-Client doesn't receive this object. The client
just receives an empty stdClass-object. But the other way around works: The Server can receive complex objects
from the client.
Code:
-------
/***************** CLIENT ***************/
Code: Select all
<?php
try {
$client = new SOAPClient('http://localhost/WebServiceSchnittstelle_fuer_CancelOrder_und_ChangeService/RequestBrokerService_1_0.wsdl',
array("trace"=>1, "exceptions"=>1));
$myOrder = new Order("hal","li","ha","lo");
var_dump($client->ChangeService(new ChangeService($myOrder)));
}
catch (SOAPFault $f) {
print $f->faultstring;
}
class ChangeService {
public $order;
function __construct($order) {
$this->order=$order;
}
}
class CancelOrder {
public $orderId;
function __construct($orderId) {
$this->orderId = $orderId;
}
}
class Order {
protected $customer; // Typ:Customer
protected $OrderDate; // Typ:DateTime
protected $orderDetails; // Array vom Typ OrderDetail
protected $orderId; // Typ: String
function __construct($customer, $OrderDate, $orderDetails, $orderId) {
$this->customer=$customer;
$this->OrderDate=$OrderDate;
$this->orderDetails=$orderDetails;
$this->orderId=$orderId;
}
}
?>/***************** SERVER ******************/
Code: Select all
<? php
try {
$server = new SoapServer('RequestBrokerService_1_0.wsdl');
$server->setClass("RequestBrokerService");
$server->handle();
}
catch (SOAPFault $f) {
print $f->faultstring;
}
class RequestBrokerService {
public function ChangeService() {
return new ChangeServiceResult(new ArgumentOutOfRangeResult("this is a message", "and a location"));
}
}
class ChangeServiceResult {
public $ChangeServiceResult;
function __construct($objektreferenz) {
$this->ChangeServiceResult=$objektreferenz;
}
}
abstract class RequestBrokerServiceResult {
protected $message; // Typ: String
function __construct($message) {
$this->message=$message;
}
}
abstract class ArgumentResult extends RequestBrokerServiceResult {
protected $source; // Typ: String
}
class ArgumentOutOfRangeResult extends ArgumentResult {
function __construct($message, $source) {
$this->message=$message;
$this->source=$source;
}
}
?>Actual Output from Client via var_dump:
--------------------------------------------------
object(stdClass)#4 (1) { ["ChangeServiceResult"]=> object(stdClass)#5 (0) { } }
There should be the strings "this is a message", "and a location" from the Server somewhere, but the server just sends an empty object back. I really dont know what the problem is..
the relevant parts from the wsdl file are:
---------------------------------------------------
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="this_is_a_namespace" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="this_is_a_namespace" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="this_is_a_namespace">
<s:complexType name="RequestBrokerServiceResult" abstract="true" />
<s:element name="ChangeService">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="order" type="tns:Order" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="Order">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="OrderId" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="OrderDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="OrderDetails" type="tns:ArrayOfOrderDetail" />
<s:element minOccurs="0" maxOccurs="1" name="Customer" type="tns:Customer" />
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfOrderDetail">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="OrderDetail" nillable="true" type="tns:OrderDetail" />
</s:sequence>
</s:complexType>
<s:complexType name="OrderDetail" />
<s:complexType name="Customer">
<s:sequence>
...
</s:sequence>
</s:complexType>
<s:element name="ChangeServiceResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ChangeServiceResult" type="tns:RequestBrokerServiceResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArgumentResult" abstract="true">
<s:complexContent mixed="false">
<s:extension base="tns:RequestBrokerServiceResult">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Source" type="s:string" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="ChangeServiceSoapIn">
<wsdl:part name="parameters" element="tns:ChangeService" />
</wsdl:message>
<wsdl:message name="ChangeServiceSoapOut">
<wsdl:part name="parameters" element="tns:ChangeServiceResponse" />
</wsdl:message>
<wsdl:portType name="RequestBrokerServiceSoap">
<wsdl:operation name="ChangeService">
<wsdl:input message="tns:ChangeServiceSoapIn" />
<wsdl:output message="tns:ChangeServiceSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="RequestBrokerServiceSoap" type="tns:RequestBrokerServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ChangeService">
<soap:operation soapAction="this_is_a_namespace/ChangeService" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="RequestBrokerServiceSoap12" type="tns:RequestBrokerServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ChangeService">
<soap12:operation soapAction="this_is_a_namespace/ChangeService" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RequestBrokerService">
<wsdl:port name="RequestBrokerServiceSoap" binding="tns:RequestBrokerServiceSoap">
<soap:address location="http://localhost/WebServiceSchnittstelle_fuer_CancelOrder_und_ChangeService/SoapServerWSS1.php" />
</wsdl:port>
<wsdl:port name="RequestBrokerServiceSoap12" binding="tns:RequestBrokerServiceSoap12">
<soap12:address location="http://localhost/WebServiceSchnittstelle_fuer_CancelOrder_und_ChangeService/SoapServerWSS1.php" />
</wsdl:port>
</wsdl:service>
[/syntax="xml"]
I appreciate every kind of a tip to solve my problem...
Thank you !